Repository navigation
feat: add reset-aware KDA recursive doubling and Ulysses CP - #1027
Merged
github-actions[bot] merged 1 commit intoNov 3, 2026
Merged
Conversation
xuxl1008
requested review from
liuchongming74,
suteng,
yangzhenzhang02 and
yaoyifanx
as code owners
September 29, 2026 01:23
xuxl1008
marked this pull request as draft
October 19, 2026 07:28
xuxl1008
force-pushed
the
feat/kda-cached-rd-cp
branch
from
October 19, 2026 07:29
775564e to
751ecd6
Compare
4 of 5 tasks
xuxl1008
force-pushed
the
feat/kda-cached-rd-cp
branch
2 times, most recently
from
October 26, 2026 15:32
ce0c545 to
6fb380a
Compare
Contributor
Author
|
/check-pr |
Contributor
Author
|
/retest |
|
26 tasks
xuxl1008
force-pushed
the
feat/kda-cached-rd-cp
branch
from
October 29, 2026 16:59
6fb380a to
3f53b2b
Compare
xuxl1008
marked this pull request as ready for review
October 31, 2026 08:58
xuxl1008
force-pushed
the
feat/kda-cached-rd-cp
branch
from
October 31, 2026 09:34
3f53b2b to
3efec7b
Compare
Contributor
Author
|
/retest |
1 similar comment
Contributor
Author
|
/retest |
|
|
Contributor
Author
|
/retest |
|
|
Contributor
Author
|
/retest |
|
|
suteng
approved these changes
Nov 3, 2026
suteng
approved these changes
Nov 3, 2026
yangzhenzhang02
approved these changes
Nov 3, 2026
liuchongming74
approved these changes
Nov 3, 2026
yaoyifanx
approved these changes
Nov 3, 2026
github-actions
Bot
merged commit Nov 3, 2026
8abb8e9
into
mindspore-ai:master
12 of 27 checks passed
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.
Summary
Related issue: #1220.
Kimi Delta Attention (KDA) represents a local sequence segment by an affine state summary,
H_out = S + M @ H_in. A sequential P2P chain has a dependency depth linear in the state-group size. This PR adds ordered recursive doubling (RD), including Ulysses × RD, and prunes communication and summary production across real packed-document resets.RD is explicitly selected with
backend: tritonandstate_cp_method: recursive_doubling. The default remains P2P. The configuration examples use the currentplan_overrides.replaceschema; forward method replacement already defaults toregion_dispatch: false, so the examples omit that redundant field.Implementation
torch.distributed.batch_isend_irecvhandles communication. Buffer lifetimes remain protected by completion dependencies. Pointwise kernels fuse packing, addition and compact cache writes while retaining matrix arithmetic and composition order.Supported scope: Ascend NPU/HCCL, BF16, K=V128, lower-bounded gates, and equally sized contiguous nonempty rank shards in sequence order. Dense and TND tails need not be multiples of 64 tokens. Ordered DP×CP submeshes and Ulysses × RD are supported. NCCL, production CPU/Gloo execution, zigzag or unequal rank shards, TP×CP, graph capture and inference caches are outside this PR.
Cost and memory
Let
R = CP / Uand let one FP32 state occupyW = 4 × B × (H/U) × 128²bytes. A single long document requires at mostceil(log2 R) + 1stages per direction; real TND resets can remove stages and messages. The worst rank retains up toW × ceil(log2 R)transition-cache bytes per invocation. Live layers and microbatches accumulate these caches independently.For B1/H96/U1, W is 6 MiB: the worst-rank cache is 18 MiB at CP8 and 48 MiB at CP256. These are tensor-size and schedule estimates, not large-CP hardware measurements. Fewer stages do not guarantee a faster complete layer: summary production, composition, handoff and concurrent communication remain relevant.
Validation
This update: rebased onto upstream master; 35 existing CPU tests passed for RD planning, packed metadata and KDA/GDN model/configuration contracts. The YAML fixtures verify the default execution mode and its serialized form. No new test files or numerical-threshold changes were introduced. This documentation/configuration update does not change RD runtime or kernel arithmetic, and does not claim a new NPU run.
Retained NPU evidence was collected on 910B3 with Torch/Torch-NPU 2.10.0, CANN 9.1.0-beta.3, Triton-Ascend 3.2.2+gitc22984ba and FLA commit
6b6f546f9bd10a97be1e8cf2f0120de70cfca482:L2(error) <= 1e-6 × L2(reference) + 1e-12and maximum absolute error<= 2e-6The zero-M boundary test validates reset arithmetic; real TND execution and pruning are covered separately by packed-layer and planner checks. Remote CI status is reported by the checks on the current commit.
Numerical scope
The fixed-summary FP64 checks validate the distributed affine scan and its reverse accumulation. The complete-layer regression validates changes against the previous RD implementation. Neither is a full-model FP64 comparison or a long-training convergence result.
On a previously recorded sensitive CP8/local4K dense input with H96/K128 and hidden size 512, RD versus P2P reached maximum relative L2 differences of 0.484164% for hidden gradients and 0.427030% for individual reduced parameter gradients. These exceed the existing
0.003screening threshold, which has not been relaxed. This is a local compatibility threshold, not a universal training-accuracy standard.RD and P2P use different floating-point composition orders, and native nonzero-state mixed-precision feedback is not strictly affine. The historical comparison is therefore retained as a limitation rather than reported as passed. RD remains opt-in, and P2P remains the default.