Skip to content

Commit a948922

Browse files
committed
fix
1 parent 54b7511 commit a948922

4 files changed

Lines changed: 68 additions & 16 deletions

File tree

.github/workflows/rust-test.yml

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,13 @@ jobs:
7474
run: rustup component add clippy
7575

7676
- name: Run clippy
77-
run: cargo clippy --workspace --all-targets --features llvm -- -D warnings
77+
run: |
78+
echo "Running clippy with all features (including LLVM)..."
79+
cargo clippy --workspace --exclude pecos --exclude pecos-quest --all-targets --all-features -- -D warnings
80+
echo "Running clippy on pecos with all non-GPU features..."
81+
cargo clippy -p pecos --all-targets --features "llvm,selene,qasm,phir,all-simulators" -- -D warnings
82+
echo "Running clippy on pecos-quest with CPU features only..."
83+
cargo clippy -p pecos-quest --all-targets --features "cpu" -- -D warnings
7884
7985
rust-lint-no-llvm:
8086
runs-on: ubuntu-latest
@@ -245,11 +251,16 @@ jobs:
245251
246252
echo "RUSTFLAGS: $RUSTFLAGS"
247253
248-
cargo test --no-run --features llvm
254+
cargo test --no-run --workspace --exclude pecos-quest --exclude pecos-decoders --features llvm
255+
cargo test --no-run -p pecos-quest --features cpu
256+
cargo test --no-run -p pecos-decoders --all-features
249257
250258
- name: Compile tests (Linux/Windows)
251259
if: matrix.os != 'macos-latest'
252-
run: cargo test --no-run --features llvm
260+
run: |
261+
cargo test --no-run --workspace --exclude pecos-quest --exclude pecos-decoders --features llvm
262+
cargo test --no-run -p pecos-quest --features cpu
263+
cargo test --no-run -p pecos-decoders --all-features
253264
254265
- name: Run tests (macOS)
255266
if: matrix.os == 'macos-latest'
@@ -264,17 +275,24 @@ jobs:
264275
unset PKG_CONFIG_PATH
265276
export LIBRARY_PATH=/usr/lib
266277
267-
cargo test --workspace --features llvm
278+
cargo test --workspace --exclude pecos-quest --exclude pecos-decoders --features llvm
279+
cargo test -p pecos-quest --features cpu
280+
cargo test -p pecos-decoders --all-features
268281
269282
- name: Run tests (Linux)
270283
if: matrix.os == 'ubuntu-latest'
271-
run: cargo test --workspace
284+
run: |
285+
cargo test --workspace --exclude pecos-quest --exclude pecos-decoders --features llvm
286+
cargo test -p pecos-quest --features cpu
287+
cargo test -p pecos-decoders --all-features
272288
273289
- name: Run tests (Windows)
274290
if: matrix.os == 'windows-latest'
275291
run: |
276292
# Run all non-doctest tests
277-
cargo test --workspace --features llvm --exclude pecos-rslib --lib --bins --tests --examples
293+
cargo test --workspace --exclude pecos-quest --exclude pecos-decoders --exclude pecos-rslib --features llvm --lib --bins --tests --examples
294+
cargo test -p pecos-quest --features cpu --lib --bins --tests --examples
295+
cargo test -p pecos-decoders --all-features --lib --bins --tests --examples
278296
279297
# For Windows, we need to run doctests for the pecos crate specially
280298
# to ensure they run from the crate directory
@@ -283,4 +301,6 @@ jobs:
283301
cd ../..
284302
285303
# Run doctests for other crates normally
286-
cargo test --workspace --features llvm --exclude pecos-rslib --exclude pecos --doc
304+
cargo test --workspace --exclude pecos-quest --exclude pecos-decoders --exclude pecos-rslib --exclude pecos --features llvm --doc
305+
cargo test -p pecos-quest --doc
306+
cargo test -p pecos-decoders --all-features --doc

Makefile

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,16 +237,32 @@ lint-fix: ## Fix all auto-fixable linting issues (Rust, Python, Julia)
237237
# -------
238238

239239
.PHONY: rstest
240-
rstest: ## Run Rust tests
241-
@$(ADD_LLVM_TO_PATH) cargo test --workspace --release --exclude pecos-quest --exclude pecos-decoders --features llvm
242-
@$(ADD_LLVM_TO_PATH) cargo test -p pecos-quest --release
243-
@$(ADD_LLVM_TO_PATH) cargo test -p pecos-decoders --release --all-features
240+
rstest: ## Run Rust tests (with GPU features only if CUDA available)
241+
@if [ "$(CUDA_AVAILABLE)" = "no" ]; then \
242+
echo "CUDA not detected - testing all features except GPU"; \
243+
$(ADD_LLVM_TO_PATH) cargo test --workspace --release --exclude pecos-quest --exclude pecos-decoders --features llvm; \
244+
$(ADD_LLVM_TO_PATH) cargo test -p pecos-quest --release --features cpu; \
245+
$(ADD_LLVM_TO_PATH) cargo test -p pecos-decoders --release --all-features; \
246+
else \
247+
echo "CUDA detected - testing with all features including GPU"; \
248+
$(ADD_LLVM_TO_PATH) cargo test --workspace --release --exclude pecos-quest --exclude pecos-decoders --features llvm; \
249+
$(ADD_LLVM_TO_PATH) cargo test -p pecos-quest --release --all-features; \
250+
$(ADD_LLVM_TO_PATH) cargo test -p pecos-decoders --release --all-features; \
251+
fi
244252

245253
.PHONY: rstest-all
246-
rstest-all: ## Run Rust tests with all features except GPU
247-
@$(ADD_LLVM_TO_PATH) cargo test --workspace --exclude pecos-quest --exclude pecos-decoders --features llvm
248-
@$(ADD_LLVM_TO_PATH) cargo test -p pecos-quest
249-
@$(ADD_LLVM_TO_PATH) cargo test -p pecos-decoders --all-features
254+
rstest-all: ## Run Rust tests with all features (including GPU if CUDA available)
255+
@if [ "$(CUDA_AVAILABLE)" = "no" ]; then \
256+
echo "CUDA not detected - testing all features except GPU"; \
257+
$(ADD_LLVM_TO_PATH) cargo test --workspace --exclude pecos-quest --exclude pecos-decoders --features llvm; \
258+
$(ADD_LLVM_TO_PATH) cargo test -p pecos-quest --features cpu; \
259+
$(ADD_LLVM_TO_PATH) cargo test -p pecos-decoders --all-features; \
260+
else \
261+
echo "CUDA detected - testing with all features including GPU"; \
262+
$(ADD_LLVM_TO_PATH) cargo test --workspace --exclude pecos-quest --exclude pecos-decoders --features llvm; \
263+
$(ADD_LLVM_TO_PATH) cargo test -p pecos-quest --all-features; \
264+
$(ADD_LLVM_TO_PATH) cargo test -p pecos-decoders --all-features; \
265+
fi
250266

251267
# Decoder-specific commands
252268
# -------------------------

python/quantum-pecos/src/pecos/engines/hybrid_engine.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ def initialize_sim_components(
154154
self.machine.init(num_qubits)
155155
self.error_model.init(num_qubits, self.machine)
156156
self.op_processor.init()
157+
# Pass seed to quantum simulator if one was set
158+
if self.seed is not None:
159+
self.qsim.qsim_params["seed"] = self.seed
157160
self.qsim.init(num_qubits)
158161

159162
def shot_reinit_components(self) -> None:

python/quantum-pecos/src/pecos/simulators/quantum_simulator.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,20 @@ def init(self, num_qubits: int) -> None:
114114
if self.backend is None:
115115
self.state = SparseSim
116116

117-
self.state = self.state(num_qubits=num_qubits, **self.qsim_params)
117+
# Try to initialize with all params including seed
118+
# If the simulator doesn't support seed, retry without it
119+
try:
120+
self.state = self.state(num_qubits=num_qubits, **self.qsim_params)
121+
except TypeError as e:
122+
if "seed" in str(e) and "unexpected keyword argument" in str(e):
123+
# Simulator doesn't support seed parameter, retry without it
124+
params_without_seed = {
125+
k: v for k, v in self.qsim_params.items() if k != "seed"
126+
}
127+
self.state = self.state(num_qubits=num_qubits, **params_without_seed)
128+
else:
129+
# Different TypeError, re-raise it
130+
raise
118131

119132
def shot_reinit(self) -> None:
120133
"""Run all code needed at the beginning of each shot, e.g., resetting state."""

0 commit comments

Comments
 (0)