feat: harden Qwen 3.5/3.6 LoRA distributed training#4
Conversation
|
Follow-up validation (commit ae75152): native ABI bumped to 7 with |
|
Additional H20 validation after f65af15: rebuilt the native library with CUDA 13 headers plus fused CUDA objects and ran |
|
最新增量:
|
|
ABI10 TP-only verification on H20 (123.57.26.97:28004): rebuilt C++/CUDA against PyTorch 2.5.1 ABI0, ran both RANK=0/1 with WORLD_SIZE=TP_SIZE=2, and both exited 0. Smoke covered MoE grouped/fallback, dense MLP, GDN/linear attention, dynamic multi-LoRA, selected-tenant isolation, and context reuse. Global LoRA rank 8 used distinct rank-4 slices; losses matched and each shard updated. This validates LoRA latent-rank TP only; frozen base weights remain replicated. |
|
ABI11 evidence update (H20
The branch still explicitly does not claim full Megatron parity: base weights are replicated, PP/CP/multi-axis groups and variable-split EP token A2A are absent, prebuilt TE/DeepEP/flash-attn were unavailable on the target runtime, and no matched throughput benchmark has been run. |
ABI11 DP/EP and optimizer verification updatePushed
The PR still intentionally does not claim Megatron parity: frozen base weights are replicated; PP/CP, multi-axis TP+DP/EP, variable-split token A2A, DeepEP/TE integration, cross-topology resharding, and matched throughput benchmarks remain open. |
ABI11 DP/EP and optimizer verification updatePushed
The PR still intentionally does not claim Megatron parity: frozen base weights are replicated; PP/CP, multi-axis TP+DP/EP, dynamic-tenant A2A metadata, DeepEP/TE integration, cross-topology resharding, and matched throughput benchmarks remain open. The target host has no importable Megatron/Transformer Engine/DeepEP/flash-attn prebuilt packages, so no dependency installation or JIT workaround was used. |
Native EP benchmark updateFresh H20 ABI0 two-rank run of
This is a synthetic native baseline, not a matched Megatron-LM/DeepEP/Transformer Engine benchmark. The result does not show an end-to-end A2A step-time win on this small workload; the main remaining gaps are GPU-only split planning, fused permutation, overlap, full Qwen3.6 shapes, and dynamic-tenant source metadata. |
|
Latest validation (commit 3431c8b):
The draft remains intentionally open because arbitrary PP/CP, true communication overlap, exact prebuilt Megatron kernels, and matched full-model throughput are not complete. |
|
本轮更新(commit
仍保持已知边界:完整 Megatron matched throughput、native DeepEP C ABI、TE/FLA 无 JIT 接入、任意 PP/CP/ring attention 尚未完成。 |
|
追加 MoE A2A 更新(commit
该改动减少 NCCL enqueue,但 variable-count planning 仍需 host-visible counts;与 DeepEP 的 GPU-only layout/fused permutation/overlap 仍有实质差距。 |
|
追加 commit
|
|
A2A prefix-plan optimization pushed in baedae0. After count all-gather, dispatch/combine autograd now reuses one CPU int64 send/receive prefix plan; removed repeated count-to-CPU, memcpy, vector allocation, and prefix scans without changing NCCL message order/layout. H20 validation: cargo check, local-smoke, and distributed smoke all exit 0; MoE parity diff=0, fixed Adam oracle error=0, heterogeneous v2 all four ranks ok. Matched TP2xEP2 dynamic B8/S128/H1024 A/B: baseline mean/p50/p95 13.974047/13.792658/15.242697 ms; prefix 13.977255/14.008014/14.735662 ms; memory unchanged. This is deterministic host-bookkeeping cleanup, not a stable EP2 end-to-end speedup. |
|
Pushed This adds opt-in H20 ABI1 verification:
The roughly 0.6% mean difference is noise-scale, so this is documented as an optional launch/temporary reduction rather than a stable throughput claim. It does not close the remaining DeepEP/GPU-only metadata/communication-overlap gap. |
|
Pushed This addresses the dynamic multi-LoRA rotation residency issue. H20 ABI1 evidence:
Persistent Adam |
|
H20 ABI1 verification for commit
The audit/progress docs record the remaining Megatron gaps, including CPU optimizer-state paging, interleaved PP, general/ring CP, DeepEP/TE integration, request/compute overlap, and real-model long-run throughput. |
|
追加两项已验证改进:
H20 依赖核查确认当前 PyTorch 2.12.1+cu130 ABI1 环境无匹配 TE/DeepEP/FLA/standalone flash-attn 预编译包;PyTorch bundled Flash-SDPA 可用。未安装依赖、未引入 JIT。文档已明确剩余 Megatron 差距。 |
|
ABI31 后续切片已完成并推送(fac291a):dynamic Adam restore 改为一次性 bulk host import。完整 stage-local CPU FP32 m/v 先校验后原子发布,restore 后 GPU resident count=0;首次选中 tenant 才按 pair hydrate。native smoke 覆盖 partial import 原子失败、CPU export 不触发 hydrate、首次训练 resident=active_pairs*4、loss/参数/m/v resume parity。H20 ABI1 cargo check、local smoke、TP2xEP2 distributed smoke 均通过;磁盘 checkpoint 格式不变,仍未实现训练后 LRU eviction/完整 optimizer paging。 |
|
ABI32/host-paging follow-up is pushed on
This is bounded native selected-path host paging, not yet Megatron distributed optimizer/offload, asynchronous prefetch, PP-window eviction, or a matched full-model throughput result. |
|
Added and pushed commit
|
Scope
Harden the native C++ Qwen 3.5/3.6 LoRA training path and add progressively verified distributed runtime slices. This remains a draft because the full Megatron-level MoE performance stack, PP/CP, cross-topology resharding, real multi-node validation, and a matched Megatron benchmark are not complete.
Delivered
Fixed and dynamic multi-LoRA coverage for full attention, GDN, dense MLP, shared experts, and routed experts, with independent tenant optimizer clocks and checkpoint state.
Independent TP, EP, DP, and expert-DP communicators with strict topology validation.
TP x EP x DP source-coordinate handling for source-sharded and replicated-source EP policies. Server workers slice one global request by
(DP,EP)source coordinate while TP peers share rows; dynamic requests require the complete global source batch.Frozen attention/GDN/dense MLP and vocabulary TP, ABI19 packed top-k sharded A2A, and ABI20 routed/shared expert tensor parallelism. The server composes EP expert narrowing before routed/shared TP sharding and rejects unsupported replicated-expert TP early.
Checkpoint v5 with explicit rank order, five-axis coordinates, TP/EP compound tensor placements, fused routed gate/up segments, replica axes, and fixed/dynamic slot identities.
Explicit per-save checkpoint generations, same-generation reuse rejection, content digests, and compact rank receipts. New receipt-aware v5 preflight reads O(world_size) compact metadata plus rank-local full state and fails closed when a receipt is missing.
Shared CLI/server checkpoint implementation with rank-scoped save, same-topology restore, and v3/v4 plus pre-receipt v5 read compatibility.
Transactional distributed server checkpoint save/load. Save holds one dispatch lock across all ranks, writes an exclusive sibling staging directory, validates the full receipt set through shadow-context hydration, and publishes only a fresh destination with
RENAME_NOREPLACE. Load prepares communicator-attached shadow contexts without temporary-parameter broadcasts, then swaps live contexts only after every rank succeeds; partial commit fail-stops the worker group.Dynamic checkpoint restore validates each adapter's rank, alpha, target slots, tensor layout, Adam state, and private clock independently. Heterogeneous signatures may coexist after hydration; legacy training fails closed before forward unless selected adapters have homogeneous rank and canonical target sets.
Dynamic Adam now preflights every active tenant and tensor before one out-of-place fused launch. Persistent per-adapter shadow buffers eliminate per-step allocation; live BF16 parameters, FP32 m/v, and private clocks swap only after launch validation. Production remains stream-asynchronous, while strict/test mode waits for completion and supports failure injection before commit.
ABI23 adds live heterogeneous adapter registration and deterministic selected-tenant grouping by rank, canonical active slots, and tensor geometry. Tensor and borrowed host-i64 all-live/selected paths use v2. A later group failure rolls earlier parameter, FP32 m/v, and tenant-clock commits back through the persistent Adam shadows; per-group distributed success consensus prevents ranks whose homogeneous trainer returned from entering different subsequent groups.
Deterministic fixed or tenant-specific dynamic adapter merge into standard PEFT, including correct
[gate_all|up_all]reconstruction and dynamic optimizer clocks.Distributed CLI export with shared run identity, rank-isolated logs, unique attempt fencing, all-rank error reporting, completion markers, and atomic final directory publication.
Fixed-LoRA CLI
--resume-fromrestores projection-aware LoRA shards, CPU safetensors Adam m/v into CUDA/FP32 allocations, loss, and the native optimizer step after validating topology, adapter identity, and the canonical base-model path.Multi-node launch validation requires shared run/attempt IDs and shared output storage before workers start.
EP IPC uses one absolute command deadline. An incomplete semaphore generation poisons the channel; the first IPC failure terminates and reaps the worker group, health changes to 503, and later dispatches fail immediately. Partial launch and graceful shutdown also have bounded worker cleanup.
ABI22 adds a 64-byte aligned binary tensor slab between the HTTP parent and workers. The parent decodes and packs once; workers borrow validated
int64spans without per-worker vector deserialization, select topology-local rows, and enter one coarse C++ host-batch ABI for blocking H2D plus the full train/eval step. Legacy vector commands remain compatible.Tensor HTTP routes use a pre-extractor single-permit admission gate. This matches the already serialized IPC dispatch and prevents concurrent base64/decoded/slab buffers from multiplying peak memory while leaving health, checkpoint, and session control routes ungated.
The EP worker group owns one explicit base-model session, clears rank-local state on delete, preserves independent dynamic adapters within that session, and returns the native logical training step through HTTP and benchmark paths.
ABI24 separates heterogeneous signature forward/backward harvesting from one full-registry finalizer. All signature groups now share one token-normalization preflight, gradient synchronization boundary, out-of-place fused Adam transaction, and commit; fast-path finalization avoids activation chunk planning, registry metadata copies, and duplicate token-validity device fences.
Verification
Local IPC tests passed 13/13; focused server tensor shape/slab tests passed 5/5;
cargo check -p rustrain-server, the worker hot-path scan, andgit diff --checkpassed. Existing repository warnings remain.Independent final review found no blocker/high issue. Its medium unbounded-request-memory finding was fixed with pre-decode tensor-route admission and re-reviewed successfully; remaining low risks are startup-only shm cleanup/naming hardening and missing full HTTP-to-worker multi-process coverage.
H20 target: ABI22 single-GPU native smoke passed host/tensor eval loss parity with zero difference, fixed-LoRA training with zero Adam-oracle error, and selected dynamic multi-LoRA isolation with no unselected update.
H20 target: transactional dynamic Adam failure smoke executed the shadow update, injected failure before commit, and preserved the selected LoRA B, FP32 m/v, and tenant clock exactly. Consecutive successful steps covered persistent shadow reuse and autograd leaf preservation.
H20 target: heterogeneous restore smoke rejected ordinary mixed-signature registration, hydrated a rank-9
q_projadapter beside rank-8 expert adapters, and rejected same-rank/different-target legacy training before forward while preserving existing tenant clocks.H20 target: ABI22 world8 TP2 x EP2 x DP2
tri-smokepassed checkpoint resume, selected adapter isolation, and Adam oracles across ranks.H20 target: ABI23 single-GPU smoke passed live mixed-signature registration, duplicate/unknown-ID registry preservation, tensor and all-live host-i64 v2 dispatch, successful mixed rank/target training, and exact cross-group rollback.
H20 target: ABI23 world8 TP2 x EP2 x DP2 trained a rank-3
q_projtenant with rank-4 multi-module tenants on every rank. Rank-0-only wrapper and pre-commit Adam failures reached all-rank consensus, restored parameters and clocks exactly, and the same contexts subsequently completed a successful heterogeneous step.H20 target: TP2 x EP2 fixed/dynamic native smoke passed routed and shared expert LoRA, tenant isolation, FP32 Adam-state oracles, and checkpoint/resume.
H20 target: world8 TP2 x EP2 x DP2 passed both source-sharded and replicated-source native policies. Fixed updates reported zero Adam-oracle error on every rank; fixed resume restored parameters and Adam m/v with exact zero divergence and optimizer step
2.H20 target: dynamic multi-LoRA preserved tenant isolation and clocks
[1, 0], matched the full-reference Adam oracle, and completed a second resume/update cycle.H20 target: checkpoint v5 TP2 x EP2 fixed merge passed save, fresh per-rank restore, and fused expert ordering; dynamic merge preserved tenant identity and optimizer clock.
H20 target: ABI21 source-sharded world8 shadow resume passed all ranks. DP-nonzero fixed tensors were deliberately diverged before no-sync communicator attach and remained bitwise unchanged after attach; hydrate restored fixed/dynamic A/B, FP32 Adam m/v, and tenant step exactly, and continued training retained zero resume divergence. The ABI version, no-sync attach, and restore-adapter symbols are exported by the native library.
ABI20 regressions passed pure EP2, TP2 x DP2, and GDN TP2.
On the matched TP2 x EP2 fixed-LoRA workload, expert tensor parallelism reduced p50 from
8.742 msto6.923 msand increased unique-token throughput from58.57k/sto73.95k/s.The H20 target does not have a Rust toolchain, so the Rust HTTP/IPC tests ran locally against the repository ABI1 environment; remote post-integration evidence covers the native host ABI and world8 oracle, not a full HTTP/shared-slab server run.
H20 target: ABI24 single-GPU smoke proved two heterogeneous signatures trigger exactly one finalizer and one fused Adam launch. Group failure preserved counters and all fixed-accumulation flags/weights; all-live host-i64 dispatch used the same unified path.
H20 target: ABI24 world8 TP2 x EP2 x DP2 passed rank-0-only group, pre-token-preflight, and pre-commit Adam failure injection without collective phase mismatch. Failure paths preserved parameters, Adam state, clocks, and pending accumulation; the same contexts then completed one-finalizer/one-Adam heterogeneous training.
Assessment and limitations
The verified subset has direct numerical and performance evidence, but this branch does not establish correctness or high performance for every Qwen 3.5/3.6 configuration. It has not completed real 35B/Qwen3.6 long-running training, real cross-node training, PP/CP, cross-topology resharding, or a matched Megatron benchmark. Base-model resume identity is canonical-path based rather than content-fingerprint based. Distributed server save currently requires a fresh destination and provides atomic visibility, but it does not yet provide immutable generation/
LATESTrollover or power-lossfsyncdurability.The server's parent/worker IPC is now binary, but HTTP ingress remains JSON/base64 and pageable host memory. Raw binary HTTP, pinned staging, asynchronous H2D/request overlap, and full remote HTTP benchmarking remain open. Heterogeneous selected training now shares one synchronization and Adam boundary, but each distinct rank/target signature still requires its own forward/backward harvest. Gradient synchronization remains a sequence of per-tensor collectives rather than a bucketed/grouped launch, and group/finalizer success consensus reads a GPU flag to CPU. The phase protocol covers tested rank-local failures before token preflight and before Adam commit; it is not recovery from an unrecoverable CUDA/NCCL failure midway through the multi-collective gradient synchronization region. Persistent shadows cost about 10 additional bytes per active LoRA parameter, so large-tenant capacity and throughput still need a matched benchmark.
Compared with Megatron-LM, rustrain still lacks sequence parallelism, fused permutation/inverse permutation, host-free split planning, communication/GEMM overlap, shared-expert overlap, PP/CP, fused QKV/gate-up, and a verified prebuilt DeepEP/TE/FLA integration. The implemented path uses the existing prebuilt PyTorch ABI1 and NCCL runtime; it introduces no Python JIT or source-built dependency.
Latest validated additions
pp-train-smokepassed loss/gradient/parameter parity and rejected a rank-divergent target shape collectively.The remaining gap is narrower but still material: arbitrary/interleaved PP, PP-aware checkpoint placement, CP model execution, dynamic LoRA combined with PP/CP or sequence parallelism, fused/overlapped EP and dense kernels, raw/pinned asynchronous ingress, long-running real-model validation, and a matched Megatron throughput benchmark are not complete.