Skip to content

feat: Add float32 zero-copy angle encoding in qdp-core (single sample)#1249

Open
viiccwen wants to merge 5 commits intoapache:mainfrom
viiccwen:add-angle-f32-core-single
Open

feat: Add float32 zero-copy angle encoding in qdp-core (single sample)#1249
viiccwen wants to merge 5 commits intoapache:mainfrom
viiccwen:add-angle-f32-core-single

Conversation

@viiccwen
Copy link
Copy Markdown
Contributor

@viiccwen viiccwen commented Apr 8, 2026

Related Issues

Closes #1248

Changes

  • Bug fix
  • New feature
  • Refactoring
  • Documentation
  • Test
  • CI/CD pipeline
  • Other

Why

It adds single-sample float32 zero-copy angle encoding support in the Rust core and CUDA kernel layer, following the existing amplitude f32 rollout pattern.

How

  • added a float32 CUDA kernel entrypoint for single-sample angle encoding
  • added AngleEncoder::encode_from_gpu_ptr_f32_with_stream(...)
  • added public QdpEngine APIs:
    • encode_angle_from_gpu_ptr_f32(...)
    • encode_angle_from_gpu_ptr_f32_with_stream(...)
  • validated the new GPU-pointer path for:
    • empty input
    • null pointer
    • qubit/input-length mismatch
  • added kernel-level numerical tests for the new float32 angle path
  • kept engine precision conversion behavior consistent with the existing core API

Files Changed

  • qdp/qdp-core/src/gpu/encodings/angle.rs
  • qdp/qdp-core/src/lib.rs
  • qdp/qdp-core/tests/gpu_ptr_encoding.rs
  • qdp/qdp-kernels/src/angle.cu
  • qdp/qdp-kernels/src/lib.rs
  • qdp/qdp-kernels/tests/angle_encode.rs

Checklist

  • Added or updated unit tests for all changes
  • Added or updated documentation for all changes

@viiccwen
Copy link
Copy Markdown
Contributor Author

viiccwen commented Apr 8, 2026

cc @400Ping, @ryankert01

@viiccwen viiccwen changed the title feat: Add float32 zero-copy angle encoding in qdp-core feat: Add float32 zero-copy angle encoding in qdp-core (single sample) Apr 8, 2026
Copy link
Copy Markdown
Member

@ryankert01 ryankert01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall lg, I think maybe can add a python test also?

@ryankert01 ryankert01 force-pushed the add-angle-f32-core-single branch from 66b8bfb to b479dc8 Compare April 8, 2026 15:29
Co-authored-by: Ryan Huang <ryankert01@gmail.com>
@viiccwen
Copy link
Copy Markdown
Contributor Author

viiccwen commented Apr 9, 2026

Overall lg, I think maybe can add a python test also?

Currently, this PR doesn't include python binding, so it's still unsupported in python behavior.
I'll change python binding in the follow-up PR (#1250).

Copy link
Copy Markdown
Member

@guan404ming guan404ming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is missing validate_qubit_count(num_qubits)? call that all other encode paths use. Guards against overflow in 1 << num_qubits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add float32 zero-copy angle encoding in qdp-core (single sample)

3 participants