Skip to content

feat(config): add BatchGenModelConfig resolver for GLM-5.2 - #309

Merged
Andrewxu313 merged 2 commits into
mainfrom
tairanxu/glm52-core
Aug 12, 2026
Merged

feat(config): add BatchGenModelConfig resolver for GLM-5.2#309
Andrewxu313 merged 2 commits into
mainfrom
tairanxu/glm52-core

Conversation

@Andrewxu313

Copy link
Copy Markdown
Contributor

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 rich BaseModelConfig
subclass via a supported-variant registry plus a per-model from_hf() mapping;
validate() fails loud and unlisted GLM-5.x variants warn loudly. The module
body 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_config path unchanged and migrate one
per change.

Type of Change

  • model
  • kernel
  • core
  • fix
  • infra
  • docs

File changes

File Δ Note
batchgen/config/batchgen_model_config.py add resolver: resolve(model_name, ckpt) -> BaseModelConfig subclass; torch/engine-free
batchgen/config/model_registry.py mod GLM-5.2 name patterns before GLM-5; loud warning for unlisted GLM-5.x variants
batchgen/config/tokenizer_registry.py mod GLM-5.2 tokenizer pattern before GLM-5
batchgen/batchgen_worker.py mod reset GLM5AttnWrapper._dsa_prev_topk_indices once per decode step (both dispatch paths)

Checklist

  • Every changed file traces to this task; the diff is surgical and one concern (§3).
  • Changed files stay within the declared type's allowlist — a model/kernel PR does not touch the scheduling/scaffolding layer (§2.5–§2.6).
  • The File changes table lists every changed file and matches the diff (§2.5).
  • No debug_*/scratch_*/tmp_* scripts, BATCHGEN_* env-guards, stray print(), committed artifacts, or Co-Authored-By (§1/§4). (bench_* benchmarks are fine.)
  • Tests added/updated under tests/; touched modules' MODULE.md updated if the public API changed (§2).
  • Ran bash .github/workflows/scripts/check-pr-hygiene.sh origin/main locally; the CI hygiene check is green.

🤖 Generated with Claude Code

TairanXU 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.
@Andrewxu313
Andrewxu313 merged commit b4cfbff into main Aug 12, 2026
1 check passed
@Andrewxu313
Andrewxu313 deleted the tairanxu/glm52-core branch August 12, 2026 21:25
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