[module_fused_split_gdr_update] refactor#3777
Open
amd-ruitang3 wants to merge 1 commit into
Open
Conversation
Contributor
🏷️ CI GuideRuns automatically on every PR:
Extended tests (opt-in via labels):
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the module_fused_split_gdr_update op to remove Torch/C10 dependencies from the C++/CUDA(HIP) compilation units by switching the kernel interface to aiter_tensor_t and using AITER’s thread-local HIP stream plumbing.
Changes:
- Replaced
torch::Tensor/TORCH_CHECKinterfaces withaiter_tensor_t/AITER_CHECKand addedHipDeviceGuard+aiter::getCurrentHIPStream()usage in the kernel wrapper. - Updated the pybind module to expose
_set_current_hip_stream(develop-mode stream handoff) and updated Python to pre-allocate outputs / default tensors before calling into the torch-free binding. - Adjusted the pybind arg list for
fused_split_gdr_updateto accept an explicitoutputtensor (no allocation on the C++ side).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| csrc/pybind/fused_split_gdr_update_pybind.cu | Adds AITER stream setter export to support develop-mode stream handoff. |
| csrc/kernels/fused_split_gdr_update.cu | Converts op wrapper to aiter_tensor_t and uses AITER stream + device guard; removes torch includes. |
| csrc/include/rocm_ops.hpp | Updates pybind binding signature/args for the refactored op. |
| csrc/include/fused_split_gdr_update.h | Updates public header signature to aiter_tensor_t and void return. |
| aiter/ops/fused_split_gdr_update.py | Adds Python-side allocation/defaulting and forwards to the new torch-free binding. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+72
to
+75
| B = mixed_qkv.shape[0] | ||
| T = mixed_qkv.shape[2] | ||
| HV = num_heads_v | ||
| V = head_dim |
Comment on lines
+82
to
+90
| if initial_state_indices is None or initial_state_indices.numel() == 0: | ||
| initial_state_indices = torch.zeros( | ||
| (B,), dtype=torch.int32, device=mixed_qkv.device | ||
| ) | ||
|
|
||
| if initial_state_source is None: | ||
| initial_state_source = torch.empty( | ||
| 0, dtype=torch.float32, device=mixed_qkv.device | ||
| ) |
Comment on lines
+2236
to
+2240
| py::arg("softplus_beta"), \ | ||
| py::arg("softplus_threshold"), \ | ||
| py::arg("scale"), \ | ||
| py::arg("use_qk_l2norm_in_kernel"), \ | ||
| py::arg("output")); |
| 0, \ | ||
| stream, \ | ||
| reinterpret_cast<const __hip_bfloat16*>(mixed_qkv.data_ptr()), \ | ||
| reinterpret_cast<float*>(A_log.data_ptr()), \ |
| reinterpret_cast<const __hip_bfloat16*>(b_gate.data_ptr()), \ | ||
| reinterpret_cast<__hip_bfloat16*>(o.data_ptr()), \ | ||
| use_initial_state ? reinterpret_cast<float*>(initial_state_source.data_ptr()) : nullptr, \ | ||
| reinterpret_cast<int32_t*>(initial_state_indices_ptr.data_ptr()), \ |
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.
Motivation
remove torch depency. Build time drop to 10.6s from 35.9s (-70.5%)
Technical Details
Test Plan
Test Result
Submission Checklist