Skip to content

fix(mocker): use logical KV tokens for decode timing [DYN-3851] - #12583

Merged
PeaBrane merged 3 commits into
mainfrom
rupei/mocker-logical-active-kv
Aug 3, 2026
Merged

fix(mocker): use logical KV tokens for decode timing [DYN-3851]#12583
PeaBrane merged 3 commits into
mainfrom
rupei/mocker-logical-active-kv

Conversation

@PeaBrane

@PeaBrane PeaBrane commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Align Mocker decode timing with the scheduled logical KV-token semantics used by profiler-derived performance data.
  • Stop using distinct physically resident blocks as a decode-compute proxy, which undercounts heterogeneous batches when prefix caching deduplicates shared blocks.
  • Keep the full logical sum uncapped for interpolation while saturating only the legacy polynomial model's utilization ratio at 1.0.

This does not change KV allocation, prefix-cache ownership, routing, or direct AIC decode prediction.

Details

  • vLLM ordinary and speculative decode now pass the summed context lengths of the requests scheduled for decode.
  • SGLang uses the same uncapped logical-KV meaning.
  • Removed reservation-size accessors that were only needed by the physical-block timing proxy.

Where should the reviewer start?

Start with lib/mocker/src/scheduler/vllm/core.rs for the semantic change and lib/mocker/src/common/perf_model.rs for the timing-model boundary.

Related Issues

  • Confirmed — no related issue

Validation

  • cargo test -p dynamo-mocker test_fpm_prefill_and_decode_mixed_batch -- --nocapture (vLLM and SGLang cases passed locally and on a clean Linux checkout)

  • cargo test -p dynamo-mocker --features kvbm-offload speculative_decode_reservation_waits_without_preempting -- --nocapture

  • cargo fmt --all -- --check, commit hooks, and git diff --check

  • ComputeLab SC-01: single H100, Qwen3-1.7B, vLLM TP1, 38,863 runtime GPU KV blocks, four prefix groups at 68.68-74.85% measured prefix-cache token hit rate, three trials each at concurrency 8 and 128, zero request errors or output-length mismatches.

  • At concurrency 128, candidate median ITL was 21.69 ms versus live 22.12 ms; baseline was 8.98 ms. Candidate output-throughput error was -19.6% versus baseline +40.8%.

  • Paired trace at scheduler batch 106/context 4,103 showed candidate active_kv_tokens=434,972 (106.01 logical contexts) versus baseline 143,968 (35.09 contexts), confirming the corrected timing input tracks the scheduled batch under prefix dedup.

  • Lower-level attribution on the exact live stack (H100 80GB, pinned vLLM 0.23.1 development image, Qwen3-1.7B BF16 TP1, FlashAttention 3) reproduced the scheduler shape at batch 106 with 434,976 logical KV tokens. At fixed batch and logical total, the actual ragged request vector was within 0.5% of the homogeneous attention control.

  • The old batch-35 proxy underpriced direct paged FlashAttention by 58.2% and steady-state engine decode by 48.6% versus the actual batch-106 workload. This directly validates removing the dedup-aware scheduler cap.

  • Physical prefix-block aliasing reduced attention time by 35.7% versus an unaliased replay. That is a separate attention-model fidelity opportunity; it does not make deduplicated physical blocks a valid proxy for the scheduled decode batch.

The live image reports vLLM 0.23.1rc1.dev1502; the available AIC interpolation data is for vLLM 0.24.0. Candidate mean and upper-tail simulated ITL remained conservative, so the campaign validates the accounting semantics and center-of-distribution parity rather than exact end-to-end calibration across those versions.


Open in Devin Review

Signed-off-by: PeaBrane <yanrpei@gmail.com>
@PeaBrane
PeaBrane requested review from a team as code owners August 3, 2026 18:49
@github-actions github-actions Bot added the fix label Aug 3, 2026

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

Open in Devin Review

Comment thread lib/mocker/src/scheduler/vllm/core.rs Outdated
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Changes

Decode modeling

Layer / File(s) Summary
Scheduled logical token timing
lib/mocker/src/scheduler/vllm/core.rs, lib/mocker/src/common/perf_model.rs
Regular and speculative decode timing now use scheduled sequence lengths capped by total KV capacity. Documentation defines these values as logical KV token counts.
Reservation API cleanup
lib/mocker/src/kv_manager/g1_manager.rs, lib/mocker/src/kv_manager/vllm_backend.rs
Removed crate-visible len accessors from decode block reservation types.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: using logical KV tokens for Mocker decode timing.
Description check ✅ Passed The description explains the change, affected files, review starting points, related-issue status, and validation results in sufficient detail.

Comment @coderabbitai help to get the list of available commands.

Comment thread lib/mocker/src/scheduler/vllm/core.rs Outdated
@datadog-official

This comment has been minimized.

Signed-off-by: PeaBrane <yanrpei@gmail.com>
…active-kv

Signed-off-by: PeaBrane <yanrpei@gmail.com>
@PeaBrane
PeaBrane enabled auto-merge (squash) August 3, 2026 21:39
@PeaBrane
PeaBrane merged commit 3927251 into main Aug 3, 2026
113 checks passed
@PeaBrane
PeaBrane deleted the rupei/mocker-logical-active-kv branch August 3, 2026 22:29
hhzhang16 added a commit that referenced this pull request Aug 4, 2026
dyn-3691-extract-shared-target-pid-cuda-customstorage-operation-layer

* 'main' of https://github.com/ai-dynamo/dynamo: (50 commits)
  docs(cli): correct removed vLLM prefill-worker flag reference (#12581)
  docs(operator): reserve webhook Ignore for emergencies (#12563)
  ci(docs): make previews and checks match what actually publishes (#12339)
  refactor(vllm): organize custom encoder modules (#12416)
  feat(llm): Select reasoning output field via env var (#11464)
  feat(runtime): add TLS support to TCP request plane (#10921)
  fix: convert conditional disagg sglang warning to httperror 400 (#12578)
  feat(operator): add runtime feature gates (#12421)
  refactor(runtime): extract PushRouter transport seam behind StreamingDispatch trait (#12447)
  feat(replay): add deterministic canonical offline reports (#12363)
  build: bump ModelExpress to 0.5.0(OPS-7978) (#12455)
  fix(mocker): use logical KV tokens for decode timing (#12583)
  fix(examples): update Triton example for CUDA 13 + fix libdcgm copy (DYN-3697) (#12577)
  refactor(operator): implement composition-first DGD reconciliation (#12283)
  feat(frontend): add basetenkenizer backend (#12376)
  fix(profiler): configure rapid mocker without planner (#12573)
  docs(vllm): correct worker-role flags and document --kv-transfer-config (#12568)
  ci: add Kubernetes deploy test to nightly (#12090)
  fix(container): reuse pinned protoc in runtime image (#12535)
  feat(self-host): flip DYN_SELF_HOST_METADATA default to ON (gh-8749) (#11417)
  ...

Signed-off-by: Hannah Zhang <hannahz@nvidia.com>
@PeaBrane PeaBrane changed the title fix(mocker): use logical KV tokens for decode timing fix(mocker): use logical KV tokens for decode timing [DYN-3851] Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants