refactor: consolidate model dispatch into a single registry - #256
refactor: consolidate model dispatch into a single registry#256Andrewxu313 wants to merge 1 commit into
Conversation
Replace the duplicated if/elif name-matching in get_initializer.py and get_parallel_strategy_manager.py with one MODEL_REGISTRY + resolve_model() in batchgen/model_dispatch.py. Behavior-preserving: identical substring/exact matching, same order, same classes; per-model imports stay lazy. Adds tests/test_model_dispatch.py (14 cases). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Andrewxu313 <Andrewxu313@users.noreply.github.com>
|
Review finding (import-time regression): Suggested fix: keep the KIMI patterns out of the module-level import path (inline the literal tuple, or make the import lazy inside the matcher), or guarantee |
Description
Collapse the duplicated
if/elifmodel-name dispatch inget_initializer.pyandget_parallel_strategy_manager.pyinto oneMODEL_REGISTRY+resolve_model()inbatchgen/model_dispatch.py. The twoget_*functions become thin delegators. Behavior-preserving: identical substring/exact matching, same order, same classes; per-model imports stay lazy. Addstests/test_model_dispatch.py(14 cases). No behavior change (pure refactor).Motivation
The two
get_*files duplicated the same name→classif/elifchain (incl. a copy-pastedKIMI_K25_BACKEND_NAME_PATTERNS), which is fragile (ordering/collision) and a maintenance hazard. Consolidating into a single registry makes model→implementation dispatch live in exactly one place, so the runtime core never branches on model names. First step of the modularization effort.Type of Change
Checklist