[GLM-5.2] Preserve HF config compatibility for vLLM - #1998
Open
jayhenry wants to merge 3 commits into
Open
Conversation
Keep legacy routing metadata required by vLLM and trim unused RoPE defaults from exported configs.
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.
Summary
topk_method="noaux_tc"so vLLM and SGLang construct the router layout expected by the checkpointhead_dimnormalization unchangedcheck_hf_config_savetesting helper plus acheck-hf-config-saveskill for future model portsfrom_hf -> save_hfcontract testRoot cause
flowchart LR A["Original HF config"] --> B["XTuner from_hf"] B --> C["XTuner internal config"] C --> D["Reconstructed HF config"] D --> E["Inference-engine model construction"] E --> F["Checkpoint weight loading"]The previous reverse mapping from
Glm52MoEConfigtoHFGlmMoeDsaConfigomitted legacy compatibility fields. In particular, the exported checkpoint still contained tensors such as:but its
config.jsonomittedtopk_method.Transformers 5.14.1 no longer exposes
topk_methodas a GLM-5.2 architecture argument. Its GLM implementation constructs and uses the correction bias independently of that legacy field, so adding the field back does not change current Hugging Face model structure or inference semantics.vLLM 0.26.0 still treats the field as a model-construction switch: it registers
gate.e_score_correction_biasonly fortopk_method == "noaux_tc"(exact source). When the field is absent, vLLM builds no matching parameter and fails on the existing checkpoint tensor with:SGLang 0.5.16 has the same value-sensitive correction-bias construction (exact source) and also directly reads
moe_layer_freqwhen selecting sparse layers (exact source).Therefore these configs are equivalent for current Hugging Face inference, but they are not equivalent inputs to the vLLM/SGLang model constructors. Restoring the fields fixes a real engine load-time compatibility failure.
Generic export check
xtuner._testing.check_hf_config_savecompares:config.json;from_hf -> save_hfresult.The direct Transformers round-trip is the serialized reference. This prevents forced changes such as
head_dim,layer_types, andmlp_biasin Transformers 5.14.1 from being misdiagnosed as XTuner bugs. VersionedHFConfigFieldDependencyentries independently protect engine-critical fields that Transformers may not consume.The new
check-hf-config-saveskill standardizes this workflow for future models: resolve exact versions, inspect exact engine tags, add the public-path regression test, and report runtime checks separately from source-only audits.GLM-5.2 result
pt29_glm1Transformerspt29_glm2TransformersTransformers normalization observed by the helper:
bos_token_id,transformers_versionbos_token_id,head_dim,layer_types,mlp_bias,transformers_versionThe old
hf-800/config.jsonis a negative reproduction: the helper rejects it for missingep_size,index_topk_pattern,moe_layer_freq,pretraining_tp,rope_interleave, andtopk_method, and for the unrelated RoPE defaults/nulls. The repaired export passes in both Transformers versions.head_dimremains intentionally unchanged in XTuner code. Transformers 5.14.1 continues to normalize it toqk_rope_head_diminGlmMoeDsaConfig.__post_init__.Additional checks: targeted Ruff checks, Python compile checks, and skill validation all pass.