Skip to content

Cleanup#281

Merged
ciaranra merged 72 commits intodevfrom
cleanup
Apr 7, 2026
Merged

Cleanup#281
ciaranra merged 72 commits intodevfrom
cleanup

Conversation

@ciaranra
Copy link
Copy Markdown
Member

@ciaranra ciaranra commented Apr 6, 2026

No description provided.

ciaranra added 30 commits April 5, 2026 15:50
Move tutorial-length comments from source to proper doc pages:
- noise/prelude.rs -> docs/experimental/composable-noise.md
- engine_type.rs -> docs/user-guide/engine-selection.md
- fault_tolerance.rs trimmed (content already in docs/user-guide/fault-tolerance.md)
- classical.rs trait methods trimmed

All doc examples are tested via the unified Rust test crate (13 new tests).
- Convert 26 ignored doctests to runnable with proper imports and setup
- Fix 1 pre-existing failure (Python example missing language tag)
- Change Python examples from ignore to python language tag
- Change pseudocode examples from ignore to text
- cuQuantum examples: ignore -> no_run (compile-checked, needs GPU .so at runtime)
Load cuQuantum/CUDA shared libraries at runtime via libloading instead
of linking at build time. This means doctests run everywhere: on GPU
machines they exercise real hardware, without GPU they get a graceful
NotAvailable error via the ? operator.

Removes the cuquantum_stub cfg and all function stubs from build.rs.
Stub path now emits only type definitions. The loader searches
CUQUANTUM_ROOT, ~/.pecos/deps, CUDA_PATH, and system paths.
- Trim "This module/crate/struct/trait provides" from 40 doc comments
- Make 5 no_run doctests fully runnable (qasm, simulator test utils)
- Change 6 pseudocode doctests from no_run to text
- Replace 211 ASCII art section dividers with clean headers in 8 files
- Remove "Comprehensive" from 9 test file doc comments
- Remove 16 "This generic implementation" boilerplate lines from math.rs
QASM parser no longer panics on malformed input -- returns parse errors
instead. Engine code uses expect() with clear invariant messages or
restructured to avoid unwraps entirely.
…pecos-build

- pecos-num: as_slice().unwrap() now documents contiguity requirement
- pecos-build: download thread panics return errors instead of crashing
- pecos-phir: regex captures and lock acquisitions use expect with reasons
Examples now use ? operator instead of unwrap(), teaching users good
error handling. Python bindings use expect() with clear invariant
messages instead of bare unwrap() that would crash the interpreter.
…code

Python bindings: 130 unwraps eliminated -- prevents interpreter crashes
on conversion failures, lock poisoning, and array operations.

Rust: 28 unwraps replaced across 22 files in GPU sims, decoders,
circuit display, PHIR engine, and simulators.
- map_async callbacks no longer panic from GPU worker threads when
  receiver is dropped (expect -> silent drop on send)
- All 6 GPU simulator types now have explicit Drop that polls the
  device to completion before resources are freed
- New concurrent stress test: 8 threads creating/destroying simulators
  in parallel, plus rapid sequential create/destroy cycles
Doctests now pass on systems without cuQuantum by early-returning Ok(())
when the libraries aren't available. On systems with cuQuantum, they
still exercise the real GPU code.
…tion

Doctests should test real GPU code without availability guards. The
test runner (pecos rust test) already excludes pecos-cuquantum from
workspace tests and only includes it when cuQuantum SDK is detected.
…ction

Python simulators/__init__.py no longer gates CudaStateVec/CudaStabilizer
imports behind is_cuquantum_available(). Classes are always importable
when the package is installed -- GPU availability is checked at
construction time with a clear RuntimeError, not silently set to None.
pecos-quest now always compiles CUDA engine code. GPU availability is
detected at runtime via libloading (cuda_loader.rs), matching the
pecos-cuquantum pattern. No more --features cuda needed.

Removes cuda feature from pecos-quest, pecos, pecos-rslib, and
benchmarks Cargo.toml files. Simplifies CLI check/clippy/test commands.
@ciaranra ciaranra marked this pull request as ready for review April 7, 2026 13:34
@ciaranra ciaranra merged commit ee6bfd3 into dev Apr 7, 2026
88 checks passed
@ciaranra ciaranra deleted the cleanup branch April 7, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant