Skip to content

Add GLM-5.2 native SFT and validation outputs for PaddleFleet alignment - #3

Merged
zrr1999 merged 35 commits into
PFCCLab:mainfrom
zrr1999:glm52-bit-exact-alignment
Sep 14, 2026
Merged

zrr1999 merged 35 commits into
PFCCLab:mainfrom
zrr1999:glm52-bit-exact-alignment

Conversation

@zrr1999

@zrr1999 zrr1999 commented Jul 27, 2026

Copy link
Copy Markdown

PR type

  • Bug Fix
  • New Feature
  • Document Updates
  • More Models or Datasets Support

PR information

接通 GLM-5.2 原生 Megatron SFT:配置 DSA / MLA / MoE / MTP,从官方权重与可追溯输入训练,再由原生回调和保存流程输出原始 loss、来源信息与 checkpoint。底层计算依赖 Megatron-LM #4

  • 将新增 DSA / TP1 bridge 行为限定在显式配置的模型实例内;dense MLP 加载只修正本地 norm 参数名,复用现有 bridge 的其余逻辑。
  • 为独立 tokenizer、预分词输入和空 assistant 过滤提供显式选项;空回复过滤、确定性模式与非融合 AdamW 默认关闭。
  • 保留上游 clipping、loss 默认行为,移除通用参数清单与 forward dump hooks;保留验收需要的原始 loss、输入来源和 checkpoint 输出。
  • 未修改构建脚本、CI workflow、依赖安装流程或其他模型用例。

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-swift 76aa97fa、PaddleFleet f85e5d7a;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.jsonregression-comparison-r1-glm45-minimax.jsonglm45-determinism.json

Dependencies and integration

建议按 Megatron-LM #4 → 对应 Megatron wheel → ms-swift #3 的顺序接入,再使用匹配的 Torch 参考环境验证 PaddleFleet #1961。本地测试直接使用上述 PR 候选提交,无需先合入。跨仓精度 CI 使用发布的 wheel,源码合入不表示 wheel 已更新。

zrr1999 added 26 commits July 22, 2026 22:18
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.
_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.
@zrr1999 zrr1999 changed the title Preserve GLM-5.2 Megatron accuracy-compatible specs Preserve GLM-5.2 accuracy-compatible specs and native outputs Sep 8, 2026
@zrr1999
zrr1999 marked this pull request as ready for review September 11, 2026 02:36
@zrr1999 zrr1999 changed the title Preserve GLM-5.2 accuracy-compatible specs and native outputs Add GLM-5.2 native SFT and validation outputs for PaddleFleet alignment Sep 14, 2026
@zrr1999
zrr1999 merged commit 6eea315 into PFCCLab:main Sep 14, 2026
0 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant