Skip to content

Worker decouple — Phase 2 / Slice 6: PrefillScheduler #176

Description

@Andrewxu313

Phase 2 of the worker decouple initiative.

Scope

Extract prefill batch selection + execution (worker:7132–7575 + parts of Phase Configuration, ~600 LOC) into batchgen/worker/prefill.py.

Design

class ModelExecutorBackend(Protocol):
    def forward_prefill(self, batch) -> PrefillOutputs: ...

@dataclass(frozen=True)
class PrefillSchedulingRequest:
    pending_uuids: tuple[str, ...]
    available_gpu_kv_pages: int
    max_input_length: int

class PrefillScheduler:
    def __init__(self, *, executor: ModelExecutorBackend): ...
    def plan(self, req: PrefillSchedulingRequest) -> PrefillPlan: ...
    def execute(self, plan: PrefillPlan) -> PrefillResult: ...

3-PR plan

  • PR-6.1 Port.
  • PR-6.2 Dual-path gate + compare-mode.
  • PR-6.3 Cleanup.

Pre-merge checklist (from scheduler-split Step 7 fix-up commits)

  • self.model_config synced to snapshot before each call.
  • state.model cleared at deep_free_model_memory boundary (Phase C release_context pattern).

Design source reference

origin/tairan/scheduler-split:batchgen/worker/prefill.py (689 LOC).

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