Repository navigation
[Fix] Match GLM53 KDA projection precision to the FP8 checkpoint recipe - #2244
Open
RunningLeon wants to merge 1 commit into
Open
RunningLeon wants to merge 1 commit into
RunningLeon wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
Root Cause
GLM-5.3-Flash uses a mixed-precision FP8 recipe, not FP8 for every linear layer. The official checkpoint configuration explicitly lists the KDA q/k/v/o, beta and forget/output-gate projections in
quantization_config.modules_to_not_convert. LMDeploy correspondingly builds these projections without an FP8 quantization config.XTuner currently forwards the model-wide
Float8ConfigthroughKDAConfig.buildinto all KDA projections. Enabling FP8 training therefore changes the KDA projection precision relative to the official recipe and the rollout model.The existing
gate_projection_block_sizeoption from #2167 only excludes selected sensitive gates when fixed blocking is enabled; it does not implement the full GLM53 KDA exclusion. This is also separate from the FLA state-layout API compatibility in #2197.Fix
KDAConfig.quantize_projections, defaulting toTrueto preserve generic KDA behavior.Float8Configto KDA when disabled; do not forward the config-only flag to the module constructor.from_hf.Only the KDA policy and regression tests are included. No grad-norm compatibility patches, FLA dependency changes, rollout instrumentation, or weight-export changes are included.
Test Plan
Focused regression tests on this PR
tests/model/test_glm53_kda_quantization.pycovers:Results on PR base
214ad3e3plus this patch:pt2121_all_en_sglang: 9 passed, including real local HF-config conversion, with the repository conftest enabled.verl: 8 passed, 1 skipped with--noconftest(the environment lacksexpecttest; its Transformers lacks GLM5Next). No packages were installed into either environment.git diff --checkpass. Focused non-type-check formatting/lint hooks also pass.These are CPU/meta construction tests, not attention-kernel forward/backward tests.
Prior end-to-end evidence for the same policy change
A cropped GLM-5.3-Flash ~25B model was run for five RL steps before and five after the KDA-only policy fix, on 8 H200 GPUs, with FP8 training/rollout, MTP3, routed-expert replay, and FP32 heads. Source snapshots: XTuner
6a5cbe08a5d0f04b38e2bbc7f2e1a61408d0172a, LMDeploy9f2cd03ad1187443ede93c8f75f540c5c643b419. Both arms retained the same separate Torch 2.11 grad-norm compatibility patch; it is not part of this PR. Environment: Torch 2.11.0+cu130, training FLA 0.4.2 / rollout FLA 0.5.2 isolated per process.1.585e-3initially and3.36e-2–3.79e-2after updates.7.23e-4and1.07e-3. Independently recomputed, token-weighted overall sampled KL was8.447e-4, and k3 was8.218e-4over 326,596 valid response tokens.Limitations: naturally generated trajectories differ between arms, so this is not a fixed-trajectory paired KL attribution. Framework metrics use microbatch aggregation; the independent overall result uses token weighting. These are sampled log-probability estimators, not full-vocabulary KL. Rewards/advantages were zero for this cropped-model run; MTP auxiliary loss supplied the gradient signal. The baseline completed training but required cleanup of one lingering worker. Full-size accuracy, throughput, and RL reruns on the newer PR base are not claimed.
Performance / Compatibility
This correctness fix intentionally uses the non-FP8 linear path for GLM53 KDA, matching the checkpoint recipe. It may change KDA projection memory/throughput versus the previous global-FP8 path; no performance improvement is claimed. MoE/MLP and sparse-attention FP8 selection is unchanged. No additional per-token branching or kernel changes are introduced.
ProduceBatchResult impact: not affected.
RoutedExperts ownership/format impact: not affected.