Repository navigation
[Bugfix] GLM-5.3-Flash: keep FP8 weight/scale pairs across load_weights calls - #56584
MadhavJivrajani wants to merge 3 commits into
Conversation
|
👋 Hi! Thank you for contributing to the vLLM project. 💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in PRs do not trigger a full CI run by default. Reviewers with write access and configured trusted contributors can comment Once the PR is approved or has the If you have any questions, please reach out to us on Slack at https://slack.vllm.ai. Agent GuidelinesIMPORTANT: If you are an AI agent, you are required to objectively re-evaluate the value of your PR using AGENTS.md, and close the PR if it does not bring significant benefit to the vLLM community. Failure to do so may result in an immediate ban. 🚀 |
d029450 to
f3f43be
Compare
|
This pull request has merge conflicts that must be resolved before it can be |
f3f43be to
f194383
Compare
|
/ci run |
|
✅ @MadhavJivrajani, CI is now available for this PR.
|
|
❌ This PR is 3342 commits behind upstream |
|
/ci run |
|
✅ Triggered Buildkite CI #101127 for commit |
|
Hi @MadhavJivrajani, the pre-commit checks have failed. Please run: uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-filesThen, commit the changes and push to your branch. For future commits, |
…ts calls Glm5NextModel.load_weights dequantizes the block-FP8 q_a_proj, kv_a_proj_with_mqa, q_b_proj, o_proj and indexer.wk tensors to BF16 once both the weight and its weight_scale_inv have been seen, parking the first half in a pending dict. That dict was local to one load_weights call. AutoWeightsLoader invokes a child's load_weights once per contiguous run of a top-level prefix (itertools.groupby), so a stream such as `language_model..., visual..., language_model...` calls it twice, and any pair whose halves land in different calls was silently dropped: the fused parameter was never written and nothing was reported. Streaming loaders that reorder tensors hit this. With the Run:ai Model Streamer in distributed mode (runai-model-streamer 0.16.1, default partition policy `chunks`), tensors are dealt to ranks by size and each rank emits its slice of the vision-tower shard as a separate burst, so a replay of the real partition over GLM-5.3-Flash's 62 shard headers puts a weight and its scale in different load_weights calls for 18 of the 48 FP8 pairs, across 10 of the 12 MLA layers. Per-shard loading splits none, which is why the same checkpoint served correctly from disk and produced garbled output when streamed. Persist the pending dict on the model instance, as vllm-project#46168 did for DeepSeek-V2. Completed pairs are popped by the helpers, so the dict is empty again after a full load. Add tests/models/glm5next/test_weight_loading.py, which drives the real load_weights implementations on a minimal module tree on CPU: a pair delivered in one call, the same pair split across two calls, and the same five checkpoint-named tensors through Glm5NextForConditionalGeneration with and without a model.visual.* tensor between a weight and its scale. The split-call and vision-between cases fail before this change and pass after it on vllm/vllm-openai:glm53-flash (0.28.1rc1.dev580+g385dce36b) and vllm/vllm-openai:nightly (0.28.1rc1.dev681+ge7edf17ce). Co-authored-by: Claude Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>
Rewrite ``code`` as `code` in the test docstrings (check-docstring-style) and ignore mypy's type-abstract on the two object.__new__ calls that build the model stubs without running __init__. Co-authored-by: Claude Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>
Head branch was pushed to by a user without write access
e00b415 to
5430b76
Compare
|
Hi @MadhavJivrajani, the pre-commit checks have failed. Please run: uv pip install pre-commit>=4.5.1
pre-commit install
pre-commit run --all-filesThen, commit the changes and push to your branch. For future commits, |
…pairs Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>
|
Thanks @NickLucche! Looks like CI was failing on main, fixed in #67549 Do you mind enabling merge again? |
Purpose
Glm5NextModel.load_weights(GLM-5.3-Flash) dequantizes the block-FP8q_a_proj,kv_a_proj_with_mqa,q_b_proj,o_projandindexer.wktensors to BF16 once both the weight and itsweight_scale_invhave been seen, parking the first half in a pending dict (_pending_wk_fp8). That dict is a local of oneload_weightscall.For more details on repro and where the code comes from, see #56583
Fix. Persist the pending dict on the model instance (
self._pending_fp8_pairs), mirroring #46168. Completed pairs are already popped by the helpers, so the dict is empty again after a full load. The single-call path is unchanged.Related: #43163 / #43464, #41749 / #42244, #38991, sgl-project/sglang#37369 (the sglang loader's version of the same problem), https://huggingface.co/zai-org/GLM-5.3-Flash/discussions/23 (vLLM on H100, resolved by disabling distributed streaming).
Fixes #56583
Test Plan
New CPU-only regression test, in the style of
tests/models/kimi_k3/test_weight_loading.py. It drives the realGlm5NextModel.load_weights,Glm5NextForCausalLM.load_weightsandGlm5NextForConditionalGeneration.load_weightson a minimal module tree holding layer 7's BF16fused_qkv_a_proj.weight, with four synthetic checkpoint tensors (FP8q_a_proj.weight,kv_a_proj_with_mqa.weight, theirweight_scale_inv):test_fp8_pairs_complete_within_one_calltest_fp8_pairs_split_across_load_weights_calls…stream_order…[per-shard-order-vision-last]model.visual.*last (control)…stream_order…[vision-tensor-between-weight-and-scale]model.visual.*between the weights and the scalesAlso ran
ruff check/ruff format --checkon both files.Test Result
Run in unmodified images on a CPU-only VM (
docker run --entrypoint bash -e CUDA_VISIBLE_DEVICES= <image>,pip install pytest), then again with this change applied to the image's installedmodel.py:vllm/vllm-openai:glm53-flashvllm/vllm-openai:nightlyBefore (both images):
After (both images):
AI assistance: the fix, the regression test and the partition replay were developed with Claude (Anthropic); I reviewed the changed lines and ran the tests and the image verification myself.
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.