This is an automated email from the ASF dual-hosted git repository.

ryankert01 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/mahout.git


The following commit(s) were added to refs/heads/main by this push:
     new 35a8526d9 [Bug][QDP] Align Iris GPU training path with sibling 
pipelines (real dtype + leaf weights) (#1412)
35a8526d9 is described below

commit 35a8526d9cb08669ee3989b801be74bea0216cf4
Author: Ryan Huang <[email protected]>
AuthorDate: Fri Jul 10 14:14:16 2026 +0900

    [Bug][QDP] Align Iris GPU training path with sibling pipelines (real dtype 
+ leaf weights) (#1412)
---
 .../encoding_benchmarks/qdp_pipeline/iris_amplitude.py  | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git 
a/qdp/qdp-python/benchmark/encoding_benchmarks/qdp_pipeline/iris_amplitude.py 
b/qdp/qdp-python/benchmark/encoding_benchmarks/qdp_pipeline/iris_amplitude.py
index 7b0132343..09ba096f1 100644
--- 
a/qdp/qdp-python/benchmark/encoding_benchmarks/qdp_pipeline/iris_amplitude.py
+++ 
b/qdp/qdp-python/benchmark/encoding_benchmarks/qdp_pipeline/iris_amplitude.py
@@ -322,9 +322,12 @@ def _run_training_gpu(
 ) -> dict[str, Any]:
     """GPU path: lightning.gpu + PyTorch interface, data stays on GPU. 
Optional early stop every 100 steps."""
     device = encoded_train.device
-    dtype = encoded_train.dtype
-    Y_train_t = torch.tensor(Y_train, dtype=dtype, device=device)
-    Y_test_t = torch.tensor(Y_test, dtype=dtype, device=device)
+    # Encoded data may be complex (from QDP); use real dtype for weights, bias 
and labels.
+    real_dtype = (
+        torch.float64 if encoded_train.dtype == torch.complex128 else 
torch.float32
+    )
+    Y_train_t = torch.tensor(Y_train, dtype=real_dtype, device=device)
+    Y_test_t = torch.tensor(Y_test, dtype=real_dtype, device=device)
 
     @qml.qnode(dev_qml, interface="torch", diff_method="adjoint")
     def circuit(weights, state_vector):
@@ -341,10 +344,12 @@ def _run_training_gpu(
         return torch.mean((Y_batch - preds) ** 2)
 
     torch.manual_seed(seed)
-    weights = 0.01 * torch.randn(
-        num_layers, NUM_QUBITS, 3, device=device, dtype=dtype, 
requires_grad=True
+    weights = (
+        (0.01 * torch.randn(num_layers, NUM_QUBITS, 3, device=device, 
dtype=real_dtype))
+        .detach()
+        .requires_grad_(True)
     )
-    bias = torch.tensor(0.0, device=device, dtype=dtype, requires_grad=True)
+    bias = torch.tensor(0.0, device=device, dtype=real_dtype, 
requires_grad=True)
     opt = torch.optim.SGD([weights, bias], lr=lr, momentum=0.9, nesterov=True)
 
     t0 = time.perf_counter()

Reply via email to