refactor(worker): retire KVCacheManager stats legacy + gate (Phase 5.1c, refs #175) - #196
Open
Andrewxu313 wants to merge 1 commit into
Open
refactor(worker): retire KVCacheManager stats legacy + gate (Phase 5.1c, refs #175)#196Andrewxu313 wants to merge 1 commit into
Andrewxu313 wants to merge 1 commit into
Conversation
…1c, refs #175) Phase 2 / Slice 5 / sub-slice 1c — cleanup step. Removes the dual-path migration scaffolding now that H20 compare-mode proved zero divergence: L2-2048 = 71.09% accuracy (91/128), zero `kv_stats compare mismatch` assertions across both nodes (16 ranks, 2× backend calls per call site during compare-mode). Deletes: - `BATCHGEN_WORKER_KV_STATS_NATIVE` / `..._COMPARE` env reads + comment -8 LOC - 3 `_legacy_get_*_kv_*` methods (original bodies) -85 LOC - Gate branches inside the 3 wrapper methods -21 LOC Each worker helper is now a thin delegation to `KVCacheManager`: - `_get_host_kv_free_pages` → 1-line delegation - `_get_gpu_kv_free_pages` → 1-line delegation - `_get_host_kv_utilization` → 4-line delegation (constructs `KVUtilizationRequest`, calls handler, returns `dataclasses.asdict(HostKVUtilization)` to preserve the legacy dict-return contract for the 3 in-worker call sites) The lazy `_kv_cache_manager` field + `_make_kv_cache_manager` + `_make_kv_utilization_request` helpers stay (still needed to wire the `TorchKVStatsBackend` adapter on first use). Net: -104 LOC on `batchgen/batchgen_worker.py`. Validation: - H20 L2-2048 with NATIVE=1 + COMPARE=1: 71.09% accuracy (91/128), zero assertion failures. Run on commit 7102ab8 (Phase 5.1b merged tip). - Sampling band across post-Phase-0 runs: 70.31–75.00% on identical config — 71.09% sits in the middle. Slice 5.1 (stats tier) complete. Subsequent sub-slices (5.2 page-table capacity, 5.3 token-budget cache, 5.4 allocation/I/O, 5.5 watermark+ planner, 5.6 migration executor) remain on issue #175 as scoped work for future PRs. Refs #175. Part of milestone Worker decouple.
Collaborator
|
Review note (risk classification): the removed gate defaulted to legacy — |
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.
Description
Phase 2 / Slice 5 / sub-slice 1c — cleanup step. Issue #175 stays open (covers full KV decouple; 5.1c closes the stats tier only).
Removes the dual-path migration scaffolding for the 3 read-only KV stat helpers now that H20 compare-mode proved zero divergence.
Diff: −104 LOC
BATCHGEN_WORKER_KV_STATS_NATIVE/..._COMPAREenv reads + comment_legacy_get_*_kv_*methods (original bodies)Each helper collapses to a 1-line (or 4-line for the dict-returning one) delegation:
The lazy
_kv_cache_managerfield +_make_kv_cache_manager+_make_kv_utilization_requesthelpers stay (still needed to wire theTorchKVStatsBackendadapter on first use).Validation (H20 dual-mode L2-2048 on commit
7102ab85)kv_stats compare mismatch/AssertionErrorThe 3-retry run completed normally once external GPU contention from
tairan-batchgen-fp8was cleared.Motivation
Refs #175. Part of milestone Worker decouple. Slice 5 sub-slice 1 complete; issue stays open for sub-slices 5.2–5.6 (page-table capacity, token-budget cache, allocation/I/O, watermark+planner, migration executor).
Type of Change
(Refactor — deletion of validated migration scaffolding.)
Checklist
tests/worker/test_kv_manager.pycontinues to coverKVCacheManagerdirectly.Pre-merge verification
python -m py_compile batchgen/batchgen_worker.pysucceeds.pytest tests/worker/ -x→ 67/67 passing.grep -cE "_kv_stats_native|_kv_stats_compare|_legacy_get_*_kv_*|BATCHGEN_WORKER_KV_STATS"→ 0 (zero residual gate/legacy refs).Slice 5.1 cumulative impact
Slice 5.1 net: −17 LOC on worker + 426 LOC in
batchgen/worker/+ tests.