Add GLM-5.2 native SFT and validation outputs for PaddleFleet alignment - #3
Merged
Merged
Conversation
Resolve swift/megatron/init.py: keep both _patch_mcore_bridge additions. Upstream main added the import-time use_accuracy_compatible TE-off patch; this branch added the norm_accuracy_compatible DSA q/kv layernorm spec patch. They are independent and both are applied, TE-off first.
…ed by this branch
_replace_spec_dsa otherwise still asks TESpecProvider, leaving TELinear on indexer/MLA while Paddle HAVE_TE is False.
Stack-top dump-off YAML uses those keys. Without the dataclass fields parse_args left remaining_argv and failed closed. Alias MTP depth onto mtp_num_layers and apply the Megatron deterministic contract at init.
TE-off local TransformerLayer has a standalone pre_mlp_layernorm, not fused linear_fc1.layer_norm_weight. Weight load asserted None on that fused key. Route the HF post-attention LN onto the local module when the fused parameter is absent.
TP2+SP pads ceil(57/2)*2=58 without the extra *2, while PaddleFleet and the E-811 IEEE 1-100 carrier are 60. Restore the SP interleave factor so get_padding_to is 4 on the frozen profile. Signed-off-by: Zhan Rongrui <me@zrr.dev>
CI flake8/isort/yapf on PFCCLab#3 failed on the new test imports and nearby wrap. Numerics unchanged. Signed-off-by: Zhan Rongrui <me@zrr.dev>
Merge PFCCLab/ms-swift main so lint --all-files includes the new alignment workflow and build.sh. Wrap the two E501 lines in the observability trainer helpers and let isort/yapf/single-quote hooks rewrite only files already on this branch.
CI pre-commit --all-files still ran double-quote-string-fixer on utils.py after the main merge. Local --all-files is now green.
The previous quote-fixer pass rewrote rf'({"|".join(...)})' to
' | ', which would change the regex. Restore the original
alternation and only single-quote the dump/load helper strings
that CI's double-quote-string-fixer still rewrote.
CI lint uses Python 3.10, whose tokenize still sees f"..." as STRING tokens, so double-quote-string-fixer rewrites them. Local 3.12 tokenize splits f-strings and the hook no-ops. Convert the four logger f-strings and one comment on this branch.
Self-hosted unittest died at sudo chown with "no tty present and no askpass". Keep chown when sudo -n works; otherwise skip so checkout can run.
Keep pull_request on the historical CodeSync/develop tarball and develop/latest wheels. workflow_dispatch can opt into fail-closed SHA checkout plus artifact digest checks; pairing remains unproven unless this job built the wheels from the pin. MinimaxV2.5_EP2 and GLM45Air_EP2 are unchanged.
paddle-4 runner 2.337.0 forces Node 24 for actions/checkout@v3; node24 needs GLIBC 2.27/2.28 which this host lacks (job 101275701451). Keep checkout@v3 and opt into ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION.
Match Megatron PFCCLab#4: checkout COMMIT_ID on workflow_dispatch, export source trees from the pin selector, and consume that env in the alignment step so setup_venvs never sees the hardcoded 0.0.0 wheel.
Match Megatron PFCCLab#4: caller mode/pin stay authoritative; unproven develop fallback is refused; verified 0.0.0 names remain legal.
Selector clone failure must fail the docker exec (set -e) instead of continuing wget/build. Receipt checks live in a helper so the single-quoted -c script has no nested quotes. Missing pin.env after an error receipt is selector failure, not env-handoff.
stack-paired checkout_pin used a full default-branch git clone with no retry. Swift 34038640242 failed Get Whl on curl 56 / early EOF before ops, so Fleet 09bb4bd4 was not evaluated. Fetch origin $PIN_SHA at --depth=1 --no-tags, detach-checkout, and keep exact HEAD. Transient RPC/curl-56 retries up to 3 clean dests; HTTP 401/403, missing SHA, and missing repo fail closed on attempt 1 with commit_verified=false.
Signed-off-by: Zhan Rongrui <me@zrr.dev>
This was referenced Sep 9, 2026
Open
Closed
zrr1999
marked this pull request as ready for review
September 11, 2026 02:36
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.
PR type
PR information
接通 GLM-5.2 原生 Megatron SFT:配置 DSA / MLA / MoE / MTP,从官方权重与可追溯输入训练,再由原生回调和保存流程输出原始 loss、来源信息与 checkpoint。底层计算依赖 Megatron-LM #4。
Experiment results
在官方权重抽取的缩层、缩 expert GLM-5.2 配置上,H800 / BF16、TP2 / PP2 / EP1 / ETP1、sequence parallel,双方经原生 CLI 独立训练 100 步。100 个原始 loss、187 个最终参数逐位一致,loss / provenance / checkpoint 三项严格检查通过;两侧结果也分别与改动前的 100 步基线一致。
验证提交:Megatron-LM
76dd11a1、ms-swift76aa97fa、PaddleFleetf85e5d7a;invocation:formal-minimal-companions-20260914-n100-r0。本地其他模型回归:GLM-4.5 与 MiniMax 各运行 10 步,两卡 EP2、BF16、精度兼容模式。每个模型的 40 条原始 loss 哈希与基线完全一致,导出的 checkpoint 文件也完全一致(分别 413 / 407 个 tensor)。MiniMax 使用未修改的上游基线;GLM-4.5 上游无法加载本地 dense MLP,因此基线仅加入与候选相同的 MLP norm 参数名加载修复。GLM-4.5 原始基线和收窄候选各三次运行逐位稳定;恢复上游原有 MoE clone 条件后,候选与基线恢复一致。
Megatron 定向测试 78 项、Swift 定向测试 28 项通过;恢复 MoE 条件后重验受影响的 4 项测试全部通过。关闭精度兼容模式的整图基线在 TE 前向阶段失败,未获得该模式的数值回归结论。上述证据不覆盖完整模型、其他拓扑或所有模型;远端 CI 与审批需分别满足。
本地证据:
experiments/ops/minimal-companion-prs-20260914/terminal.json、regression-comparison-r1-glm45-minimax.json、glm45-determinism.json。Dependencies and integration
建议按 Megatron-LM #4 → 对应 Megatron wheel → ms-swift #3 的顺序接入,再使用匹配的 Torch 参考环境验证 PaddleFleet #1961。本地测试直接使用上述 PR 候选提交,无需先合入。跨仓精度 CI 使用发布的 wheel,源码合入不表示 wheel 已更新。