Preserve AutoEP score correction bias buffers - #8369
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 83a4f6c5f4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if spec.e_score_correction_bias_path is not None: | ||
| source_ecb_owner = (source_module if spec.e_score_correction_bias_path == "" else | ||
| source_module.get_submodule(spec.e_score_correction_bias_path)) | ||
| source_ecb = getattr(source_ecb_owner, "e_score_correction_bias", None) |
There was a problem hiding this comment.
Preserve gate lookup when the parsed path is absent
When a caller constructs MoELayerSpec directly (the new field defaults to None) or attaches e_score_correction_bias between ep_parser() and replace_moe_layer(), this leaves source_ecb unset even if the source gate has a valid bias. The previous implementation discovered the bias from source_gate during replacement, and the pre-change unit test explicitly exercised the post-parser attachment case; the revised test now moves that attachment before parsing. This regression silently drops the correction bias and changes expert selection, so replacement should fall back to inspecting source_gate when no path was recorded.
Useful? React with 👍 / 👎.
Signed-off-by: poorpaper <43514747+poorpaper@users.noreply.github.com>
83a4f6c to
42db829
Compare
Summary
Fix AutoEP replacement silently dropping
e_score_correction_biaswhen Hugging Face models register it as a buffer or place it somewhere other than the router module expected by the preset.The parser now records the bias owner's actual path inside each MoE layer. Replacement then copies the bias while preserving whether it is an
nn.Parameteror registered buffer, including the buffer's persistence setting.The implementation supports locations such as:
gateroutergate.moe_staticsAmbiguous layers containing more than one
e_score_correction_biasare rejected rather than selecting one silently. Unsupported non-parameter/non-buffer values produce a warning.Validation
103 passedDeepseekV3MoE0.0The available validation machine has one GPU, so a multi-GPU collective/ZeRO-3 end-to-end run was not performed.
Fixes #8358