Skip to content

Worker decouple — Phase 2 / Slice 7: HostKVRebalancer #177

Description

@Andrewxu313

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)

  • No self.device reference — use req.torch_device from snapshot.
  • No self.host_paged_kv_worker_view reference — pass via backend.
  • No self.model_config — pass via snapshot.
  • host_kv_eviction_watermark matches actual config (the was 70 vs actual 10 bug).
  • effective_chunk_size return value preserved (the "stray remaining_uuids block" bug).
  • put_on_hold filtered to IN_DECODE state.
  • pin_memory=False on 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).

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestworker-decoupleWorker monolith decouple initiative (May 2026)

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions