Skip to content

[CUDA] Add fork/join execution on CUDA streams - #199128

Closed
MatthiasKohl wants to merge 11 commits into
gh/MatthiasKohl/2/basefrom
gh/MatthiasKohl/2/head
Closed

MatthiasKohl wants to merge 11 commits into
gh/MatthiasKohl/2/basefrom
gh/MatthiasKohl/2/head

Conversation

@MatthiasKohl

@MatthiasKohl MatthiasKohl commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Stack from ghstack (oldest at bottom):

Authored with an AI assistant.

Add torch.cuda.execute_on_streams for fork/join execution with ordinary
streams, green-context streams, or mixtures. Queued work is joined and
caller state restored even when a callback raises.

Same-device execution switches directly between streams and restores the caller once to reduce host-side overheads. Cross-device execution uses stream context managers to restore device and stream state.

Test Plan

Tested on Rubin with driver R610 + CUDA 13.4 compat (56 tests passed)

). This stack adds:

1. convenience functions to allocate localized memory
2. convenience function to execute operations in several green contexts through the fork/join pattern
3. minor fixes to green contexts discovered during testing of localized workloads

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/199128

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit 43b371c with merge base d0b8bbb (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@MatthiasKohl
MatthiasKohl marked this pull request as ready for review September 30, 2026 10:35
@MatthiasKohl
MatthiasKohl requested a review from ngimel September 30, 2026 10:36
MatthiasKohl added a commit to MatthiasKohl/pytorch that referenced this pull request Sep 30, 2026
Add `execute_in_green_contexts` to fork work from the caller stream into supplied green-context streams and join queued work back to the caller. Same-device execution switches directly between streams and restores the caller once to reduce host-side overheads. Cross-device execution uses stream context managers to restore device and stream state.

> Authored with an AI assistant.
>
> Callbacks that raise still restore the caller state and join work already queued.

Test Plan

Tested on Rubin with driver R610 + CUDA 13.4 compat.
56 tests passed.

```sh
python test/test_cuda.py TestCudaGreenContextsCUDA TestGreenContextExecution -v
```

ghstack-source-id: a021045
Pull-Request: pytorch#199128
@ngimel

ngimel commented Oct 1, 2026

Copy link
Copy Markdown
Collaborator

AI-assisted

Could this be torch.cuda.execute_on_streams(streams, fn) rather than green_contexts.execute_in_green_contexts(green_ctx_streams, fn)? The implementation only selects streams and records/waits on events; it never uses green-context state or locality metadata. Ordinary streams, green-context streams, and mixtures should share the same fork/join API. Please put the primitive with the stream utilities and keep green contexts as an example.

Please reduce the nine-case mocked stream-switching matrix. Success, exceptions, restoration, and joining are already exercised by the hardware tests. At most, keep a focused test for the intended same-device fast path; exact event-construction order and stream-selection call sequences should not become the behavioral contract. Hardware coverage for ordinary streams and capture/replay through this helper would be more useful.

@MatthiasKohl MatthiasKohl changed the title [CUDA] Add fork/join execution for green context streams [CUDA] Add fork/join execution on CUDA streams Oct 2, 2026
@MatthiasKohl

Copy link
Copy Markdown
Collaborator Author

@ngimel

Could this be torch.cuda.execute_on_streams(streams, fn) rather than green_contexts.execute_in_green_contexts(green_ctx_streams, fn)?

yes this makes sense, I have updated the PR accordingly, as well as reduced the test matrix.
Please let me know if anything else needs changes.

@ngimel

ngimel commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

@claude typically users would want functional callbacks that return some result (y = fn(x)) yet it doesn't seem like current API supports it. The out overload used in the example specifically prohibits autograd, out overloads are pretty limiting. Can you propose some better API?

@claude

claude Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Claude finished @ngimel's task in 1m 6s —— View job


Proposal: make it a map-style helper that passes per-stream arguments, returns fn's results as a list, and calls record_stream for the caller, so y = fn(x) (and autograd) just works.

Details: proposed API, sketch, and caveats

Why fn(index) -> None + out= is limiting

  • Autograd: out= ops don't record a grad_fn. If the callbacks return freshly computed tensors, autograd works on its own. The engine runs each backward node on the stream its forward ran on and adds the cross-stream syncs, so nothing autograd-specific is needed in the helper.
  • Allocator safety is the real reason for out=. A tensor allocated inside fn belongs to the side stream S's pool. Say the caller reads it on the caller stream C and then frees it. The allocator hands the block back to S right away, and the next allocation on S can reuse it while C is still reading. Inputs have the mirror problem: they are allocated on C, read on S, and the caller may free them right after the call returns. Preallocating outputs on C avoids the first hazard but not the second. If the helper owns inputs and outputs, it can handle both with record_stream, so users don't have to think about it.

Proposed API

T = TypeVar("T")

def execute_on_streams(
    streams: Sequence[Stream],
    fn: Callable[..., T],
    *iterables: Iterable[Any],
) -> list[T]:
    """Like ``map(fn, *iterables)``, with call ``i`` enqueued on ``streams[i]``
    and forked from / joined back to the caller stream."""

Usage:

ys = torch.cuda.execute_on_streams(streams, model_shard, xs)           # y_i = f(x_i)
ys = torch.cuda.execute_on_streams(streams, lambda f, x: f(x), fns, xs)  # different fn per stream
ys = torch.cuda.execute_on_streams(streams, fn, range(len(streams)))  # current index-based form
loss = sum(y.sum() for y in ys); loss.backward()                       # autograd works

It follows the shape of map / Executor.map. Different work per stream (e.g. attention and MLP side by side) doesn't need extra API surface, and the current index-based usage is just range(n).

Implementation sketch (diff against current streams.py)

from torch.utils._pytree import tree_leaves

def _record(tree, stream):
    for t in tree_leaves(tree):
        if isinstance(t, torch.Tensor) and t.is_cuda:
            t.record_stream(stream)

# in execute_on_streams
args_per_stream = list(zip(*iterables, strict=True)) if iterables else [()] * len(streams)
if len(args_per_stream) != len(streams):
    raise ValueError(...)
results = []
...  # same fork loop as today, per stream:
        stream.wait_event(start)
        _record(args, stream)          # caller may free inputs before S finishes
        try:
            results.append(fn(*args))
        finally:
            done.record(stream)
            completed += 1
...  # same join in finally
for r in results:
    _record(r, caller_stream)          # outputs are freed/reused from C's perspective
return results

Both the same-device fast path and the cross-device path keep their current structure. Only argument passing, result collection and the two _record calls are new.

Caveats to check

  • record_stream only reaches tensors that go through args or come back as results. Tensors captured by closure still follow the manual lifetime rules, so the docs should keep that note, just narrower.
  • record_stream adds an event record when the block is freed. That's cheap, but add a short hardware test that captures and replays this helper in a CUDA graph, together with returned outputs, to confirm it behaves under capture. ngimel also asked for capture/replay coverage earlier.
  • If a callback raises, the partial results are dropped, and the join still covers the work that was already enqueued, as it does today.
  • An optional kwargs iterable isn't needed; functools.partial / a lambda covers it.

AI-generated proposal (Claude). I have not built or run this code; it is a design sketch for the author and reviewers to evaluate.

@ngimel

ngimel commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

@claude can you learn at some point truly for real and forever that record_stream is banned and no one should ever call it?

@claude

claude Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Claude finished @ngimel's task in 1m 3s —— View job


You're right, and I'm sorry. Here is the corrected proposal with no record_stream. It turns out the helper's own fork/join ordering already covers the allocator hazard I tried to patch with it.

Details: corrected API and why no lifetime hooks are needed

Retraction

Please ignore every record_stream / _record call in my previous comment. record_stream makes block reuse depend on event polling at allocation time, which means nondeterministic memory spikes. It also behaves badly under graph capture. PyTorch code should not call it.

Why the fork/join already makes returned tensors and inputs safe

  • Outputs (allocated on side stream S, used and then freed by the caller on C): the next allocation on S that can reuse the block is enqueued only after a later fork's S.wait_event(start), and start is recorded on C after every prior C-side use of that tensor. So S cannot overwrite the block while C is still reading it.
  • Inputs (allocated on C, read on S, freed by the caller after return): the join makes C wait on each done event before any later C work, so reusing the block on C is ordered after S has finished reading it.
  • The remaining requirement is a documented contract, not a runtime hook: side streams must not get new work outside this helper (or outside some other explicit wait_stream/wait_event on the caller stream) while tensors that crossed streams are still alive. Tensors passed from one callback to another (allocated in fn_i on S_i, freed in fn_j on S_j) are outside the contract.

API (same shape as before, minus lifetime hooks)

def execute_on_streams(
    streams: Sequence[Stream],
    fn: Callable[..., T],
    *iterables: Iterable[Any],
) -> list[T]:
    """Like ``map(fn, *iterables)``, with call ``i`` enqueued on ``streams[i]``,
    forked from and joined back to the caller stream."""
ys = torch.cuda.execute_on_streams(streams, shard_fn, xs)   # y_i = f(x_i), autograd works
ys = torch.cuda.execute_on_streams(streams, fn, range(len(streams)))  # current index form

The implementation is today's fork loop plus args = zip(*iterables, strict=True) (checked against len(streams)), results.append(fn(*args)) and return results. Nothing else changes. Autograd already runs each backward node on its forward stream and inserts the cross-stream syncs.

Tests worth adding

  • Return values that are then consumed and freed on the caller stream, followed by a second execute_on_streams call that allocates on the same side streams. This exercises the reuse-ordering argument above.
  • Capture and replay of the helper with returned outputs.

AI-generated (Claude). The ordering argument above is a design analysis; I have not run it on hardware. On "learn forever": this bot runs on a fresh checkout every time and keeps no memory between jobs. The durable fix would be a maintainer adding a line like "Never call Tensor.record_stream; rely on stream/event ordering instead" to the repo's CLAUDE.md. I can't make that edit here because write operations are disabled on this ghstack PR.

@ngimel

ngimel commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

@claude but if we are making allocations on stream S we also should activate corresponding mempool there to get advantage of locality domains?

@claude

claude Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Claude finished @ngimel's task in 1m 11s —— View job


Yes. Without a localized pool, the outputs that a green-context callback allocates come from the default pool, so they land on whatever physical memory that pool has. You get compute locality but not memory locality. I'd add an optional per-stream pool argument to the helper rather than tying pools to streams.

Details: proposed shape, why it's explicit, and caveats

Proposed shape

def execute_on_streams(
    streams: Sequence[Stream],
    fn: Callable[..., T],
    *iterables: Iterable[Any],
    mem_pools: Sequence[MemPool | None] | None = None,
) -> list[T]:

Per stream i, inside the existing fork loop:

pool = mem_pools[i] if mem_pools is not None else None
with use_mem_pool(pool, device=stream.device) if pool is not None else nullcontext():
    results.append(fn(*args))

Example usage with green contexts:

ctxs = GreenContext.split(num_sms=(24, 24), locality_domain_ids=[0, 1], device_id=0)
pools = [MemPool(allocator=LocalizedAllocator(locality_domain_id=c.locality_domain_id, device="cuda:0").allocator()) for c in ctxs]
ys = torch.cuda.execute_on_streams([c.Stream() for c in ctxs], shard_fn, xs, mem_pools=pools)

Why an explicit argument instead of auto-detecting

  • A torch.cuda.Stream returned by GreenContext.Stream() has no back-reference to its context or locality domain. locality_domain_id can also be None. Ordinary streams and mixed lists need "no pool" too.
  • Pools are expensive and stateful: physical memory is reserved, and LocalizedAllocator has its own threading restrictions (docs/source/cuda.md:656). The caller should create them once and reuse them across calls. Building them inside the helper would be wrong.
  • If we later want sugar, it belongs on GreenContext (for example a cached ctx.mem_pool()), not in the fork/join primitive.

Does the fork/join safety argument still hold?

Yes. The caching allocator still only reuses a block on the stream it was allocated on, inside the pool as well. So the ordering from my last comment still applies: start precedes later side-stream reuse, and done precedes caller-side reuse. The pool changes where the memory physically lives, not which stream owns the block.

Caveats worth documenting or testing

  • Backward isn't localized. use_mem_pool only routes allocations from the current thread (torch/cuda/memory.py:1700). Autograd backward runs on engine threads on the forward streams, so gradients and backward temporaries come from the default pool. Saved activations from forward are localized. Localizing backward would need a separate mechanism, for example pool-aware autograd stream hooks. That is out of scope here.
  • Inputs aren't localized. Inputs that the caller allocates on C stay wherever they were allocated. For full locality the caller has to place them in the matching pool first.
  • Graph capture. use_mem_pool inside capture makes the graph retain the pool (memory.py:1714). It also overlaps with the graph's own private-pool routing for the capture stream, so add a hardware test that captures and replays with mem_pools set.
  • Per-device. Each pool must belong to its stream's device. Validate pool.device == stream.device, or at least document it, because LocalizedAllocator rejects cross-device use.
  • Lifetime. Results returned from the call still reference pool memory, so the docs should say the pools must outlive those tensors, as they already say for green contexts.

AI-generated (Claude). This is a design analysis; I have not run it on hardware. The allocator's same-stream reuse rule inside a MemPool and the interaction between use_mem_pool and capture should be confirmed by the author.

@MatthiasKohl

Copy link
Copy Markdown
Collaborator Author

@ngimel some time ago, you rejected my proposed design of tying the fork/join execution to mem pools.
If a map-style callback is wanted, we can make it accept *args as in claude's suggestion here, but why can the callback not use the corresponding mem pool itself for the returned tensor? Is there an issue with object lifetimes that I'm missing here?

@ngimel

ngimel commented Oct 2, 2026

Copy link
Copy Markdown
Collaborator

You want the callback itself to activate mempool? Yes, that should work, we don't have to overcomplicate fork/join wrapper

@MatthiasKohl

Copy link
Copy Markdown
Collaborator Author

You want the callback itself to activate mempool?

yes, it lets the user choose whether they want to use localized outputs or not and keeps the API / implementation here a little cleaner. I'll update the API to the map-style as suggested here, and I'll add this to the docs as well

@ngimel ngimel left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small doc cleanup, otherwise lgtm

Comment thread torch/cuda/streams.py
Python callbacks run sequentially; their CUDA work may execute concurrently.
Each stream waits for work previously submitted to the caller's current
stream. Subsequent work on the caller stream waits for every callback's
queued work, including work queued before a callback raises. These waits

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"asynchronous and do not synchronize the host." - you are repeating yourself

aleozlx added a commit to soodoshll/flashinfer that referenced this pull request Oct 5, 2026
The localized path imported torch.cuda.green_contexts.execute_in_green_contexts
and raised otherwise. No released PyTorch provides it (including the CI
image's 2.14.0), and the open upstream proposal (pytorch/pytorch#199128) now
names the helper torch.cuda.execute_on_streams. The path therefore failed on
every stock PyTorch build.

Resolve torch.cuda.execute_on_streams first, then the earlier name, and
otherwise use an in-repo helper with the proposal's semantics: each stream
waits on an event recorded on the caller stream, and the caller stream waits
on a per-callback completion event that is recorded even when the callback
raises. Callers keep supplying their green-context streams (for example
GreenContext.Stream()).

The Rubin GPU test now runs without an executor shim on ordinary and real
green-context streams. Mocked tests patch _resolve_stream_executor instead of
sys.modules, and the missing-API test now checks the resolution order.

AI-assisted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
> AI-assisted: map-style stream execution, localized-output docs, trim redundant tests.

[ghstack-poisoned]
@MatthiasKohl

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Oct 7, 2026
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge failed

Reason: This PR needs a release notes: label
If your changes are user facing and intended to be a part of release notes, please use a label starting with release notes:.

If not, please add the topic: not user facing label.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "topic: not user facing"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

Details for Dev Infra team Raised by workflow job

@MatthiasKohl MatthiasKohl added the release notes: cuda release notes category label Oct 7, 2026
@MatthiasKohl

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

pytorchmergebot pushed a commit that referenced this pull request Oct 8, 2026
Fix potential races in green context stream pool slot selection/creation/indexing.

> Authored with an AI assistant.
>
> The lock covers creation through publication; failed creation leaves the index unchanged.

Test Plan

Tested on Rubin with driver R610 + CUDA 13.4 compat.
All 3 focused stream-pool tests passed.

```sh
python test/test_cuda.py TestGreenContextStreamPool -v
```
Pull Request resolved: #199129
Approved by: https://github.com/ngimel
ghstack dependencies: #199127, #199128
pytorchmergebot pushed a commit that referenced this pull request Oct 8, 2026
….t. MPS (#199130)

Improve documentation of the NVML based check for locality support: later attachment to MPS isn't supported.

> Authored with an AI assistant.
>
> The limitation concerns the pre-initialization NVML estimate. Already attached clients use the CUDA driver path; query again after attachment rather than reusing an earlier estimate. These regression tests do not test dynamic MPS attachment.

Test Plan

Tested on Rubin with driver R610 + CUDA 13.4 compat.
All 10 existing locality-query regression tests passed.

```sh
python test/test_cuda.py TestCudaGreenContextsCUDA -k locality -v
```
Pull Request resolved: #199130
Approved by: https://github.com/ngimel
ghstack dependencies: #199127, #199128, #199129
cyyever pushed a commit to BakeLab/pytorch that referenced this pull request Oct 11, 2026
> Authored with an AI assistant.
>
> Add `torch.cuda.execute_on_streams` for fork/join execution with ordinary
> streams, green-context streams, or mixtures. Queued work is joined and
> caller state restored even when a callback raises.

Same-device execution switches directly between streams and restores the caller once to reduce host-side overheads. Cross-device execution uses stream context managers to restore device and stream state.

Test Plan

Tested on Rubin with driver R610 + CUDA 13.4 compat (56 tests passed)
Pull Request resolved: pytorch#199128
Approved by: https://github.com/ngimel
ghstack dependencies: pytorch#199127
cyyever pushed a commit to BakeLab/pytorch that referenced this pull request Oct 11, 2026
…9129)

Fix potential races in green context stream pool slot selection/creation/indexing.

> Authored with an AI assistant.
>
> The lock covers creation through publication; failed creation leaves the index unchanged.

Test Plan

Tested on Rubin with driver R610 + CUDA 13.4 compat.
All 3 focused stream-pool tests passed.

```sh
python test/test_cuda.py TestGreenContextStreamPool -v
```
Pull Request resolved: pytorch#199129
Approved by: https://github.com/ngimel
ghstack dependencies: pytorch#199127, pytorch#199128
cyyever pushed a commit to BakeLab/pytorch that referenced this pull request Oct 11, 2026
….t. MPS (pytorch#199130)

Improve documentation of the NVML based check for locality support: later attachment to MPS isn't supported.

> Authored with an AI assistant.
>
> The limitation concerns the pre-initialization NVML estimate. Already attached clients use the CUDA driver path; query again after attachment rather than reusing an earlier estimate. These regression tests do not test dynamic MPS attachment.

Test Plan

Tested on Rubin with driver R610 + CUDA 13.4 compat.
All 10 existing locality-query regression tests passed.

```sh
python test/test_cuda.py TestCudaGreenContextsCUDA -k locality -v
```
Pull Request resolved: pytorch#199130
Approved by: https://github.com/ngimel
ghstack dependencies: pytorch#199127, pytorch#199128, pytorch#199129
Aneureka added a commit to flashinfer-ai/flashinfer that referenced this pull request Oct 20, 2026
…#6488)

<!-- .github/pull_request_template.md -->

## 📌 Description

After [#5276 — feat(moe): add Rubin locality-domain
execution](#5276) was
merged, [PyTorch updated its stream-execution API in
pytorch/pytorch#199128](pytorch/pytorch#199128)
to require explicit callback input sequences. This PR updates FlashInfer
to that upstream API change and restores compatibility with the newer
PyTorch nightly builds.

The updated API is `execute_on_streams(streams, fn, *inputs)`: callback
arguments come from the supplied input sequences, rather than an
implicitly supplied stream index. FlashInfer's existing two-argument
calls reflected the earlier interface and are incompatible with this
newer contract. Both FC1 and FC2 now explicitly pass the locality-domain
shard indices:

```python
torch.cuda.execute_on_streams(
    localized_streams, callback, range(len(localized_streams))
)
```

Use this single upstream interface directly and remove the local
fork/join implementation, executor resolver, and legacy callback-arity
handling. Keep the existing failure-path stream joins so queued work
remains ordered before the exception propagates.

Localized execution now explicitly requires a PyTorch build providing
`torch.cuda.execute_on_streams`. Non-localized execution does not
require that API. This is an API-compatibility fix, not a new kernel or
a standalone performance optimization.

## 🔍 Related Issues

- Previous implementation: [#5276 — feat(moe): add Rubin locality-domain
execution](#5276).
- Upstream API:
[pytorch/pytorch#199128](pytorch/pytorch#199128);
the landed implementation in [commit
5ba7f2bf](pytorch/pytorch@5ba7f2b)
defines `execute_on_streams(streams, fn, *inputs)` and rejects calls
without input sequences.

## 🚀 Pull Request Checklist

Thank you for contributing to FlashInfer! Before we review your pull
request, please make sure the following items are complete.

### ✅ Pre-commit Checks

- [x] I have installed `pre-commit` by running `pip install pre-commit`
(or used your preferred method).
- [x] I have installed the hooks with `pre-commit install`.
- [x] I have run the hooks manually with `pre-commit run --all-files`
and fixed any reported issues.

> If you are unsure about how to set up `pre-commit`, see [the
pre-commit documentation](https://pre-commit.com/).

## 🧪 Tests

- [x] Tests have been added or updated as needed.
- [ ] All tests are passing (`unittest`, etc.).

## 🔬 Experimental Track

<!-- Only for PRs submitted under the experimental policy
(CONTRIBUTING.md → "Experimental APIs and Backends").
     Leave this section untouched for normal PRs. -->

- [ ] This PR is **experimental**: it adds or changes code under
`flashinfer/experimental/` and/or an `@flashinfer_experimental_api`.
Tracking issue: #
- [ ] The tracking issue names an owner, the reason for the experimental
path, and a graduation plan with a target release.
- [ ] Core changes are limited to a thin entry point (signature, shared
validation, feature-gate check, backend selection, handoff).
- [ ] Tests live in `tests/experimental/` and were validated on the
intended hardware; a runnable example is included.
- [ ] Nothing is registered in `flashinfer/aot.py`, and no experimental
backend is reachable from `backend="auto"` without
`FLASHINFER_ALLOW_EXPERIMENTAL_AUTO_BACKENDS=1`. (Calling an
`@flashinfer_experimental_api` or naming a backend explicitly is itself
the opt-in and needs no environment variable.)
- [ ] **Test scope declared below.** The experimental CI lane runs
exactly these targets, so keep them as narrow as the change allows.

<!-- Required for experimental PRs. Replace the commented lines below
with your targets.
Do not delete the fence or change its `experimental-tests` tag — the
experimental-track
watcher reads it verbatim to decide which targets to ask CI for. -->

```experimental-tests
# One target per line: a directory or a file. (A pytest ::selector is not
# supported -- the sharding runner cannot consume one.) Must be under
# tests/experimental/ and must exist. Delete these comment lines and add yours, e.g.
#
#   tests/experimental/test_my_backend.py
#   tests/experimental/my_backend/
#
# Declaring the whole tree (tests/experimental/) is allowed but means every
# experimental PR pays for every other feature's tests, in every matrix cell.
```

## Reviewer Notes

<!-- Optional: anything you'd like reviewers to focus on, concerns, etc.
-->


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Compatibility**
* Localized MoE execution requires a PyTorch build with the
stream-execution API and reports an error when unavailable. Standard MoE
execution remains available without it.
* **Bug Fixes**
* Improved handling of partial-width outputs in grouped GEMM
finalization, preventing invalid reductions and ensuring output data is
ready before reuse.
* Localized execution now joins participating streams before propagating
GEMM failures.
* **Testing**
* Expanded coverage for localized execution failures, partial-width
outputs, and CUDA graph capture and replay.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Qidong Su <[email protected]>
Co-authored-by: Haobin Guo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/trunk Trigger trunk jobs on your pull request Merged open source release notes: cuda release notes category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants