refactor(#422): remove duplicate BatchedEngine (-341 lines) - #428
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes #422. Removes the duplicate
BatchedEngineclass fromengine/batched/__init__.py, keeping only the live_mtp_dispatchshim.Background
The issue reported two
BatchedEngineimplementations. 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__.pyall importengines.batched.BatchedEngine(the production impl, 1157 lines), never this one. The 18 test files importing the duplicate class are all incollect_ignore(debt quarantine — never collected).engine/batched/_mtp_dispatch.py— NOT dead: imported by the production engine (engines/batched.py:362) and by the activetest_mtp_cli_wiring.py(58 tests) via re-exports. The package cannot be deleted wholesale.Change
BatchedEngineclass (−341 lines)._mtp_dispatch+ its re-exports sofrom fusion_mlx.engine.batched import _DISPATCH_ATTACHED/_apply_mtp_dispatch/_decide_mtp_dispatch_actionetc. continue to work. The package becomes a thin shim.Verification
test_mtp_cli_wiring.py→ 57 passed, 1 skippedtest_vlm_dflash_wiring+test_vlm_ngram_spec_wiring→ 13 passedcollect_ignore)engines.batched.BatchedEngine,engines/__init__.py) unaffectedruff+blackclean🤖 Generated with Claude Code