Repository navigation
feat(metrics): export KV held by deferred frees - #3238
Open
MengqingCao wants to merge 1 commit into
Open
MengqingCao wants to merge 1 commit into
MengqingCao wants to merge 1 commit into
Conversation
Contributor
🏷️ CI GuideRuns automatically on every eligible PR before approval:
Heavy model tests:
|
2 tasks done
Contributor
Author
|
@MengqingCao LGTM, reading each table into one mask over the pool is the right call instead of a python set. one thing: did you see it move on a real pd pair, prefill holding source kv until the send completes, or only the cpu tests? hold before pre-checkin and atom test pass. |
2 of 4 tasks
2 of 3 tasks
MengqingCao
force-pushed
the
mengqing/deferred-free-metrics
branch
2 times, most recently
from
November 12, 2026 15:29
2c03991 to
655fcbb
Compare
MengqingCao
force-pushed
the
mengqing/deferred-free-metrics
branch
2 times, most recently
from
November 12, 2026 16:38
16fdeab to
30d4fe6
Compare
Add atom:requests_deferred_free and atom:kv_cache_blocks_deferred_free: finished or aborted requests the scheduler keeps allocated as a whole until every connector releases them, and the physical blocks they hold, shared prefixes counted once. On P/D prefill this is the source KV decode has not pulled yet. Early-release offload leases are not included. Both are computed with the metrics snapshot, from the block tables' buffers rather than a Python set.
MengqingCao
force-pushed
the
mengqing/deferred-free-metrics
branch
from
November 12, 2026 16:44
30d4fe6 to
13a2e8b
Compare
This branch has not been deployed
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.
Summary
Split out of #3173 on review: these are P-side metrics and do not depend on decode admission. The PR sits on top of the stack only for ordering; it touches none of the admission code.
Every scheduler exports two gauges, summed across DP ranks:
atom:requests_deferred_free: finished or aborted requests kept allocated as a whole until every connector releases them.atom:kv_cache_blocks_deferred_free: the physical KV blocks those requests hold, shared prefix blocks counted once.On P/D prefill this is the source KV decode has not pulled yet. An offload save that defers the whole request is counted the same way. Early-release offload leases are not included: those blocks return once every rank has finished reading them, before the store completes.
Both are computed in
EngineUtilityHandler.collect_metricsat snapshot time, not per step.physical_block_countmarks a boolean mask over the pool from each block table's buffer instead of building a Python set of every id.collect_metricsreadsscheduler.deferred_free_blocksdirectly;Scheduler.__init__always sets it, and RapidServe'sPrefillSchedulerhas no block manager, so it never reaches this branch.Both gauges are listed under "Engine aggregate state" in
docs/metrics_guide.md.Test plan
tests/test_pd*.py,tests/test_mooncake*.py,tests/test_kv_connector*.py,tests/test_disagg*.py,tests/test_model_runner*.py,tests/test_scheduler*.py,tests/test_engine_core*.py,tests/entrypoints/test_metrics.py,tests/test_gpu_metrics.py,tests/test_observability_report.py: 1320 passed, 22 skipped. New here:test_deferred_free_counts_shared_blocks_once[list]and[new_block_table], the second over thearray('i')a real block table is.Stack created with GitHub Stacks CLI • Give Feedback 💬