guan404ming commented on code in PR #1000:
URL: https://github.com/apache/mahout/pull/1000#discussion_r2750469065


##########
qdp/qdp-python/benchmark/benchmark_throughput.py:
##########
@@ -28,13 +28,21 @@
 """
 
 import argparse
+import sys
 import time
+from pathlib import Path
 
 import numpy as np
 import torch
 
-from _qdp import QdpEngine
-from utils import normalize_batch, prefetched_batches
+# Add project root to path so qumat_qdp is importable when run as script

Review Comment:
   ditto



##########
qdp/qdp-python/benchmark/benchmark_latency.py:
##########
@@ -26,12 +26,20 @@
 from __future__ import annotations
 
 import argparse
+import sys
 import time
+from pathlib import Path
 
 import torch
 
-from _qdp import QdpEngine
-from utils import normalize_batch, prefetched_batches
+# Add project root to path so qumat_qdp is importable when run as script

Review Comment:
   I think we handle this more better by using the internal qdp export here



##########
qdp/qdp-python/benchmark/benchmark_loader_throughput.py:
##########
@@ -0,0 +1,114 @@
+#!/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.
+
+"""
+Throughput benchmark using QuantumDataLoader (for qt in loader).
+
+Compares iterator-based throughput with run_throughput_pipeline_py.
+Expectation: loader version slightly slower due to Python boundary per batch.
+
+Usage (from qdp-python):
+  uv run python benchmark/benchmark_loader_throughput.py --qubits 16 --batches 
200 --batch-size 64
+"""
+
+from __future__ import annotations
+
+import argparse
+import sys
+import time
+from pathlib import Path
+
+# Add project root to path so qumat_qdp is importable when run as script

Review Comment:
   ditto



##########
.pre-commit-config.yaml:
##########
@@ -71,7 +71,7 @@ repos:
         name: cargo clippy
         language: system
         pass_filenames: false
-        entry: bash -c 'LIBTORCH_USE_PYTORCH=1 cargo clippy "$@"' --
+        entry: bash -c 'LIBTORCH_USE_PYTORCH=1 LIBTORCH_BYPASS_VERSION_CHECK=1 
cargo clippy "$@"' --

Review Comment:
   I think we use local torch instead of libtorch here. Could you help share 
why we need this change?



##########
qdp/qdp-python/qumat_qdp/__init__.py:
##########
@@ -0,0 +1,55 @@
+#
+# 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 (Quantum Data Processing) Python API.
+
+Public API: QdpEngine, QuantumTensor (Rust extension _qdp),
+QdpBenchmark, ThroughputResult, LatencyResult (benchmark API),
+QuantumDataLoader (data loader iterator).
+
+Usage:
+    from qumat_qdp import QdpEngine, QuantumTensor
+    from qumat_qdp import QdpBenchmark, ThroughputResult, LatencyResult
+    from qumat_qdp import QuantumDataLoader
+"""
+
+from __future__ import annotations
+
+# Rust extension (built by maturin)
+import _qdp
+
+from qumat_qdp.api import (

Review Comment:
   Do we want to export this for our users?



##########
qdp/qdp-python/qumat_qdp/loader.py:
##########
@@ -0,0 +1,123 @@
+#
+# 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.
+
+"""
+Quantum Data Loader: Python builder for Rust-backed batch iterator.
+
+Usage:
+    from qumat_qdp import QuantumDataLoader
+
+    loader = (QuantumDataLoader(device_id=0).qubits(16).encoding("amplitude")
+              .batches(100, size=64).source_synthetic())
+    for qt in loader:
+        batch = torch.from_dlpack(qt)
+        ...
+"""
+
+from __future__ import annotations
+
+from typing import Iterator, Optional
+
+# Lazy import _qdp until __iter__ is used
+_qdp: Optional[object] = None
+
+
+def _get_qdp():

Review Comment:
   I'm not really sure if we need this. Could you explain more?



-- 
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