Add architecture-specific MoE and zero-K3 training support - #23
Add architecture-specific MoE and zero-K3 training support#23kiddyboots216 wants to merge 16 commits into
Conversation
Broly Security ScanNote ✅ Clean scan Note Re-scan this PR anytime with
|
a77f780 to
ea9a1e0
Compare
qywu
left a comment
There was a problem hiding this comment.
Reviewed: description is clear, CI passing, no suspicious file changes. LGTM.
qywu
left a comment
There was a problem hiding this comment.
Deep review summary
Read the full description and the ~7.5k line / 55-file diff (not just the first screen), cross-checked the MoE EP-combine/scatter-gather math, the norm-family dispatch, KV-cache threading, and the security claims against the actual diff.
What checks out
_ep_combine_native/_ep_combine_sim(src/xorl/models/transformers/qwen3_5_moe/modeling_qwen3_5_moe.py) andexchange_and_chain_sum(src/xorl/models/layers/moe/ep_native_combine.py) use a consistent(n-1) -> 0chain-sum order across the simulation path, the native training path, and the docstrings — no order mismatch._AllGatherSumBackward(ep_native_combine.py:617-643): the reduce-scatter-sum backward is correct given that every EP rank's forward consumes the entire gathered token batch (each rank's local shard genuinely receives gradient contributions from every other rank's forward use of it).experts.py'sfilter_expert=Truemasked backward (compacting valid(token, slot)pairs beforeexpert_histogram/moe_index_compute, then scattering grads back withvalid_flat) correctly handles thenumel()==0all-masked case by returning exact zeros, and the L2Norm/RoPE/eager-mask fixes ineager.pyandmulti_head_attention.pyare consistent with the addedpast_key_valuesincremental-decode support.model_runner.py:6530-6504world-size guard ondist.all_reduce(loss_report, ...)matches the described single-GPU NCCL/libnvidia-ml.so.1fix and is scoped correctly.
Non-blocking observations
- Description vs. diff: the "Filesystem fallback for R3 routing side payloads ... versioned JSON manifest ... refuses symlinks, rejects legacy pickle" paragraph describes code that already exists pre-PR (
runner_dispatcher.pymanifest/symlink checks,security.py::resolve_path_within) — none of that logic appears in this diff. It's disclosed as "inherited," but the wording ("now uses...") reads like new work in this PR; worth tightening so reviewers don't credit this PR for hardening it didn't add. qwen3_moe/modeling_qwen3_moe.pyadds a large amount of env-var-gated diagnostic scaffolding (XORL_QWEN3_MOE_DELAYED_RESIDUAL_PAIR*,..._O_PROJ_PARTIAL_RESIDUAL*,..._CAPTURE_O_PROJ_PARTIAL_RESIDUAL_CANDIDATES*) with several near-duplicate boolean-env-parsing helper functions. It is off by default and does have dedicated tests, but it's a lot of surface area/branching to carry for a "complete MoE support" PR — consider consolidating the repeated{"1","true","yes","on"}parsing helpers and confirming these diagnostic-only paths are pruned once bring-up is done.
No logic bugs, race conditions, or trust-boundary issues were found in the reviewed diff that would justify blocking. Filing as comment-only given the above are non-blocking clarity/complexity notes rather than defects.
ea9a1e0 to
99e7793
Compare
65e666e to
dbbd527
Compare
dbbd527 to
edf2765
Compare
edf2765 to
818b68b
Compare
818b68b to
5aed1b1
Compare
Include the production Qwen3.5/Qwen3.6 LoRA composition: fused GDN adapter geometry, strict target manifests, canonical merged-forward synchronization, variable-row native EP combine, and LoRA-aware expert execution.
5aed1b1 to
8bb4f15
Compare
7b97713 to
1029c51
Compare
c79f1d2 to
55b0de7
Compare
ca9a78c to
f9811ef
Compare
Add architecture-scoped exact numerical programs for GLM-5.2, Qwen3.5-0.8B, and Qwen3.6-35B-A3B server training. Match serving kernels and reduction order, retain native FP8 and canonical MoE support, and reject unqualified model geometries, topologies, or numerical overrides.
f9811ef to
6e1d598
Compare
Summary
Complete the MoE, GDN, and Qwen3.5 trainer surface needed for the validated zero-K3 path.
This adds serving-layout fused experts, deterministic routing and scatter, batch-invariant router behavior, native ordered EP combine, Qwen3.5 MoE and dense GDN wiring, FlashQLA packaging, decode and prefill kernels, residual normalization, and token diagnostics. It also performs the final shared-file reconciliation across model, loss, runner, trainer, and weight-synchronization paths.
The final reconciliation corrects Qwen3.5 MRoPE feature rotation at the dense and MoE attention call sites and restores the temperature-aware fused-head forward/backward contract required by policy losses.
The filesystem fallback for R3 routing side payloads now uses a versioned JSON manifest and fixed-dtype raw tensor files. The reader validates paths, shapes, dtypes, byte counts, and file sizes, refuses symlinks, and rejects legacy pickle references before opening payload data.
This head inherits the Foundation trust-boundary hardening and is explicitly reconciled with the repaired Numerical base. Its MoE-specific runner deltas retain Foundation's R3 slicing, diagnostics, rank-local row batching, and ZORL dispatch while adding cross-rank top-token diagnostics.
Raw experiment outputs, launch manifests, shared-environment operations, and machine-specific dependency mutations are excluded. This PR supersedes #16 and #20.
Validation
git diff --checkpassed.git diff --checkpassed.0.0, ratio mean1.0, policy KL0.0, and both clip fractions0.0.Class-B RoPE closure
The apparent Class-B residual was an FSDP transport defect, not a remaining trainer/sampler arithmetic mismatch. Decoder FSDP2 units recursively downcast the model-root FP32 cos/sin tuple to BF16 before the Class-B apply function. The engagement tally covered the apply route but not table precision.
This rebased head inherits the generic fail-closed transport repair from PR #22 and retains Qwen3.5's shared Class-B dispatch.
The corrected one-GPU dense Qwen3.5 replay passed on 128 completion tokens with behavior K3
0.0, ratio mean1.0, negative log-ratio mean0.0, Class-B-only engagement, and a healthy backward/optimizer step. Focused Qwen3.5 and generic contract tests passed (9 tests). This certifies only the measured one-GPU dense lane.Remaining gates
The exact paired result certifies the one-GPU dense Qwen3.5 lane. At-scale expert equality, routing vitality and replay, native EP8 forward/backward/combine order, and paired replay/update for additional production topologies remain required. A world-size-4 native-EP mechanics run is partial evidence, not EP8 certification.
Stack
This PR targets the Numerical-contract PR.