Skip to content

feat(vllm): capture generation artifacts (5/6) - #14975

Open
biswapanda wants to merge 1 commit into
biswapanda/generation-artifact-04-fsspecfrom
biswapanda/generation-artifact-05-capture
Open

biswapanda wants to merge 1 commit into
biswapanda/generation-artifact-04-fsspecfrom
biswapanda/generation-artifact-05-capture

Conversation

@biswapanda

@biswapanda biswapanda commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Add a bounded vLLM producer session that captures requested generation data, validates capacity before inference, encodes generation_artifact_v1, and delivers the resulting opaque object through either storage target from the lower layers.

What changes

  • Adds VllmGenerationArtifactSession with explicit admission, per-delta capture, finalization, and release.
  • Supports the vLLM content names moe_routes and selected_logprobs; unknown content names fail fast.
  • Requires format generation_artifact_v1, codec zstd, and one generated choice.
  • Requires Dynamo --enable-rl and vLLM --enable-return-routed-experts when moe_routes is requested.
  • Resolves router IDs and expert counts from model configuration and rejects missing or conflicting model metadata.
  • Supports nonzero routed_experts_prompt_start and validates the returned route tensor against the effective sequence range.
  • Retains prompt/completion token deltas and selected logprobs within admitted token bounds, while retaining only the latest full routed-expert tensor.
  • Produces a ready receipt with format, sorted contents, byte count, SHA-256, and opaque object ID.

Admission and resource bounds

Admission happens before generation and estimates the worst-case canonical payload from prompt length, max_tokens, model router count, experts per token, manifest overhead, and target byte limit. It rejects the request before inference if the decoded or conservatively bounded encoded object cannot fit.

  • Decoded bytes default to a hard 64 MiB ceiling and can be lowered with DYN_GENERATION_ARTIFACT_MAX_DECODED_BYTES.
  • Encoding/upload concurrency defaults to 2 per event loop and is controlled by DYN_GENERATION_ARTIFACT_PIPELINE_CONCURRENCY.
  • Prompt, completion, logprob, route, router-count, manifest, and target limits are revalidated as data arrives and again before encoding.
  • release() clears captured tokens, routes, counters, and admission state.

Cancellation semantics

Encoding runs off the event loop and delivery runs behind a bounded semaphore. If the caller is cancelled before an operation starts, the queued task is cancelled. If cancellation arrives after encoding/upload starts, the operation continues in the background and retains its semaphore slot until completion, avoiding an in-process ambiguous half-write and unbounded replacement work. A worker-process crash still requires external object-store reconciliation and is not solved in this PR.

Architecture boundary

This is the vLLM schema/capture layer. The common storage writer still receives only bytes plus a target and remains unaware of routed experts or training experiences. Handler/frontend wiring is intentionally deferred to #14978.

Reviewer guide

  • components/src/dynamo/vllm/generation_artifact.py: admission, capture, model-layout validation, finalization, and cancellation-safe delivery.
  • components/src/dynamo/vllm/tests/test_generation_artifact_capture.py: bounds, alignment, cancellation, concurrency, and receipt behavior.
  • components/src/dynamo/common/generation_artifact_storage.py: side-effect-free target validation used during admission.

Validation

  • Format and capture suites: 62 passed.
  • Storage suite: 48 passed.
  • Local MinIO E2E: 2 passed.
  • Independent correctness/security review completed with no remaining actionable findings at the time of publication.

PR stack

Review and merge bottom-up. Each PR is based on the preceding stack branch, so its diff contains only that layer. The original umbrella #14385 remains open and unchanged as a reference.

Order PR Layer
1 #14977 Protocol and opaque receipt projection
2 #14979 vLLM binary format
3 #14980 Presigned HTTP PUT delivery
4 #14976 Managed fsspec storage
5 #14975 Bounded vLLM capture
6 #14978 vLLM and frontend integration

Signed-off-by: Biswa Panda <biswa.panda@gmail.com>
raise ArtifactCaptureError(
"completion tokens exceed the admitted token bounds"
)
if "moe_routes" in self.contents and routed_experts is not None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The retained route-tensor limit is based on the source tensor's assumed int64 representation, while admission budgets routes using their compact wire dtype. For models with many routers and small expert IDs, a valid int64 vLLM tensor can therefore retain up to roughly 8x the configured decoded-byte limit until finalization, despite the request being admitted under that limit. Canonicalize the tensor before retaining it and enforce the admitted bound on that canonical representation.

🤖 AI Fix

Convert routed_experts to its validated canonical integer dtype before storing it and compare the canonical byte count against the admission budget.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend::vllm Relates to the vllm backend feat size/XXL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant