You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mahout.apache.org by "400Ping (via GitHub)" <gi...@apache.org> on 2026/01/23 14:57:55 UTC
[PR] [QDP] PyTorch GPU Pointer Validation [mahout]
400Ping opened a new pull request, #929:
URL: https://github.com/apache/mahout/pull/929
### Purpose of PR
Added CUDA pointer validation for GPU-pointer encode paths and hooked DLPack stream synchronization so PyTorch consumers can pass a stream and get a safe wait.
Details:
- `cuda_ffi.rs`: added `cudaPointerGetAttributes` FFI and pointer attribute constants/struct for validation.
- `lib.rs`: added `validate_cuda_input_ptr` and wired it into `encode_from_gpu_ptr`/`encode_batch_from_gpu_ptr`.
- `dlpack.rs`: added `synchronize_stream` using a CUDA event recorded on the default stream.
- `lib.rs`: `QuantumTensor.__dlpack__` now honors `stream` and calls the new sync helper when `stream > 0`.
### Related Issues or PRs
<!-- Add links to related issues or PRs. -->
<!-- - Closes #123 -->
<!-- - Related to #123 -->
Related to #726
### Changes Made
<!-- Please mark one with an "x" -->
- [ ] Bug fix
- [x] New feature
- [ ] Refactoring
- [ ] Documentation
- [ ] Test
- [ ] CI/CD pipeline
- [ ] Other
### Breaking Changes
<!-- Does this PR introduce a breaking change? -->
- [ ] Yes
- [x] No
### Checklist
<!-- Please mark each item with an "x" when complete -->
<!-- If not all items are complete, please open this as a **Draft PR**.
Once all requirements are met, mark as ready for review. -->
- [ ] Added or updated unit tests for all changes
- [ ] Added or updated documentation for all changes
- [ ] Successfully built and ran all unit tests or manual tests locally
- [ ] PR title follows "MAHOUT-XXX: Brief Description" format (if related to an issue)
- [ ] Code follows ASF guidelines
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mahout.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [QDP] PyTorch GPU Pointer Validation [mahout]
Posted by "rich7420 (via GitHub)" <gi...@apache.org>.
rich7420 commented on PR #929:
URL: https://github.com/apache/mahout/pull/929#issuecomment-3803116207
Yeah same here, I think we need to add unit tests for new feature.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mahout.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [QDP] PyTorch GPU Pointer Validation [mahout]
Posted by "rich7420 (via GitHub)" <gi...@apache.org>.
rich7420 commented on code in PR #929:
URL: https://github.com/apache/mahout/pull/929#discussion_r2724290189
##########
qdp/qdp-python/src/lib.rs:
##########
@@ -65,6 +64,14 @@ impl QuantumTensor {
return Err(PyRuntimeError::new_err("Invalid DLPack tensor pointer"));
}
+ if let Some(stream) = stream {
+ if stream > 0 {
+ qdp_core::dlpack::synchronize_stream(stream as *mut std::ffi::c_void).map_err(
+ |e| PyRuntimeError::new_err(format!("CUDA stream sync failed: {}", e)),
+ )?;
+ }
+ }
+
Review Comment:
DLPack stream handling treats special CUDA stream values 1 (legacy default) and 2 (per-thread default) as raw pointers, which can lead to invalid cudaStream_t usage and undefined behavior. The array API spec explicitly defines these values as non-pointer sentinel values for CUDA streams. The current logic calls synchronize_stream for any stream > 0, passing 1/2 directly. I think this should be mapped to cudaStreamLegacy/cudaStreamPerThread (or avoided) per spec.
ref: https://data-apis.org/array-api/latest/API_specification/generated/array_api.array.__dlpack__.html
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mahout.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [QDP] PyTorch GPU Pointer Validation [mahout]
Posted by "400Ping (via GitHub)" <gi...@apache.org>.
400Ping commented on PR #929:
URL: https://github.com/apache/mahout/pull/929#issuecomment-3796433529
@CheyuWu PTAL
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mahout.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [QDP] PyTorch GPU Pointer Validation [mahout]
Posted by "rich7420 (via GitHub)" <gi...@apache.org>.
rich7420 commented on PR #929:
URL: https://github.com/apache/mahout/pull/929#issuecomment-3821607665
@ryankert01 do you want to take another look?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mahout.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [QDP] PyTorch GPU Pointer Validation [mahout]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming merged PR #929:
URL: https://github.com/apache/mahout/pull/929
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@mahout.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org