Skip to content

fix(qdp): apply shared max qubit validation#1442

Merged
viiccwen merged 1 commit into
apache:mainfrom
viiccwen:max-qubits-validation-cleanup
Jul 16, 2026
Merged

fix(qdp): apply shared max qubit validation#1442
viiccwen merged 1 commit into
apache:mainfrom
viiccwen:max-qubits-validation-cleanup

Conversation

@viiccwen

Copy link
Copy Markdown
Contributor

Related Issues

Closes #1262

Changes

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

Why

Several amplitude f32 batch and GPU-pointer paths calculated 1 << num_qubits without first using QDP's shared validate_qubit_count function. Excessive inputs could therefore panic on shift overflow or proceed toward an impractical allocation instead of returning the established MahoutError::InvalidInput. QDP also retained an unused duplicate MAX_QUBITS macro in the CUDA kernel configuration.

How

  • Apply validate_qubit_count before state-length calculations in the uncovered float32 batch and float32/float64 GPU-pointer single and batch paths.
  • Keep the Rust MAX_QUBITS constant as the single effective validation policy.
  • Remove the unused CUDA MAX_QUBITS definition and update the stale Rust comment.
  • Extend the existing maximum-qubit and GPU-pointer test modules with regression coverage for all affected entry points.

Runtime device-capacity planning remains outside this cleanup's scope.

Checklist

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

Signed-off-by: viiccwen <vicwen@apache.org>
@viiccwen
viiccwen requested a review from 400Ping as a code owner July 15, 2026 10:36
@viiccwen
viiccwen requested a review from ryankert01 July 15, 2026 10:36
@viiccwen
viiccwen merged commit b9e33e6 into apache:main Jul 16, 2026
3 checks passed
@viiccwen
viiccwen deleted the max-qubits-validation-cleanup branch July 16, 2026 08:20
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] Centralize MAX_QUBITS validation across QDP encoding paths

2 participants