[QDP] Add zero-copy amplitude encoding from float32 GPU tensors#999
Merged
guan404ming merged 6 commits intoapache:mainfrom Feb 4, 2026
Merged
Conversation
b6dec66 to
eaad56a
Compare
Member
|
Design looks nice to me. Could you help attach before and after benchmark on your local machine to prove your improvement works? Thanks! |
Contributor
Author
|
@guan404ming got it! |
9bad00b to
eaad56a
Compare
Member
|
Looks nice, please help resolve the conflicts. Thanks! |
eaad56a to
746635e
Compare
Contributor
Author
|
cc @guan404ming @rich7420 |
Member
|
Looks nice for the change. |
…ith stream support
…onversion for both Float32 and Float64
… encoding methods
…sor encoding methods
746635e to
07fcb2f
Compare
Contributor
|
@viiccwen thanks for the update! |
guan404ming
approved these changes
Feb 4, 2026
Contributor
Author
|
Thx all! |
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.
Purpose of PR
This PR adds
encode_from_gpu_ptr_f32andencode_from_gpu_ptr_f32_with_streamtoQdpEngine, enabling zero-copy amplitude encoding from float32 GPU pointers. It relies on the existingGpuStateVectorFloat32 support and thelaunch_amplitude_encode_f32/launch_l2_norm_f32kernels.Summary
QdpEngine::encode_from_gpu_ptr_f32(input_d, input_len, num_qubits)— amplitude encoding from GPU f32 pointer using the default stream.QdpEngine::encode_from_gpu_ptr_f32_with_stream(..., stream)— same with an explicit CUDA stream (null = default).encode_from_gpu_ptrandencode_batch_from_gpu_ptrpaths now validate the input pointer viacudaPointerGetAttributes(non-null, device/managed memory, same device as engine). Early checks for empty input / sample size are added where missing.calculate_inv_norm_gpu_f32is refactored to call a newcalculate_inv_norm_gpu_f32_with_stream; the stream-aware variant is used for f32 GPU encoding and is synchronized before host copy.get_torch_cuda_stream_ptrreturnsnullwhen PyTorch reports stream pointer 0 (default stream) instead of raising, so default-stream usage is supported.encode_from_gpu_ptr_f32andencode_from_gpu_ptr_f32_with_stream(default and non-default stream, f32/f64 engine, empty input, input length > state size). Existing GPU pointer tests updated to use valid GPU pointers so they still hit the intended error paths after the new validation. Basis tests useFloat64engine. Test helpercreate_test_data_f32added intests/common.import torchremoved;test_encode_cuda_tensor_unsupported_encodingparametrized withiqp/iqp-zand error message match updated to the current supported list.Related Issues or PRs
closes #996 , also a follow-up PR for #995
Changes Made
Breaking Changes
Checklist