Fix checkpointed prefix-cache result reconstruction - #39
Draft
lmcafee-nvidia wants to merge 4 commits into
Draft
Conversation
Signed-off-by: Lawrence McAfee <lmcafee@nvidia.com>
Signed-off-by: Lawrence McAfee <lmcafee@nvidia.com>
Signed-off-by: Lawrence McAfee <lmcafee@nvidia.com>
Signed-off-by: Lawrence McAfee <lmcafee@nvidia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR correctly reconstructs the final result for a request split across multiple checkpoint records. The old optional-list merge decided the entire result from the first record, so an initial
Nonediscarded values produced by later records. Routing reconstruction was also limited to requests with exactly one record. The fix merges every non-Nonesegment in order, returnsNoneonly when every segment is absent, and reconstructs per-block routing regardless of checkpoint count.Example failure scenario(s)
How was this bug discovered?
A focused prefix-cache scenario paused and resumed a request before its first checkpoint contained scores, then inspected the joined result at completion. Scores produced after the resume were missing, and the recorded MoE expert choices were omitted; the expected result was the ordered union of all available score segments plus routing for every completed block. The detection oracle was exact final-result reconstruction: score presence and order, token alignment, and per-block routing indices.
Dependency and scope
This draft is based on
prefix-cache-core-stress(NVIDIA #6418). Relative to that base, it changes only:megatron/core/inference/engines/dynamic_engine.pymegatron/core/inference/inference_request.pytests/unit_tests/inference/contexts/test_dynamic_prefix_caching.py(+78/-2)It adds no functional tests, recipes, or unrelated production changes.
Validation
Exact signed tip:
0c05dba3fb0595a548d65cde896462b5a290522d15520293: passed