Repository navigation
[Bugfix] Invalidate KDA merged conv-weight cache on weight reload - #57638
Closed
mustafayildirim wants to merge 8 commits into
Closed
mustafayildirim wants to merge 8 commits into
mustafayildirim wants to merge 8 commits into
Conversation
GLM-5.3 KDA lazily merges q/k/v conv weights into a single cached tensor. Online-RL refits update q_conv1d/k_conv1d/v_conv1d through their weight loaders but never invalidate the cache, so inference keeps serving the pre-refit (e.g. dummy-warmup) merge. Wrap each conv weight's stamped weight_loader so any write clears _merged_conv_weight; it is rebuilt from the new params on the next forward. Covers checkpoint-format refits (weight-loader path, including layerwise reload which re-dispatches through the stamped loader). Fixes vllm-project#55087 Signed-off-by: Mustafa YILDIRIM <mustafa@character.ai>
Contributor
Author
|
Ping for review — fixes the #55087 stale-weights bug for GLM-5.3 KDA in online-RL refit loops. Verified on MI350X against a real @gdhyi @dllehr-amd |
5 of 6 tasks
6 tasks done
Contributor
|
This pull request has merge conflicts that must be resolved before it can be |
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.
Purpose
Fixes #55087. GLM-5.3 KDA merges the q/k/v short-conv weights into one cached tensor (
_merged_conv_weight), built lazily on first forward. Online-RL workflows warm up with dummy weights (cache built), then refitq_conv1d/k_conv1d/v_conv1d— but the cached merge is never invalidated, so inference silently keeps using the pre-refit convolution weights.Approach
Weight loading dispatches on the param's stamped
weight_loader(getattr(param, "weight_loader", default_weight_loader)inAutoWeightsLoader). So the cache can be invalidated at exactly the point the weights change: inGlm5NextLinearAttention.__init__, wrap each conv weight's stamped loader so any write clears_merged_conv_weight. The next forward rebuilds it from the current params. No new hooks, no changes to the reload machinery.Coverage / limitations
reload_weights→model.load_weights→ stamped loaders → cache clearedparam.copy_bypass) writes params without loaders — the cache is NOT invalidated there. That path also skips every other derived-weight rebuild in the tree (same class of limitation); noted for follow-up if it matters in practice.A
_version-based approach was considered and rejected: the default loader writes viaparam.data.copy_, which bumps neitherparam._versionnorparam.data._version(verified on torch 2.10/ROCm), so version tracking cannot see the main refit path.Verification
Ad-hoc functional test on MI350X against a real
Glm5NextLinearAttention(gloo TP1, minimalGlm5NextConfig):q_conv1dthrough its real stamped weight loaderPre-commit: all hooks pass. No GPU-unit test added (KDA layer requires a full
VllmConfig+ mamba cache plumbing; happy to add one if maintainers want it).