{
  "language": "en",
  "title": "A batch changes with new requests and completion",
  "description": "The example has five scheduler iterations for A, B and C. The layout does not change. The state display records membership and completion.",
  "caption": "Mixed prefill/decode scheduling is an assumption. Horizontal spacing shows iteration sequence, not elapsed time. These batches are an explanatory example.",
  "alt": "Continuous batching: with five example batches, B is completed after batch 3, A is completed after batch 4 and C is completed after batch 5.",
  "stateLabels": {
    "iteration": "Iteration",
    "batch": "Current batch",
    "A": "Request A",
    "B": "Request B",
    "C": "Request C",
    "finished": "Completed requests"
  },
  "scenarios": [
    {
      "id": "abc",
      "title": "Three requests / five iterations",
      "description": "Start with the full structure. Play or step to examine each batch and its completion events.",
      "initial": {
        "iteration": "Not started",
        "batch": "—",
        "A": "Not admitted",
        "B": "Not admitted",
        "C": "Not admitted",
        "finished": "—"
      },
      "unselected": [],
      "steps": [
        {
          "title": "Admit A and run prefill",
          "description": "The server receives A, and A enters the first example batch. The state below updates after the operation.",
          "active": [
            "b1"
          ],
          "paths": [],
          "state": {
            "iteration": "1",
            "batch": "A: prefill",
            "A": "Prefill",
            "B": "Not admitted",
            "C": "Not admitted",
            "finished": "—"
          },
          "duration": 3000
        },
        {
          "title": "A decodes while B prefills",
          "description": "The same batch contains A decode work and B prefill work. These are concurrent batch members. They are not two subsequent batches.",
          "active": [
            "b2"
          ],
          "paths": [
            "t1"
          ],
          "state": {
            "iteration": "2",
            "batch": "A: decode + B: prefill",
            "A": "Decode",
            "B": "Prefill",
            "C": "Not admitted",
            "finished": "—"
          },
          "duration": 3000
        },
        {
          "title": "Decode A and B",
          "description": "The batch for iteration 3 contains the two requests. B does not have completed status at this step.",
          "active": [
            "b3"
          ],
          "paths": [
            "t2"
          ],
          "state": {
            "iteration": "3",
            "batch": "A: decode + B: decode",
            "A": "Decode",
            "B": "Decode",
            "C": "Not admitted",
            "finished": "—"
          },
          "duration": 3000
        },
        {
          "title": "End of B after batch 3",
          "description": "Completion is an event after execution. B is not an active member of the next batch.",
          "active": [
            "b3"
          ],
          "paths": [
            "finishB"
          ],
          "state": {
            "iteration": "3 completed",
            "batch": "At this step, no batch runs.",
            "A": "The request is active and waits for the next batch.",
            "B": "Completed",
            "C": "Not admitted",
            "finished": "B"
          },
          "duration": 3000
        },
        {
          "title": "Admit C with A",
          "description": "Iteration 4 contains A decode and C prefill. B is not in this batch because it was completed before the batch.",
          "active": [
            "b4"
          ],
          "paths": [
            "t3"
          ],
          "state": {
            "iteration": "4",
            "batch": "A: decode + C: prefill",
            "A": "Decode",
            "B": "Completed",
            "C": "Prefill",
            "finished": "B"
          },
          "duration": 3000
        },
        {
          "title": "End of A after batch 4",
          "description": "A is completed after the batch. C stays active.",
          "active": [
            "b4"
          ],
          "paths": [
            "finishA"
          ],
          "state": {
            "iteration": "4 completed",
            "batch": "At this step, no batch runs.",
            "A": "Completed",
            "B": "Completed",
            "C": "The request is active and waits for the next batch.",
            "finished": "A, B"
          },
          "duration": 3000
        },
        {
          "title": "Only C is active",
          "description": "Iteration 5 runs a decode step for C. After a request is completed, it does not enter the batch again.",
          "active": [
            "b5"
          ],
          "paths": [
            "t4"
          ],
          "state": {
            "iteration": "5",
            "batch": "C: decode",
            "A": "Completed",
            "B": "Completed",
            "C": "Decode",
            "finished": "A, B"
          },
          "duration": 3000
        },
        {
          "title": "C is completed and the outcome stays.",
          "description": "All three example requests were completed. The player stays here until replay or an explicit seek.",
          "active": [
            "b5"
          ],
          "paths": [
            "finishC"
          ],
          "state": {
            "iteration": "5 completed",
            "batch": "Empty",
            "A": "Completed",
            "B": "Completed",
            "C": "Completed",
            "finished": "A, B, C"
          },
          "duration": 3000
        }
      ]
    }
  ],
  "version": 1,
  "targets": {
    "b1": {
      "id": "flow-b1",
      "kind": "node",
      "label": "Batch 1"
    },
    "b2": {
      "id": "flow-b2",
      "kind": "node",
      "label": "Batch 2"
    },
    "b3": {
      "id": "flow-b3",
      "kind": "node",
      "label": "Batch 3"
    },
    "b4": {
      "id": "flow-b4",
      "kind": "node",
      "label": "Batch 4"
    },
    "b5": {
      "id": "flow-b5",
      "kind": "node",
      "label": "Batch 5"
    },
    "t1": {
      "id": "flow-t1",
      "kind": "edge",
      "label": "Next iteration 2"
    },
    "t2": {
      "id": "flow-t2",
      "kind": "edge",
      "label": "Next iteration 3"
    },
    "t3": {
      "id": "flow-t3",
      "kind": "edge",
      "label": "Next iteration 4"
    },
    "t4": {
      "id": "flow-t4",
      "kind": "edge",
      "label": "Next iteration 5"
    },
    "finishB": {
      "id": "flow-finishB",
      "kind": "edge",
      "label": "B completion event"
    },
    "finishA": {
      "id": "flow-finishA",
      "kind": "edge",
      "label": "A completion event"
    },
    "finishC": {
      "id": "flow-finishC",
      "kind": "edge",
      "label": "C completion event"
    }
  },
  "sources": [
    {
      "file": "content/blog/2026-06-11_life-of-a-request-vllm/post.md",
      "description": "Mechanism and scope from the current article; concrete requests/tokens are illustrative."
    },
    {
      "file": "/Users/jiwenbo/Documents/GitHub/Blog_Illustration_Skill/examples/animated-flow-2026-10-16/01-vllm-batching/diagram.svg",
      "sha256": "6a1a0718795a7df85c7824cf0166c1f5a129c3bab7b6faf009efd4e4c3215b80",
      "description": "Skill source illustration; imported, not an observed runtime trace."
    }
  ],
  "limitations": [
    "Playback time helps show the example. It is not measured latency or throughput.",
    "This is a constructed execution trace. It is not a captured vLLM serving run.",
    "Playback timing is an example, not measured runtime. The original SVG from the Skill has no changes."
  ]
}
