Skip to content

feat(cco): expose ccoSdma's full put/get API to FlyDSL and Triton - #792

Merged
jhchouuu merged 2 commits into
mainfrom
jiahzhou/cco-sdma-put-ptr-followup
Oct 20, 2026
Merged

jhchouuu merged 2 commits into
mainfrom
jiahzhou/cco-sdma-put-ptr-followup

Conversation

@jhchouuu

@jhchouuu jhchouuu commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to #786, and the rest of the SDMA device API with it.

#786 added cco_sdma_put_ptr_rsig__thread / cco_sdma_signal_slot to the device bitcode only. More broadly, the window put/get wrappers bake one template combination into each symbol (local signal or none, Aggregate only), so from FlyDSL and Triton a put could not signal the peer, could not signal both sides, and there was no waitSignal to consume a signal at all (gemm_ar's kernels_sdma.py works around exactly this with an LSA atomic).

Approach

Mirror ccoSdma one-to-one instead of adding one symbol per combination.

  • Wrapper: cco_sdma_{put,get}_ptr__<coop>(dc, peer, dst, src, n, qid, flags) call ccoSdma::putPtr / getPtr; every template axis besides Coop rides in flags (SdmaFlags: AGGREGATE, SIGNAL_PER_COPY, LOCAL_SIGNAL, REMOTE_SIGNAL, SAME_QUEUE). The wrapper is inlined into the caller, so a constant flags folds to the one instantiation: Triton put_ptr compiles to 355 instructions with a constant flags vs 7968 with a runtime one; FlyDSL's new put ISA matches the old window wrapper's (528 vs 527 lines). Unknown bits and SAME_QUEUE off thread scope trap. Plus cco_sdma_wait_signal and cco_local_ptr (ccoGetLocalPtr).
  • cco.hpp: ccoSdma::putPtr / getPtr (put/get delegate, no behaviour change) and signalSlot (bounds-checked).
  • Python (FlyDSL and Triton alike): Sdma.put / get / put_ptr / get_ptr / wait_signal / signal_slot, with C++'s template arguments as compile-time keywords: coop, local_signal, remote_signal, aggregate, signal_per_copy, same_queue. put / get resolve the addresses and call put_ptr / get_ptr, exactly as C++ put() calls putPtr().
  • Registry: everything is in CCO_DEVICE_FUNCTIONS; FlyDSL now binds every entry (_bindings.ALL), so a registered function can no longer lack a binding.

Compatibility

  • All existing symbols are unchanged (including cco_sdma_put_ptr_rsig__thread, which aiter links by name).
  • signal= still works on put / get, and a call naming no signal keeps the old default (a local signal). gemm_ar, benchmark and examples need no change.
  • Cost: the device bitcode grows 173 KB → 567 KB (128 instantiations); its one-time JIT build 1.7 s → 6.4 s; linking it adds ~30 ms per kernel compile.

Tests

  • test_triton_bindings.py: argument and return types of every symbol checked against the bitcode (was return types only); the reverse check (no unregistered cco_ symbol) compares against all registered symbols; FlyDSL's binding set equals the registry; SAME_QUEUE with warp scope is rejected; constant flags must fold.
  • examples/cco/ir/test_triton_cco.py --transport sdma (run by test_triton_sdma.py): a signal matrix over put_ptr / get_ptr / window put × local × remote × per-copy, checking each counter's delta and the payload, and wait_signal on the remote one. Swapping the local and remote bits makes it fail.
  • test_sdma_api.py::test_sdma_signals: FlyDSL put (both signals), put_ptr (remote), get_ptr (local) consumed by wait_signal.

On MI308X (ROCm 7.14, BUILD_CCO_SDMA=ON): bindings + Triton SDMA 12/12; all 133 Triton axis combinations compile; test_sdma_api.py 13/13 with sdma_queue_count lowered to 3 (as committed it asks for 8 queues per pair, which MI308X cannot create: NO_MEMORY at anvil.cpp:210, pre-existing); example 07 passes. test_flydsl_ar.py: 23 pass, the same 3 fail before and after this change (4/8-rank SDMA queues on MI308X, aiter comparison). gemm_ar's end-to-end tests cannot run here (the GEMM kernel hits an LLVM error with this FlyDSL), unrelated.

🤖 Generated with Claude Code

jhchouuu and others added 2 commits October 16, 2026 23:09
Follow-up to #786, which added cco_sdma_put_ptr_rsig__thread and
cco_sdma_signal_slot to the device bitcode only.

- cco.hpp: add ccoSdma::putPtr (put() on resolved addresses; put() now
  calls it) and ccoSdma::signalSlot (nullptr when out of range).
- Wrapper: call those instead of the internal ccoSdmaDispatchChunked;
  cco_sdma_signal_slot returns 0 for an out-of-range rank or queue.
- Register both in ops.py and flydsl/_bindings.py; expose them as
  Sdma.put_ptr / Sdma.signal_slot in the FlyDSL and Triton handles.
- test_triton_cco.py (sdma): put_ptr to the next rank, poll signal_slot,
  check the payload, exactly one signal, and the out-of-range cases.
- test_triton_bindings.py: the cov5 bitcode may not define a cco_ symbol
  that is not registered.
- README: correct the "Adding a new device op" steps.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The window put/get wrappers baked one template combination into each symbol
(local signal or none, Aggregate only), so remote signals, both signals at
once, SignalPerCopy, SameQueue and waitSignal were unreachable from the DSLs.

- cco.hpp: add ccoSdma::getPtr (get() now calls it, no behaviour change).
- Wrapper: cco_sdma_{put,get}_ptr__<coop>(..., flags) carry every other
  template axis in `flags` (SdmaFlags: Aggregate, SignalPerCopy, local and
  remote signal, SameQueue). The wrapper is inlined, so a constant `flags`
  folds to one instantiation (Triton put_ptr: 355 instructions vs 7968 with
  a runtime `flags`). Also cco_sdma_wait_signal and cco_local_ptr. Existing
  symbols are unchanged.
- Python: Sdma.put / get / put_ptr / get_ptr / wait_signal / signal_slot in
  FlyDSL and Triton, with C++'s template arguments as keywords (coop,
  local_signal, remote_signal, aggregate, signal_per_copy, same_queue).
  put / get route through put_ptr / get_ptr; their `signal=` keeps working
  and a call naming no signal keeps the old local-signal default.
- FlyDSL binds every registered function (_bindings.ALL).
- Tests: Triton compile check of the SameQueue/warp rejection, argument types
  checked against the bitcode, reverse check against all registered symbols,
  a constant-folding check, a GPU signal matrix (put_ptr / get_ptr / put x
  local x remote x per-copy: counts and payloads), a FlyDSL signals test.
- Review fixes: putPtr/getPtr static_assert messages and comments,
  signalSlot acquire note, the put_ptr test's one-signal-per-wave comment,
  README "Adding a new device op".

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@jhchouuu jhchouuu changed the title cco: register the raw-pointer SDMA put and signal slot wrappers cco: expose ccoSdma's full put/get API to FlyDSL and Triton Oct 19, 2026
@jhchouuu
jhchouuu requested a review from kawhil-amd October 19, 2026 14:53

@kawhil-amd kawhil-amd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@jhchouuu jhchouuu changed the title cco: expose ccoSdma's full put/get API to FlyDSL and Triton feat(cco): expose ccoSdma's full put/get API to FlyDSL and Triton Oct 20, 2026
@jhchouuu
jhchouuu merged commit d5ee67b into main Oct 20, 2026
@jhchouuu
jhchouuu deleted the jiahzhou/cco-sdma-put-ptr-followup branch October 20, 2026 08:58
"""Wait on a single (peer, queueId) queue only."""
raw.cco_sdma_quiet_queue(self.dev_comm, peer, qid)

def wait_signal(self, src_lsa_rank, qid, expected):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

seems lack the put_remote_signal impl?

yangyuhuiling pushed a commit that referenced this pull request Oct 28, 2026
Conflict in tests/python/cco/test_triton_bindings.py: main (#792) now
checks the FlyDSL ABI over _bindings.ALL and counts 80 functions; the 12
put2d/get2d entries from this branch make it 92.

Co-Authored-By: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants