Phase 2 of the worker decouple initiative.
Scope
Extract host-KV migration + eviction (~900 LOC scattered through KV section) into batchgen/worker/host_rebalancer.py.
Design
Handler consumes HostKvBackend + GpuKvBackend (Protocols already introduced by Slice 5 KVCacheManager). Returns RebalancePlan (which uuids to migrate, which pages to free).
3-PR plan
- PR-7.1 Port.
- PR-7.2 Dual-path gate + compare-mode + multi-node L2-2048 + L2-4096 back-to-back.
- PR-7.3 Cleanup.
Pre-merge checklist (from scheduler-split Step 10 fix-up commits — known bug class)
This slice has the densest known bug surface from prior attempts. Compare-mode parity gate must be on for the entire migration.
Design source reference
origin/tairan/scheduler-split:batchgen/worker/host_rebalancer.py (1091 LOC) — biggest single file on that branch; read carefully but reimplement to frozen-snapshot pattern.
Design: /Users/andrew/.claude/plans/the-task-for-this-declarative-melody.md (POIS-local). Builds on the Phase A/B/C cuda-graph contract pattern (PR #162/#163/#164, merged 2026-05-27).
Phase 2 of the worker decouple initiative.
Scope
Extract host-KV migration + eviction (~900 LOC scattered through KV section) into
batchgen/worker/host_rebalancer.py.Design
Handler consumes
HostKvBackend+GpuKvBackend(Protocols already introduced by Slice 5 KVCacheManager). ReturnsRebalancePlan(which uuids to migrate, which pages to free).3-PR plan
Pre-merge checklist (from
scheduler-splitStep 10 fix-up commits — known bug class)self.devicereference — usereq.torch_devicefrom snapshot.self.host_paged_kv_worker_viewreference — pass via backend.self.model_config— pass via snapshot.host_kv_eviction_watermarkmatches actual config (thewas 70 vs actual 10bug).effective_chunk_sizereturn value preserved (the "stray remaining_uuids block" bug).put_on_holdfiltered to IN_DECODE state.pin_memory=Falseon migration destination buffer.This slice has the densest known bug surface from prior attempts. Compare-mode parity gate must be on for the entire migration.
Design source reference
origin/tairan/scheduler-split:batchgen/worker/host_rebalancer.py(1091 LOC) — biggest single file on that branch; read carefully but reimplement to frozen-snapshot pattern.Design:
/Users/andrew/.claude/plans/the-task-for-this-declarative-melody.md(POIS-local). Builds on the Phase A/B/C cuda-graph contract pattern (PR #162/#163/#164, merged 2026-05-27).