ryankert01 commented on code in PR #1088:
URL: https://github.com/apache/mahout/pull/1088#discussion_r2846492459


##########
qdp/qdp-python/benchmark/encoding_benchmarks/qdp_pipeline/iris_amplitude.py:
##########
@@ -0,0 +1,543 @@
+#!/usr/bin/env python3
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+QDP pipeline: Iris (2-class), same data and training as baseline; only 
encoding differs.
+
+Aligned with baseline: 
https://pennylane.ai/qml/demos/tutorial_variational_classifier
+
+Data sources (default: sklearn, not the official file):
+  - Default: sklearn.datasets.load_iris, classes 0 & 1, 4 features → scale → 
L2 norm → 4-D vectors for QDP.
+  - Official file: pass --data-file <path>. File format: cols [f0, f1, f2, f3, 
label]; we use first 2 cols,
+    pad to 4, L2 norm. Bundled path: 
../pennylane_baseline/data/iris_classes1and2_scaled.txt (from XanaduAI/qml,
+    see baseline docstring URL).
+  - Total samples: 100 (2-class Iris). Full Iris has 150 (3 classes).
+
+Only difference from baseline: encoding. Here we use QDP (QuantumDataLoader + 
amplitude) → StatePrep(encoded);
+baseline uses get_angles → state_preparation(angles). Rest: same circuit (Rot 
+ CNOT), loss, optimizer, CLI.
+"""
+
+from __future__ import annotations
+
+# --- Imports ---
+
+import argparse
+import os
+import tempfile
+import time
+from typing import Any
+
+import numpy as np
+
+try:
+    import pennylane as qml
+    from pennylane import numpy as pnp
+    from pennylane.optimize import NesterovMomentumOptimizer, AdamOptimizer
+except ImportError as e:
+    raise SystemExit(
+        "PennyLane is required. Install with: uv sync --group benchmark"
+    ) from e
+
+try:
+    from sklearn.datasets import load_iris
+    from sklearn.preprocessing import StandardScaler
+except ImportError as e:
+    raise SystemExit(
+        "scikit-learn is required. Install with: uv sync --group benchmark"
+    ) from e
+
+from qumat_qdp import QuantumDataLoader
+import torch
+
+
+NUM_QUBITS = 2

Review Comment:
   Why did you set qubits = 2?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to