Skip to content

refactor(#422): remove duplicate BatchedEngine (-341 lines) - #428

Merged
dahai80 merged 1 commit into
mainfrom
fix/dedup-batched-engine-422
Aug 8, 2026
Merged

refactor(#422): remove duplicate BatchedEngine (-341 lines)#428
dahai80 merged 1 commit into
mainfrom
fix/dedup-batched-engine-422

Conversation

@dahai80

@dahai80 dahai80 commented Aug 8, 2026

Copy link
Copy Markdown
Owner

What

Closes #422. Removes the duplicate BatchedEngine class from engine/batched/__init__.py, keeping only the live _mtp_dispatch shim.

Background

The issue reported two BatchedEngine implementations. Investigation corrected one premise and confirmed the rest:

  • engine/batched/__init__.py::BatchedEngine (357 lines) — zero production importers. server.py, engine_pool.py, engines/__init__.py all import engines.batched.BatchedEngine (the production impl, 1157 lines), never this one. The 18 test files importing the duplicate class are all in collect_ignore (debt quarantine — never collected).
  • engine/batched/_mtp_dispatch.pyNOT dead: imported by the production engine (engines/batched.py:362) and by the active test_mtp_cli_wiring.py (58 tests) via re-exports. The package cannot be deleted wholesale.

Change

  • Remove the dead BatchedEngine class (−341 lines).
  • Keep _mtp_dispatch + its re-exports so from fusion_mlx.engine.batched import _DISPATCH_ATTACHED / _apply_mtp_dispatch / _decide_mtp_dispatch_action etc. continue to work. The package becomes a thin shim.

Verification

  • test_mtp_cli_wiring.py57 passed, 1 skipped
  • test_vlm_dflash_wiring + test_vlm_ngram_spec_wiring13 passed
  • Full collection → 8849 tests, no import errors (quarantined tests still ignored via collect_ignore)
  • Production imports (engines.batched.BatchedEngine, engines/__init__.py) unaffected
  • ruff + black clean

🤖 Generated with Claude Code

The standalone `BatchedEngine` class in `engine/batched/__init__.py`
(357 lines) was a duplicate of the production implementation in
`engines/batched.py` (1157 lines). Investigation confirmed the class
had ZERO production importers — server.py, engine_pool.py, and
engines/__init__.py all import `engines.batched.BatchedEngine`, never
`engine.batched.BatchedEngine`. The 18 test files that imported the
duplicate class are all in collect_ignore (debt quarantine, never
collected).

What was NOT dead: the `_mtp_dispatch` submodule, imported by the
production engine (`engines/batched.py:362: from
..engine.batched._mtp_dispatch import _apply_mtp_dispatch`) and by the
active `test_mtp_cli_wiring.py` suite (58 tests) via the re-exports in
`__init__.py`. So the package cannot be deleted wholesale.

This removes only the dead class (-341 lines) and keeps `_mtp_dispatch`
+ its re-exports so `from fusion_mlx.engine.batched import
_DISPATCH_ATTACHED` / `_apply_mtp_dispatch` etc. continue to work. The
package is now a thin shim.

Verified:
- test_mtp_cli_wiring.py: 57 passed, 1 skipped
- test_vlm_dflash_wiring + test_vlm_ngram_spec_wiring: 13 passed
- full collection: 8849 tests, no import errors (quarantined tests
  still ignored)
- production imports (`engines.batched.BatchedEngine`,
  `engines/__init__.py`) unaffected

Closes #422.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@dahai80
dahai80 merged commit 8320d84 into main Aug 8, 2026
5 checks passed
@dahai80
dahai80 deleted the fix/dedup-batched-engine-422 branch August 8, 2026 04:08
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.

tech-debt: 重复的 BatchedEngine 实现 (engine/batched/ vs engines/batched.py) 需合并

1 participant