Enable CUDA tensor validation for iqp and iqp-z encodings#1093
Enable CUDA tensor validation for iqp and iqp-z encodings#1093SuyashParmar wants to merge 1 commit intoapache:mainfrom
Conversation
| "iqp" | "iqp-z" => { | ||
| if !dtype_str_lower.contains("float64") { | ||
| return Err(PyRuntimeError::new_err(format!( | ||
| "CUDA tensor must have dtype float64 for {} encoding, got {}. \ | ||
| Use tensor.to(torch.float64)", | ||
| method, dtype_str | ||
| ))); | ||
| } | ||
| } |
There was a problem hiding this comment.
It's duplicated with angle method block, could be merged together.
There was a problem hiding this comment.
yeah , agreed it can be merged with the angle path. Since this PR is already green and scoped to the behavior fix, I’m okay to keep this minimal and do that small refactor in a follow-up (unless you prefer I include it here). Also sounds good on edge-case coverage follow-up, thank you.
There was a problem hiding this comment.
IMO, it should be refactor in this PR.
There was a problem hiding this comment.
It's happy path, I'll take a follow-up PR to cover edge case.
|
not sure if he's on a gpu machine yet (: |
|
locally passed tests. |
|
@ryankert01 @viiccwen @rich7420 Thanks everyone for the review and validation. CI is green, local validation was confirmed, and the CUDA iqp/iqp-z validation inconsistency is resolved. |
| _ => { | ||
| return Err(PyRuntimeError::new_err(format!( | ||
| "CUDA tensor encoding currently only supports 'amplitude', 'angle', or 'basis' methods, got '{}'. \ | ||
| "CUDA tensor encoding currently only supports 'amplitude', 'angle', 'basis', 'iqp', or 'iqp-z' methods, got '{}'. \ |
There was a problem hiding this comment.
+1 with rich. should be dynamic.
QdpEngine.encode() supports iqp and iqp-z in qdp-core, but the CUDA tensor validation path in pytorch.rs currently rejects these methods and only allows amplitude, angle, and basis.
This creates inconsistent behavior:
CPU/list/NumPy paths can use iqp/iqp-z
CUDA tensor path fails early with an unsupported-method error
Expected behavior
CUDA tensor inputs should allow iqp and iqp-z when dtype/shape/device constraints are satisfied (same style as other supported encodings).