Repository navigation
Conversation
Co-authored-by: ColorsWind <[email protected]>
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
There was a problem hiding this comment.
Pull request overview
This PR introduces an opt-in performance mode for the custom collective stack by making the final cross-rank end_sync optional and (when enabled) attempting to preserve correctness by keeping inputs alive across launches from Python.
Changes:
- Thread an
end_syncboolean from Python → pybind → C++ dispatch → HIP kernels for all-gather, reduce-scatter, and fused AR+RMSNorm variants. - Add a
hold_inputsmode toCustomAllreduce(controlled viaAITER_CUSTOM_AR_HOLD_INPUTS) to disableend_syncand retain inputs on the Python side. - Wire the new behavior into
CudaCommunicatorconstruction via an environment variable.
Reviewed changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| csrc/kernels/custom_all_reduce.cu | Add end_sync parameter plumbing into C++ entrypoints and dispatchers. |
| csrc/include/rocm_ops.hpp | Expose end_sync as a new pybind argument (defaulting to true) for affected ops. |
| csrc/include/custom_all_reduce.h | Update C++ declarations with end_sync default parameters. |
| csrc/include/custom_all_reduce.cuh | Make kernel-side end_sync conditional for affected kernels/launchers. |
| aiter/ops/custom_all_reduce.py | Update Python op signatures/stubs to include end_sync. |
| aiter/dist/device_communicators/custom_all_reduce.py | Add hold_inputs + input recording, and pass end_sync based on hold_inputs (but currently with correctness gaps). |
| aiter/dist/device_communicators/communicator_cuda.py | Add env-controlled wiring for hold_inputs into CustomAllreduce. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
No activity for 15 days, so this is now labelled |
|
Closing this version because retaining input tensors does not protect against in-place writes or reuse of the registered staging buffer before the next start synchronization. A revised approach should establish a safe buffer-reuse protocol and validate these cases before removing end_sync. |
Motivation
Follow-up to #4082.
PR #4082 fixed a custom collective race by adding an end-of-kernel cross-rank
end_sync, ensuring peer ranks finish reading input buffers before the caller can reuse or overwrite them. That fix is correct, but the extra device-side synchronization adds measurable latency to small custom collective paths.This PR keeps the race fix while providing a performance path that avoids the final
end_sync. Instead of synchronizing at the end of each collective, Python keeps the input tensor alive until the next custom collective launch. The next collective's existing start synchronization proves all ranks have advanced past the previous collective, so the previous input can be safely released at that point.cc @ColorsWind
Technical Details
This change adds an optional
end_syncflag through the custom allreduce Python/C++/HIP stack.When
hold_inputs=False, behavior stays unchanged and kernels still run the finalend_sync.When
hold_inputs=True:end_sync=Falseend_sync<ngpus, true>(...)CustomAllreducerecords the input tensor in PythonThe feature is controlled through:
Covered paths include:
Test Plan
You can find reproduce scripts here https://gist.github.com/jpy794/b21fd3c7b9a9ac1d0e87db62824cf78b
Race repro
Performance microbench
Test Result
Correctness
ptrdenotes input tensor reuse after custom ar.holddenotes value ofAITER_CUSTOM_AR_HOLD_INPUTSPerformance
Submission Checklist