Skip to content

[moe] Add opt-in shared-expert CUDA stream overlap - #5685

Closed
shuhuayu wants to merge 1 commit into
mainfrom
shuhuayu/k3-dm-stack-12
Closed

shuhuayu wants to merge 1 commit into
mainfrom
shuhuayu/k3-dm-stack-12

Conversation

@shuhuayu

@shuhuayu shuhuayu commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary (human-written)

Independent PR on main.

Why

Shared experts do not depend on routed-expert dispatch/computation. Serial
execution cannot overlap them; an unordered side stream can read unfinished
inputs/outputs or recycled storage. This opt-in records input readiness before
routed launches and explicitly joins shared completion before output addition,
without changing model or autograd construction order.

Example.

from dataclasses import replace

# CUDA, TP=1, with shared experts; serial remains the default.
moe_config = replace(moe_config, overlap_shared_experts=True)
caller: input-ready -> router / routed experts -> wait shared -> add
             |                                      ^
shared:      +-------> shared experts ---------------+

What changed

  • Ordinary MoE and Kimi's latent MoE use the same event/stream boundary.
  • Protect input/output allocator lifetimes across streams, avoiding allocator
    operations on recompute placeholders.
  • Retain serial defaults; reject missing shared experts, CPU inputs, and TP>1.
  • Document the policy next to the MoE code (STREAM_OVERLAP.md). It is enabled
    by setting MoE.Config.overlap_shared_experts=True in a recipe; no recipe
    override is added, since this is a first-class config field rather than an
    alternative kernel.

Alternatives considered

  • Launching on an unordered stream risks data races and use-after-recycle.
  • Waiting for routed completion before starting shared work removes overlap.
  • Reordering Python branches changes autograd construction unnecessarily.
  • Unconditional overlap adds activation memory without proving a speedup.

User-facing changes

Before After
Shared experts execute serially after routed experts. The opt-in forks after input readiness and joins before addition.
No shared-stream policy exists. Serial remains default; unsupported opt-in modes raise.

Numerics and testing

Fresh on this branch (rebased onto main at 7e6c10618): 22 CPU tests and
6 GPU tests pass on one GB300.

GPU check Result
Ordinary/latent MoE, with and without FullAC, twelve eager updates Exact outputs, losses, norms, input gradients, all parameter gradients/updates versus serial.
Latent MoE, with and without FullAC, five changing-input graph updates Exact output, loss, gradients, and updates versus serial.
CUDA_VISIBLE_DEVICES='' python -m pytest -q -o addopts= --tb=short \
  tests/unit_tests/cpu/models/common/test_moe.py

CUDA_VISIBLE_DEVICES=0 python -m pytest -q -o addopts= --tb=short \
  tests/unit_tests/gpu/models/common/test_shared_expert_overlap.py

The GPU test builds its models on meta, casts to bf16, then calls to_empty()
and init_states(). That is the order main requires since #5153, which
rejects dtype casts of materialized buffers such as the router's float32
tokens_per_expert_E.

pre-commit passes. Deterministic execution is strict; assertions, tolerances,
and the nonfatal PyTorch AccumulateGrad stream warning were not weakened or
suppressed.

Landing gates

This is an independent candidate alongside the still-open
#5554. Maintainers should
choose one implementation; duplicate overlap implementations should not land.
No in-repo recipe enables this policy, and the full-scale Kimi K3 recipes do
not use it, so there is no throughput evidence for an overlap gain yet.

Fresh distributed FSDP/EP overlap and full-scale throughput remain unverified.
Whole-model compilation and GraphTrainer parallel-branch lowering are outside
this policy. Final-tip type checking and maintainer review/CI are still needed.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 29, 2026
@shuhuayu
shuhuayu force-pushed the shuhuayu/k3-dm-stack-12 branch from 95844b8 to ed9c993 Compare October 29, 2026 08:11
@shuhuayu
shuhuayu force-pushed the shuhuayu/k3-dm-stack-11 branch from ccf511a to 6c7a6fb Compare October 29, 2026 08:11
@shuhuayu
shuhuayu force-pushed the shuhuayu/k3-dm-stack-12 branch from ed9c993 to 86e2944 Compare October 30, 2026 06:13
@shuhuayu
shuhuayu force-pushed the shuhuayu/k3-dm-stack-11 branch from 6c7a6fb to ccdf6ee Compare October 30, 2026 06:13
shuhuayu added a commit that referenced this pull request Oct 30, 2026
#5674)

Part **1/n** of the Kimi K3 / Dist-MoE training stack. Based on `main`:
the review diff contains only this feature.

human notes:
previously: `distributed/utils.py::init_distributed()` passes
`CommConfig.init_timeout_seconds` to
`torch.distributed.init_process_group()` so the world group has, say, 30
minutes timeout. now, that remains unchanged. Additionally,
`TrainingEngine._initialize_distributed_runtime()` calls
`set_pg_timeouts()` after `ParallelismContext.from_config()`, so the
tracked mesh subgroups get the configured timeout before
model/FSDP/optimizer initialization. this also covers the RL trainer.
without this pr, independently created NCCL subgroups can still use the
default 10-minute timeout even though we configured 30 minutes. the
existing switch to `train_timeout_seconds` after the first step is
unchanged.

## Why

The world process group receives `comm.init_timeout_seconds`, but mesh
subgroups created later do not inherit it. They can retain the
backend-default startup timeout through model initialization and the
first update.

Example: with `CommConfig(init_timeout_seconds=1800)`, the world group
uses 1,800 seconds but a later NCCL subgroup can use its 600-second
default. This change applies the configured startup budget to the groups
tracked by `ParallelismContext` before model/FSDP/optimizer
initialization.

## What changed

- Call the existing `set_pg_timeouts()` helper immediately after
`ParallelismContext.from_config()` in the shared training engine.
- Apply the same call in the TorchFT runtime override.
- Preserve the unconditional post-first-step switch to
`train_timeout_seconds`, including fake backends.
- Add no helper, configuration field, or test. The deleted
forwarding-only mock test is not coverage for the current code.

## User-facing changes

| Configuration | Before | After |
| --- | --- | --- |
| `init_timeout_seconds=1800` | World: 1,800 s; tracked NCCL mesh groups
may use 600 s during startup. | World and tracked mesh groups: 1,800 s
during startup. |
| Default `init_timeout_seconds=300` | World: 300 s; tracked NCCL mesh
groups may use 600 s. | World and tracked mesh groups: 300 s during
startup. |
| After the first update | Existing switch to `train_timeout_seconds`. |
Unchanged. |

Groups created separately outside the context's tracked mesh map,
including optimizer-specific communicators, are not covered by this
call.

## Numerics

No model math, parameter layout, gradient policy, or checkpoint mapping
changes. The existing helper adds one startup barrier/device
synchronization; there is no new per-update synchronization.

## Testing

Rebased onto upstream `ad7a9937b5e57ccadebbb98b3eb14ff139ceb2b3`. The
feature diff is unchanged: ten added lines in the shared engine and
TorchFT override.

```bash
CUDA_VISIBLE_DEVICES='' python -m pytest -q -p no:cacheprovider --tb=short \
  tests/unit_tests/cpu/test_trainer.py \
  tests/unit_tests/cpu/distributed/test_distributed_utils.py
```

Result: **76 passed**. These existing CPU tests do not directly verify
real NCCL subgroup timeout values.

## Known issues / landing gates

All non-type pre-commit checks passed in the preceding review. The three
Pyrefly failures were independently reproduced on unchanged upstream:
missing `torch_checkpointing.checkpoint_writer.CallbackArgs`, its
callback signature mismatch, and optional `video.stream.time_base`
multiplication. No unrelated source or dependency workaround is
included.


## Stack

Bottom of stack; based on `main`. Next:
[#5675](#5675).

<details>
<summary>Full draft stack — review and land in this order</summary>

| Position | Draft PR |
| --- | --- |
| 1/n | [#5674 — [distributed] 1/n Apply initialization timeouts to mesh
process groups](#5674) |
| 2/n | [#5675 — [fsdp] 2/n Expose explicit backward-prefetch
policy](#5675) |
| 3/n | [#5676 — [fsdp] 3/n Support layer-scoped CPU
offload](#5676) |
| 4/n | [#5677 — [optim] 4/n Bound optimizer memory ownership and
allocation lifetimes](#5677) |
| 5/n | [#5678 — [dist_muon] 5/n Support CP and TP storage-to-compute
layouts](#5678) |
| 6/n | [#5679 — [profiler] 6/n Preserve failure context and merge
CUDA-graph streams](#5679) |
| 7/n | [#5680 — [kda] 7/n Preserve graph metadata and expose
chunk-kernel options](#5680) |
| 8/n | [#5681 — [cp] 8/n Add configurable graph-friendly Ulysses
transport](#5681) |
| 9/n | [#5682 — [compile] 9/n Compile MLA assembly and router
postprocessing](#5682) |
| 10/n | [#5683 — [pp] 10/n Make cache release and FSDP chunk lifetimes
explicit](#5683) |
| 11/n | [#5684 — [dist_moe] 11/n Enable Kimi K3 SiTU-GLU training and
pipeline lifecycle](#5684) |
| 12/n | [#5685 — [moe] 12/n Add opt-in shared-expert CUDA stream
overlap](#5685) |
| 13/n | [#5686 — [ac] 13/n Add block-scoped activation
retention](#5686) |

</details>

After the preceding PR lands, rebase the remaining suffix onto updated
main and retarget its next bottom PR to main. Keep the rest stacked; no
automatic landing is requested.
@shuhuayu
shuhuayu force-pushed the shuhuayu/k3-dm-stack-11 branch from ccdf6ee to 664401a Compare November 4, 2026 00:13
@shuhuayu
shuhuayu force-pushed the shuhuayu/k3-dm-stack-12 branch from 86e2944 to 5e73b43 Compare November 4, 2026 00:13
shuhuayu added a commit that referenced this pull request Nov 4, 2026
…tion (#5681)

Part **8/n** of the Kimi K3 / Dist-MoE training stack. Based directly on
`main`; this PR can land independently of the remaining stack.

human notes: fix the nccl ulysses safeguard that uses `Ulysses.Config`
instead of `UlyssesInnerAttention.Config`.

## Why

The existing NCCL Ulysses safeguard detects
`UlyssesInnerAttention.Config`.
Compact MLA, Ulysses KDA, and Ulysses GDN instead inherit directly from
`Ulysses.Config`, so these models miss the existing protection on
affected
NCCL versions.

Example: `UlyssesMLAAttention.Config` does not inherit from
`UlyssesInnerAttention.Config`. On NCCL 2.32.2 the old traversal leaves
graph
registration enabled; traversing the common base selects the existing
safeguard.
The NCCL fix and version boundary are unchanged:
[NVIDIA/nccl#2362](NVIDIA/nccl#2362).

## What changed

- Match the common `Ulysses.Config` base in the existing safeguard.
- Add one isolated GDN regression for a subclass outside the old
hierarchy.
Full attention uses K/V all-gather in this test, so it cannot
accidentally
  trigger the old safeguard.
- Keep the existing version-boundary and unsupported-runtime tests
rather than
  repeating them for each backend.

There are only two production-line replacements. Native attention and
communication paths are unchanged; no new option or dependency is
introduced.

## User-facing changes

| Before | After |
| --- | --- |
| The safeguard detects only full-attention Ulysses wrappers. | It also
detects compact MLA and linear-attention Ulysses wrappers. |
| NCCL >= 2.32.3, non-CUDA, and fake runtimes skip the safeguard. |
Unchanged. |

## Numerics

No tensor computation, collective implementation, parameter, or
checkpoint
layout changes. This extends an existing pre-initialization runtime
policy.
The CPU checks below do not claim fresh end-to-end training or
throughput
acceptance.

## Testing

Fresh validation against upstream
`73c4ebdac57de0d89bb20d5dfabed340449c8b0d`:

- **91 CPU tests and 84 subtests passed**, with no deselection.
- **Fresh negative control:** the retained GDN regression fails on
untouched main
because `NCCL_GRAPH_REGISTER` remains unset; it passes with this change.
- All non-type-checking pre-commit hooks passed over all files.

```bash
CUDA_VISIBLE_DEVICES='' python -m pytest -q -o addopts='' -p no:cacheprovider --tb=short \
  tests/unit_tests/cpu/distributed/test_ulysses_nccl.py \
  tests/unit_tests/cpu/models/common/test_cp_attention.py \
  tests/unit_tests/cpu/config/test_context_parallel_validation.py
```

The type error at unchanged
`torchtitan/components/data/multimodal/utils/video.py:114` independently
reproduces on untouched upstream `73c4ebdac`. This PR does not change
that file.

Not verified: a fresh real multi-rank CP/CUDA-graph training run.

## Stack

This PR is directly based on `main` and does not require 4/n-7/n. The
other
source branches are unchanged by this update.

1/n (#5674) is merged; 2/n (#5675) and 3/n (#5676) are closed.

| Position | PR |
| --- | --- |
| 4/n | [#5677](#5677) |
| 5/n | [#5678](#5678) |
| 6/n | [#5679](#5679) |
| 7/n | [#5680](#5680) |
| 8/n | [#5681](#5681),
independent on main |
| 9/n | [#5682](#5682) |
| 10/n | [#5683](#5683) |
| 11/n | [#5684](#5684) |
| 12/n | [#5685](#5685) |
| 13/n | [#5686](#5686) |
| 14/n | [#5793](#5793),
full-scale MXFP8 recipes |
@shuhuayu
shuhuayu force-pushed the shuhuayu/k3-dm-stack-12 branch 2 times, most recently from ea78b7b to b117ce9 Compare November 5, 2026 07:13
@shuhuayu
shuhuayu force-pushed the shuhuayu/k3-dm-stack-11 branch 2 times, most recently from 14eb78d to 768b32b Compare November 5, 2026 08:50
@shuhuayu
shuhuayu force-pushed the shuhuayu/k3-dm-stack-12 branch from b117ce9 to 3157b3a Compare November 5, 2026 08:50
shuhuayu added a commit that referenced this pull request Nov 5, 2026
Part **4/n** of the Kimi K3 / Dist-MoE training stack. Based directly on
`main`: the review diff contains only the optimizer-memory changes
below.

human notes: 
1. release distmuon's gpu redistribution and compute scratch after each
eager optimizer update by default. 1) in full eager training, later
fwd/bwd can reuse the released memory. 2) if one rank has two eager
optimizers (fwd/bwd can use cudagraph), like when vpp=2, their scratch
allocations can reuse memory instead of remaining simultaneously
resident. keep tensor metadata and cpu scratch, and release unused ns
intermediates earlier without changing the math.
2. the flow is: reserve shapes/dtypes/device, and use allocate for
setting real storage, and use resize_(0) to free the storage.
3. remove some ns step intermediate tensors without changing math. 

## Why

DistMuon retains exchange and compute scratch between updates, even when
eager forward/backward or a second eager optimizer could reuse that
memory. Dropping scratch allocated on the transfer stream does not let
the caller stream reuse its cached blocks.

Prepare the buffer capacities once, then regrow and release accelerator
backing storage on the caller stream. Keep CPU backing storage allocated
between updates to avoid repeated host allocations. Tensor objects,
shapes, bucket plans, communication streams/events, parameters, and
optimizer state remain alive. This is the default behavior; no new
config knob is added.

**Example.**

```python
# Forward/backward may be eager or CUDA-graphed; optimizer updates are eager.
chunk0_optimizer.step()  # Regrow cached scratch, update, resize storage to zero.
chunk1_optimizer.step()  # Can reuse released caller-stream allocator blocks.
# With one optimizer, later eager forward/backward can reuse those blocks too.
# A separate forward/backward CUDA-graph pool cannot reuse normal-pool scratch.
```

## What changed

- Keep the four scratch tensor types and their metadata; prepare
capacities at construction or checkpoint replanning, not before every
update.
- Regrow released backing storage with `untyped_storage().resize_(size)`
on the current caller stream. Preserve the existing transfer/caller
event ordering, then release accelerator storage with `resize_(0)` after
a successful eager update. CPU storage stays allocated; `allocate()`
already skips correctly sized storage.
- Make storage release the default rather than introduce a persistence
knob. Because every storage lifetime begins and ends on its caller
stream, the old persistent-buffer caller-tracking set is unnecessary.
- Release obsolete Newton-Schulz intermediate references after their
last use. Arithmetic, compute dtype, and update ordering do not change.

The net diff touches the runtime, DistMuon implementation, and one CPU
runtime regression. Existing optimizer/checkpoint tests exercise the new
default without new distributed CI variants. There are no
trainer/container changes, synthetic all-to-all warmups, new
dependencies, or communicator/CTA changes.

## User-facing behavior

| Before | After |
| --- | --- |
| Accelerator scratch tensor objects and backing storage remain resident
between updates | Tensor objects persist; accelerator backing storage is
released after each eager update |
| CPU scratch remains allocated between updates | Unchanged; the release
loop skips CPU tensors |
| Several eager optimizers each retain their scratch arena | Sequential
eager updates can reuse caller-stream scratch allocations |
| Forward/backward graph pools are separate from optimizer scratch |
Unchanged; this PR does not implement graph-pool sharing |

## Numerics

Compared with the `main` parent `22047b18a`:

- GPU 0: FP32 and BF16 parameters each produced bitwise-identical loss,
gradients, and updated weights for ten updates, with both eager and
CUDA-graphed forward/backward. Each run reloaded an optimizer checkpoint
after update five.
- Real two-rank CPU/Gloo redistribution: owned, uneven mixed-block, and
expert matrices produced bitwise-identical updated weights for ten
updates and a checkpoint reload. The owned matrix also matched
`torch.optim.Muon` exactly. Scratch tensor identities survived
updates/reloading; CPU backing storage now stays allocated between
updates, matching the host-buffer behavior on `main`.
- A standalone one-rank optimizer-capture smoke test completed ten
exact-parity replays. This is not multi-rank optimizer-graph validation;
the Titan optimizer container still does not enable DistMuon capture.

Fresh follow-up checks against the previous PR head `a4fada369` also
produced exact FP32/BF16 eager and graphed loss/gradient/weight parity,
and exact two-rank Gloo updates. An actual single-GPU FSDP2
`CPUOffloadPolicy` run with `ns_device=None` completed ten updates and a
checkpoint reload: a 16-to-16-to-8 linear model (384 weights, eight
input rows) kept its 1,024-byte host scratch allocated and reused its
pointer between replans, with bitwise-identical loss, gradients, and
weights. This is correctness/lifecycle evidence, not an offload
throughput or host-allocation-cost measurement.

Fresh multi-rank NCCL validation has not been rerun because only GPU 0
was available.

## Memory evidence

The following accelerator-only measurements predate the CPU-retention
correction; the correction does not change the accelerator release
branch. This is a synthetic single-GPU GB300 allocator benchmark, not a
Kimi K3 training run. BF16 forward/backward uses a bias-free
1024-to-8192 linear layer (8.39M weights) with 4096 input rows. Each
eager DistMuon instance updates a separate 29.36M-parameter workload
(14.68M local parameters on shape-only fake DP=2), with FP32
parameters/gradients/momentum, BF16 compute, and one Newton-Schulz
iteration.

The table covers ten updates after two eager warmups; graph cases
additionally capture/replay forward/backward before measurement. Values
are PyTorch allocator counters, not total device HBM. FakePG is used for
shapes here, not distributed numerical evidence.

| Forward/backward | Eager optimizers | Peak allocated: parent -> PR |
Steady reserved: parent -> PR |
| --- | ---: | ---: | ---: |
| Eager | 1 | 672 -> 528 MiB | 722 -> 594 MiB |
| Eager | 2 | 984 -> 696 MiB | 1058 -> 774 MiB |
| CUDA graph | 1 | 424 -> 420 MiB | 788 -> 800 MiB |
| CUDA graph | 2 | 736 -> 588 MiB | 1124 -> 980 MiB |

Each optimizer retains 144 MiB of scratch capacity metadata but zero
backing storage after an update, versus 144 MiB resident on the parent.
All cases had zero allocator retries. The single-optimizer graph case
does not show meaningful scratch-related peak savings; the two-optimizer
case demonstrates normal-pool scratch reuse, not graph-pool sharing.

A separate setup-call census over ten updates/two optimizers recorded
zero `reserve_buffers` and `_reserve_tensor` calls in the new steady
loop, versus 20 and 180 calls in the previous transient implementation.
Storage allocation/free operations still occur. No full-scale HBM or
throughput gain is claimed.

## Testing

- **123 CPU tests passed** for redistribution, optimizer
state/configuration, trainer, and accelerator graphs. The one added CPU
regression checks all four scratch buffer roles for ten release/allocate
cycles, verifying retained host capacity, pointers, and contents; it
fails cleanly against the previous PR head.
- The supplementary GPU-0, FSDP2 CPU-offload, and real Gloo probes above
passed; no new multi-GPU CI variants were added.
- All non-type-checking pre-commit hooks passed across the repository.
Both changed production files and the CPU regression pass focused
Pyrefly.
- Full-project Pyrefly reports the same single optional-value error at
`components/data/multimodal/utils/video.py:114` on both this patch and
the independently checked `main` parent. No unrelated fix or suppression
is included.

```bash
CUDA_VISIBLE_DEVICES='' python -m pytest -q \
  tests/unit_tests/cpu/distributed/flex_shard \
  tests/unit_tests/cpu/components/optim/test_optimizer_param_groups.py \
  tests/unit_tests/cpu/components/optim/test_optim.py \
  tests/unit_tests/cpu/test_trainer.py \
  tests/unit_tests/cpu/distributed/test_accelerator_graph.py

SKIP=pyrefly-check pre-commit run --all-files
pyrefly check torchtitan/distributed/flex_shard/_optimizer_reshard_runtime.py \
  torchtitan/distributed/flex_shard/dist_muon.py \
  tests/unit_tests/cpu/distributed/flex_shard/test_optimizer_reshard_runtime.py
```

## Stack

Based directly on `main`. Next:
[#5678](#5678).

<details>
<summary>Draft stack — review and land in this order</summary>

1/n (#5674) and 8/n (#5681) are merged. 2/n (#5675) and 3/n (#5676) are
closed because the chosen full-scale recipes use neither the
prefetch-disable policy nor selected-layer CPU offload. They are no
longer in the stack.

| Position | Draft PR |
| --- | --- |
| 4/n | [#5677 — [distmuon] 4/n Release scratch storage between
optimizer updates](#5677) |
| 5/n | [#5678 — [dist_muon] 5/n Support CP and TP storage-to-compute
layouts](#5678) |
| 6/n | [#5679 — [profiler] 6/n Preserve active failures during
shutdown](#5679) |
| 7/n | [#5680 — [attention] 7/n Keep linear-attention graph metadata
replayable](#5680) |
| 8/n, merged | [#5681 — [cp] 8/n Apply the Ulysses NCCL safeguard to
compact and linear
attention](#5681) |
| 9/n | [#5682 — [compile] 9/n Compile MLA assembly and router
postprocessing](#5682) |
| 10/n | [#5683 — [pp] 10/n Add once-only startup cache
release](#5683) |
| 11/n | [#5684 — [dist_moe] 11/n Enable Kimi K3 SiTU-GLU training and
pipeline lifecycle](#5684) |
| 12/n | [#5685 — [moe] 12/n Add opt-in shared-expert CUDA stream
overlap](#5685) |
| 13/n | [#5686 — [ac] 13/n Add block-scoped activation
retention](#5686) |
| 14/n | [#5793 — [recipes] 14/n Add full-scale Kimi K3 MXFP8
recipes](#5793) |

</details>

After this PR lands, rebase the remaining suffix onto updated main and
retarget its next bottom PR to main. Keep the rest stacked; no automatic
landing is requested.
@shuhuayu
shuhuayu force-pushed the shuhuayu/k3-dm-stack-11 branch from 768b32b to 7ec9131 Compare November 5, 2026 19:40
@shuhuayu
shuhuayu force-pushed the shuhuayu/k3-dm-stack-12 branch 2 times, most recently from 101d409 to f79a8e7 Compare November 6, 2026 01:27
@shuhuayu
shuhuayu force-pushed the shuhuayu/k3-dm-stack-11 branch from 7ec9131 to bc5ca00 Compare November 6, 2026 01:27
@shuhuayu
shuhuayu force-pushed the shuhuayu/k3-dm-stack-12 branch from f79a8e7 to df43bb5 Compare November 6, 2026 01:34
@shuhuayu
shuhuayu force-pushed the shuhuayu/k3-dm-stack-11 branch 2 times, most recently from 21376c3 to 8cc7b05 Compare November 10, 2026 09:23
@shuhuayu
shuhuayu force-pushed the shuhuayu/k3-dm-stack-12 branch from df43bb5 to 71aeff8 Compare November 10, 2026 09:36
@shuhuayu
shuhuayu changed the base branch from shuhuayu/k3-dm-stack-11 to main November 10, 2026 09:36
@shuhuayu shuhuayu changed the title [moe] 12/n Add opt-in shared-expert CUDA stream overlap [moe] Add opt-in shared-expert CUDA stream overlap Nov 10, 2026
@shuhuayu
shuhuayu force-pushed the shuhuayu/k3-dm-stack-12 branch from 71aeff8 to 209b0e5 Compare November 10, 2026 09:45
Join shared-expert side-stream work with explicit readiness and lifetime dependencies. Keep serial execution as the default and reject unsupported CPU or tensor-parallel configurations.
@shuhuayu
shuhuayu force-pushed the shuhuayu/k3-dm-stack-12 branch from 209b0e5 to dba5dbd Compare November 10, 2026 09:53
@shuhuayu

Copy link
Copy Markdown
Contributor Author

Closing. No recipe in the repo enables shared-expert overlap, and the full-scale Kimi K3 recipes run the shared experts serially, so this has no consumer and no throughput evidence yet. #5554 covers the same idea; shared-expert overlap can continue there.

If it comes back, it needs a measured gain first: tokens/s and peak memory with the overlap on vs. off on a representative EP run, plus a trace showing the shared GEMMs overlapping the routed all-to-alls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/rl CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant