Skip to content

Commit e833f41

Browse files
committed
fix routes problem and update
1 parent 0d9920e commit e833f41

File tree

6 files changed

+15
-37
lines changed

6 files changed

+15
-37
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ repos:
7171
name: cargo clippy
7272
language: system
7373
pass_filenames: false
74-
entry: bash -c 'LIBTORCH_USE_PYTORCH=1 LIBTORCH_BYPASS_VERSION_CHECK=1 cargo clippy "$@"' --
74+
entry: bash -c 'LIBTORCH_USE_PYTORCH=1 cargo clippy "$@"' --
7575
args:
7676
- --manifest-path
7777
- qdp/Cargo.toml

qdp/qdp-python/benchmark/benchmark_latency.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,20 @@
1818
"""
1919
Data-to-State latency benchmark: CPU RAM -> GPU VRAM.
2020
21-
Run:
22-
python qdp/qdp-python/benchmark/benchmark_latency.py --qubits 16 \
21+
Run from qdp-python directory (qumat_qdp must be importable, e.g. via uv):
22+
uv run python benchmark/benchmark_latency.py --qubits 16 \\
2323
--batches 200 --batch-size 64 --prefetch 16
2424
"""
2525

2626
from __future__ import annotations
2727

2828
import argparse
29-
import sys
3029
import time
31-
from pathlib import Path
3230

3331
import torch
3432

35-
# Add project root to path so qumat_qdp is importable when run as script
36-
_script_dir = Path(__file__).resolve().parent
37-
_project_root = _script_dir.parent
38-
if str(_project_root) not in sys.path:
39-
sys.path.insert(0, str(_project_root))
40-
41-
from benchmark.utils import normalize_batch, prefetched_batches # noqa: E402
42-
from qumat_qdp import QdpBenchmark # noqa: E402
33+
from benchmark.utils import normalize_batch, prefetched_batches
34+
from qumat_qdp import QdpBenchmark
4335

4436
BAR = "=" * 70
4537
SEP = "-" * 70

qdp/qdp-python/benchmark/benchmark_loader_throughput.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,16 @@
2121
Compares iterator-based throughput with run_throughput_pipeline_py.
2222
Expectation: loader version slightly slower due to Python boundary per batch.
2323
24-
Usage (from qdp-python):
24+
Run from qdp-python directory (qumat_qdp must be importable, e.g. via uv):
2525
uv run python benchmark/benchmark_loader_throughput.py --qubits 16 --batches 200 --batch-size 64
2626
"""
2727

2828
from __future__ import annotations
2929

3030
import argparse
31-
import sys
3231
import time
33-
from pathlib import Path
3432

35-
# Add project root to path so qumat_qdp is importable when run as script
36-
_script_dir = Path(__file__).resolve().parent
37-
_project_root = _script_dir.parent
38-
if str(_project_root) not in sys.path:
39-
sys.path.insert(0, str(_project_root))
40-
41-
from qumat_qdp import QuantumDataLoader, QdpBenchmark # noqa: E402
33+
from qumat_qdp import QuantumDataLoader, QdpBenchmark
4234

4335

4436
def run_loader_throughput(

qdp/qdp-python/benchmark/benchmark_throughput.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,18 @@
2323
- Prefetch on the CPU side to keep the GPU fed.
2424
- Encode vectors into amplitude states on GPU and run a tiny consumer op.
2525
26-
Run:
27-
python qdp/benchmark/benchmark_throughput.py --qubits 16 --batches 200 --batch-size 64
26+
Run from qdp-python directory (qumat_qdp must be importable, e.g. via uv):
27+
uv run python benchmark/benchmark_throughput.py --qubits 16 --batches 200 --batch-size 64
2828
"""
2929

3030
import argparse
31-
import sys
3231
import time
33-
from pathlib import Path
3432

3533
import numpy as np
3634
import torch
3735

38-
# Add project root to path so qumat_qdp is importable when run as script
39-
_script_dir = Path(__file__).resolve().parent
40-
_project_root = _script_dir.parent
41-
if str(_project_root) not in sys.path:
42-
sys.path.insert(0, str(_project_root))
43-
44-
from benchmark.utils import normalize_batch, prefetched_batches # noqa: E402
45-
from qumat_qdp import QdpBenchmark # noqa: E402
36+
from benchmark.utils import normalize_batch, prefetched_batches
37+
from qumat_qdp import QdpBenchmark
4638

4739
BAR = "=" * 70
4840
SEP = "-" * 70

qdp/qdp-python/qumat_qdp/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929

3030
from __future__ import annotations
3131

32-
# Rust extension (built by maturin)
32+
# Rust extension (built by maturin). QdpEngine/QuantumTensor are public for
33+
# advanced use; QdpBenchmark and QuantumDataLoader are the recommended high-level API.
3334
import _qdp
3435

3536
from qumat_qdp.api import (

qdp/qdp-python/qumat_qdp/loader.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131

3232
from typing import Iterator, Optional
3333

34-
# Lazy import _qdp until __iter__ is used
34+
# Lazy import _qdp until __iter__ is used: avoids import-time load when only
35+
# importing QuantumDataLoader, and defers extension/CUDA requirement until first use.
3536
_qdp: Optional[object] = None
3637

3738

0 commit comments

Comments
 (0)