feat(config): add BatchGenModelConfig resolver for GLM-5.2 - #309
Merged
Conversation
added 2 commits
August 13, 2026 00:41
Introduce a decoupled, pure-Python config-resolution module as the single producer of the engine's model config, replacing hand-hardcoded values in the GLM-5 initializer that silently drifted from the checkpoint. Enables GLM-5.2 config resolution (its own config identity, shared model graph). - batchgen/config/batchgen_model_config.py (new): resolve(model_name, ckpt) returns a rich BaseModelConfig subclass via a supported-variant registry plus per-model from_hf() mapping; validate() fails loud; unlisted variants warn loudly. Module body is torch/engine-free and imports model configs lazily. - batchgen/config/model_registry.py: add GLM-5.2 patterns before GLM-5 and a loud warning for unlisted GLM-5.x variants. - batchgen/config/tokenizer_registry.py: add the GLM-5.2 tokenizer pattern before GLM-5. GLM-only in this change; other model families keep the existing load_config path unchanged and will be migrated one per change.
Clear GLM5AttnWrapper._dsa_prev_topk_indices once per decode step (before layer 0) in both decode dispatch paths, so GLM-5.2 shared DSA layers never reuse a stale top-k carried over from the previous step. GLM-5 never publishes a carry, so this is a no-op for it.
12 tasks
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
Add a decoupled, pure-Python config-resolution module (
BatchGenModelConfig)as the single producer of the engine's model config, replacing hand-hardcoded
values in the GLM-5 initializer that silently drifted from the checkpoint.
resolve(model_name, checkpoint_path)returns a richBaseModelConfigsubclass via a supported-variant registry plus a per-model
from_hf()mapping;validate()fails loud and unlisted GLM-5.x variants warn loudly. The modulebody is torch/engine-free and imports model configs lazily. This also adds the
GLM-5.2 name/tokenizer patterns (more-specific before GLM-5) and resets the
GLM-5.2 DSA indexer top-k carry once per decode step so shared layers never
reuse a stale value.
Why
GLM-5.2 shares the GLM-5 model graph but needs its own config identity and a
checkpoint-backed source of truth for the engine's model config. This is the
core seam the GLM-5.2 model work stacks on. GLM-only in this change; other
model families keep the existing
load_configpath unchanged and migrate oneper change.
Type of Change
modelkernelcorefixinfradocsFile changes
batchgen/config/batchgen_model_config.pyresolve(model_name, ckpt)->BaseModelConfigsubclass; torch/engine-freebatchgen/config/model_registry.pybatchgen/config/tokenizer_registry.pybatchgen/batchgen_worker.pyGLM5AttnWrapper._dsa_prev_topk_indicesonce per decode step (both dispatch paths)Checklist
model/kernelPR does not touch the scheduling/scaffolding layer (§2.5–§2.6).debug_*/scratch_*/tmp_*scripts,BATCHGEN_*env-guards, strayprint(), committed artifacts, orCo-Authored-By(§1/§4). (bench_*benchmarks are fine.)tests/; touched modules'MODULE.mdupdated if the public API changed (§2).bash .github/workflows/scripts/check-pr-hygiene.sh origin/mainlocally; the CI hygiene check is green.🤖 Generated with Claude Code