You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mahout.apache.org by "viiccwen (via GitHub)" <gi...@apache.org> on 2026/03/04 11:33:29 UTC

[PR] Support python binding with amplitude f32 batch [mahout]

viiccwen opened a new pull request, #1116:
URL: https://github.com/apache/mahout/pull/1116

   ### Related Issues
   
   closes #1113 
   
   ### Changes
   
   - [ ] Bug fix
   - [x] New feature
   - [ ] Refactoring
   - [ ] Documentation
   - [x] Test
   - [ ] CI/CD pipeline
   - [ ] Other
   
   ### Why
   
   Python CUDA tensors with shape `[batch_size, features]` and dtype `torch.float32` now use the existing core batch float32 GPU-pointer path
   
   ### How
   
   #### Python bindings
   
   - Extended `QdpEngine::_encode_from_cuda_tensor` to support 2D CUDA float32 amplitude inputs
   - Wired the Python CUDA path to `encode_batch_from_gpu_ptr_f32_with_stream`
   - Kept stream interop consistent with the existing single-sample float32 CUDA path
   - Preserved the existing float64 / basis / other method dispatch behavior
   
   #### Tests
   
   - Replaced the old Python test that expected 2D CUDA float32 amplitude to fail
   - Added coverage for successful 2D CUDA float32 amplitude encoding
   - Added coverage for engine precision behavior:
     - default `float32` engine returns `complex64`
     - `float64` engine still returns `complex128`
   
   
   ## Checklist
   
   - [ ] Added or updated unit tests for all changes
   - [ ] Added or updated documentation for all changes
   


-- 
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: commits-unsubscribe@mahout.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: add CUDA float32 batch amplitude encoding support in Python bindings [mahout]

Posted by "viiccwen (via GitHub)" <gi...@apache.org>.
viiccwen commented on PR #1116:
URL: https://github.com/apache/mahout/pull/1116#issuecomment-4004354043

   thx @ryankert01 , @guan404ming for reviewing! 🙌
   
   <img width="150" height="170" alt="image" src="https://github.com/user-attachments/assets/7c732319-690d-456f-8e75-1f23d46b99fa" />
   


-- 
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: commits-unsubscribe@mahout.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: add CUDA float32 batch amplitude encoding support in Python bindings [mahout]

Posted by "viiccwen (via GitHub)" <gi...@apache.org>.
viiccwen commented on code in PR #1116:
URL: https://github.com/apache/mahout/pull/1116#discussion_r2884983734


##########
qdp/qdp-python/tests/test_dlpack_validation.py:
##########


Review Comment:
   got it!



-- 
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: commits-unsubscribe@mahout.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: add CUDA float32 batch amplitude encoding support in Python bindings [mahout]

Posted by "viiccwen (via GitHub)" <gi...@apache.org>.
viiccwen commented on code in PR #1116:
URL: https://github.com/apache/mahout/pull/1116#discussion_r2884982843


##########
qdp/qdp-python/src/engine.rs:
##########
@@ -506,10 +506,35 @@ impl QdpEngine {
                         consumed: false,
                     })
                 }
-                2 => Err(PyRuntimeError::new_err(
-                    "CUDA float32 batch amplitude encoding is not yet supported. \
-                     Use float64 (tensor.to(torch.float64)) or encode samples individually.",
-                )),
+                2 => {
+                    let num_samples: usize = data.call_method1("size", (0,))?.extract()?;

Review Comment:
   thx for pointing out!



-- 
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: commits-unsubscribe@mahout.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: add CUDA float32 batch amplitude encoding support in Python bindings [mahout]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #1116:
URL: https://github.com/apache/mahout/pull/1116#discussion_r2884674857


##########
qdp/qdp-python/tests/test_dlpack_validation.py:
##########


Review Comment:
   We could add some non-trivial input like [3.0, 4.0, 0.0, 0.0]



-- 
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: commits-unsubscribe@mahout.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: add CUDA float32 batch amplitude encoding support in Python bindings [mahout]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on code in PR #1116:
URL: https://github.com/apache/mahout/pull/1116#discussion_r2884648037


##########
qdp/qdp-python/src/engine.rs:
##########
@@ -506,10 +506,35 @@ impl QdpEngine {
                         consumed: false,
                     })
                 }
-                2 => Err(PyRuntimeError::new_err(
-                    "CUDA float32 batch amplitude encoding is not yet supported. \
-                     Use float64 (tensor.to(torch.float64)) or encode samples individually.",
-                )),
+                2 => {
+                    let num_samples: usize = data.call_method1("size", (0,))?.extract()?;

Review Comment:
   Nit: consider using `tensor_info.shape` for consistency with the f64 path, though the current approach is functionally correct since contiguity is already validated.



-- 
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: commits-unsubscribe@mahout.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: add CUDA float32 batch amplitude encoding support in Python bindings [mahout]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming merged PR #1116:
URL: https://github.com/apache/mahout/pull/1116


-- 
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: commits-unsubscribe@mahout.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org