Skip to content

refactor(worker): remove dead methods, shims, and legacy decode modes - #899

Merged
Andrewxu313 merged 3 commits into
mainfrom
tairan/worker-slim-a1
Dec 4, 2026
Merged

Andrewxu313 merged 3 commits into
mainfrom
tairan/worker-slim-a1

Conversation

@Andrewxu313

@Andrewxu313 Andrewxu313 commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

Remove dead helper methods, zero-production-caller forwarding shims, and retired legacy decode mode 0/1/2 code paths from batchgen/batchgen_worker.py and batchgen/worker/decode_engine.py.

Key changes:

  • Delete dead/unreferenced methods and zero-production-caller forwarding shims from BatchGenWorker and drop the 9 worker imports that became unused.
  • Retire legacy non-DECOUPLED_GPU decode strategy methods (LegacyDecodeBoundaryOutcome, run_legacy_decode_page_boundary, run_legacy_cpu_attn_decode_step, run_legacy_microbatch_gpu_decode_step) from batchgen/worker/decode_engine.py, fail fast with NotImplementedError in decoding_continuous if an unsupported decode strategy is requested, and remove their 3 stale MODULE_CONTRACT entries and 2 unused imports.
  • Update tests/worker_method_source.py (context_function_as_worker_method) to synthesize a (self, ...) signature directly from the extracted engine function without requiring a dead same-name delegator stub on BatchGenWorker.
  • Remove 3 legacy-only unit test files and update existing unit/worker tests to bind directly to the owning engine methods.

Motivation

After completing the worker module decomposition, BatchGenWorker still retained dead legacy decode branches (modes 0/1/2) and forwarding shims kept alive solely by test-helper signature copying. Deleting them eliminates dead code paths, keeps MODULE_CONTRACT accurate, and prevents stale shims from masking the real engine boundaries.

Type of Change

  • model — add/extend model support (models/** + registration seam + model kernels only)
  • kernel — add/optimize a compute kernel (batchgen_kernels/** + in-tree kernel dirs)
  • core — change scheduling/serving/runtime scaffolding (the only type that may)
  • fix — narrow bug fix (+ a regression test)
  • infra — build / CI / packaging / scripts / Docker
  • docs — documentation only

File changes

File Δ Note
batchgen/batchgen_worker.py mod Delete dead methods, zero-caller shims, retired legacy decode mode paths, and 9 newly unused imports
batchgen/worker/decode_engine.py mod Delete retired legacy decode helpers, stale MODULE_CONTRACT entries, and 2 newly unused imports
tests/test_worker_weight_passes.py mod Update weight-pass test bindings after dead shim removal
tests/unit/test_legacy_decode_step_bound.py del Delete test covering removed legacy decode mode
tests/unit/test_legacy_kv_accounting.py del Delete test covering removed legacy decode accounting
tests/unit/test_prefill_admission_reclaim.py mod Bind helper assertions directly to owning engine methods
tests/unit/test_prefix_drain_metric.py mod Update metric test binding after shim removal
tests/unit/test_trajectory_book_migration_reservations.py mod Drop removed _get_node_for_rank delegator from WORKER_METHODS
tests/worker/test_decode_legacy_helpers_direct_params.py del Delete test covering removed legacy decode helpers
tests/worker/test_decode_strategy.py mod Verify retired decode strategies fail fast with NotImplementedError
tests/worker/test_kv_capacity_context.py mod Bind assertions directly to KVCapacityEngine methods
tests/worker/test_sequence_table.py mod Update sequence table test binding after shim removal
tests/worker/test_worker_lifecycle_engine.py mod Update lifecycle engine test binding after shim removal
tests/worker_method_source.py mod Synthesize (self, ...) directly in context_function_as_worker_method without requiring dead worker delegators

Checklist

  • I have read the CONTRIBUTING guide and the PR Merge Policy Contract.
  • I have updated the tests (if applicable).
  • I have updated the documentation (if applicable).
  • If README.md changed, I ran python3 scripts/check_readme_update.py --base-ref origin/main and preserved all News history.

Remove 36 dead methods, zero-prod-caller forwarding shims, and retired
non-executable legacy decode mode 0/1/2 paths from batchgen_worker.py
(-502 LOC) and batchgen/worker/decode_engine.py (-230 LOC). Update
decoding_continuous to fail fast with NotImplementedError for retired
modes and allow worker_method_source.py to synthesize signatures without
requiring dead same-name delegators on BatchGenWorker.
Drop the 9 worker imports and 2 decode_engine imports that became unused when dead methods, zero-caller shims, and legacy decode paths were deleted.
test_trajectory_book_migration_reservations.py listed the removed _get_node_for_rank delegator in WORKER_METHODS even though migration helpers call node_of_rank directly.
@Andrewxu313
Andrewxu313 merged commit 0e77e20 into main Dec 4, 2026
1 check passed
@Andrewxu313
Andrewxu313 deleted the tairan/worker-slim-a1 branch December 4, 2026 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant