Commit 7651dce
authored
Simulator optimization branch: GPU density matrix, perf, audits, shared context (#290)
Major work on branch (squash of 28 commits + final clippy cleanup):
GPU simulator optimizations
- f32 gate fusion, commuting-gate reorder, CY/SWAP/RXX/RYY direct shaders
- Persistent kernel for small states with dynamic shared-memory sizing
- CPU measurement fast path for small states (f32 <=16q, f64 <=15q)
- Parallel CX/CZ/RZZ/RXX/RYY via rayon when .parallel(true)
- Parallel scalar CX path for low-qubit pairs (q_lo < 2)
- Fused flush_gates + state() readback into single encoder
- Adaptive mz path selection: empirical N/M lookup table replacing hardcoded threshold
- Raised StateVecSoA parallel threshold 14 -> 21 qubits
- Exploration benchmarks for adaptive path decisions
GpuDensityMatrix
- Choi-Jamiolkowski representation on top of GpuStateVec
- Generic over backend (f32 / f64); gates, noise channels, helpers
- Cholesky re-purification for mixed states
Correctness fixes (from audits)
- GPU 2q rotation shaders (RXX/RYY bit_a==bit_b bug)
- DensityMatrix phase/amplitude damping trace preservation
- mz is_deterministic flag (previously hardcoded false)
- GpuPauliProp gate ordering + Pauli X/Y/Z semantics, stale buffer reads
- GpuDensityMatrix mz probability formula
- GpuStabMulti::mz_queue now snapshots state at call time
Shared GPU context (concurrent-use SIGSEGV fix)
- Process-wide OnceLock<GpuDeviceContext> in pecos-gpu-sims/src/gpu_probe.rs
- All 7 simulators now reuse one wgpu Instance/Adapter/Device/Queue
- Fixes crashes under cargo's parallel test harness and MonteCarloEngine shots
- Removed the --test-threads=1 workaround from pecos-cli rust test
Test infrastructure
- New audits: gate_audit, gate_fuzz, pauli_prop_audit, influence_sampler_audit,
large_n_audit, noisy_sampler_stats, stab_extra_audits, extra_audits,
flush_blocked_audit, concurrent_gpu_test
- Removed pecos-quest / pecos-qulacs wrapper crates (bench code only)
- Removed dangling quest_sim_test.rs and quest_example.rs
Clippy / lint cleanup
- GpuError::Startup variant wraps GpuStartupError
- Internal GPU constants now usize (casts removed)
- Renamed GatePipeline variants SWAP/RXX/RYY/RZZ -> Swap/Rxx/Ryy/Rzz
- # Panics / # Errors doc sections added where clippy required
- Cholesky loops allow needless_range_loop with justification
- Test files allow cast_possible_truncation / cast_precision_loss with rationale1 parent a9a9d7a commit 7651dce
122 files changed
Lines changed: 15505 additions & 17386 deletions
File tree
- crates
- benchmarks
- benches/modules
- pecos-cli/src/cli
- pecos-cuquantum/src
- pecos-gpu-sims
- examples
- src
- bin
- tests
- pecos-hugr
- src
- pecos-quest
- examples
- include
- src
- tests
- pecos-qulacs
- src
- pecos-simulators
- src
- tests
- pecos
- examples
- src
- tests
- python
- pecos-rslib
- examples
- src
- tests
- quantum-pecos
- src/pecos/simulators
- quest_densitymatrix
- quest_statevec
- qulacs
- tests
- numpy_compatibility
- pecos
- integration
- state_sim_tests
- unit
- scripts/native_bench
- bench_pecos
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
192 | 192 | | |
193 | 193 | | |
194 | 194 | | |
195 | | - | |
196 | | - | |
197 | 195 | | |
198 | 196 | | |
199 | 197 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | 20 | | |
23 | | - | |
| 21 | + | |
24 | 22 | | |
25 | 23 | | |
26 | 24 | | |
27 | 25 | | |
28 | 26 | | |
29 | | - | |
30 | | - | |
31 | 27 | | |
32 | 28 | | |
33 | 29 | | |
| |||
Lines changed: 18 additions & 248 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
21 | 19 | | |
22 | 20 | | |
23 | 21 | | |
| |||
27 | 25 | | |
28 | 26 | | |
29 | 27 | | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | 28 | | |
37 | | - | |
| 29 | + | |
38 | 30 | | |
39 | 31 | | |
40 | 32 | | |
| |||
60 | 52 | | |
61 | 53 | | |
62 | 54 | | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
| 55 | + | |
133 | 56 | | |
134 | 57 | | |
135 | 58 | | |
136 | | - | |
| 59 | + | |
137 | 60 | | |
138 | 61 | | |
139 | 62 | | |
| |||
290 | 213 | | |
291 | 214 | | |
292 | 215 | | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
300 | | - | |
301 | | - | |
302 | | - | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
| 216 | + | |
329 | 217 | | |
330 | | - | |
| 218 | + | |
331 | 219 | | |
332 | | - | |
| 220 | + | |
333 | 221 | | |
334 | 222 | | |
335 | 223 | | |
| |||
441 | 329 | | |
442 | 330 | | |
443 | 331 | | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | 332 | | |
474 | | - | |
475 | | - | |
| 333 | + | |
| 334 | + | |
476 | 335 | | |
477 | 336 | | |
478 | 337 | | |
| |||
564 | 423 | | |
565 | 424 | | |
566 | 425 | | |
567 | | - | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | | - | |
573 | | - | |
574 | | - | |
575 | | - | |
576 | | - | |
577 | | - | |
578 | | - | |
579 | | - | |
580 | | - | |
581 | | - | |
582 | | - | |
583 | | - | |
584 | | - | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
589 | | - | |
590 | | - | |
591 | | - | |
592 | | - | |
593 | | - | |
594 | | - | |
595 | | - | |
596 | 426 | | |
597 | | - | |
598 | | - | |
| 427 | + | |
| 428 | + | |
599 | 429 | | |
600 | 430 | | |
601 | 431 | | |
| |||
687 | 517 | | |
688 | 518 | | |
689 | 519 | | |
690 | | - | |
691 | | - | |
692 | | - | |
693 | | - | |
694 | | - | |
695 | | - | |
696 | | - | |
697 | | - | |
698 | | - | |
699 | | - | |
700 | | - | |
701 | | - | |
702 | | - | |
703 | | - | |
704 | | - | |
705 | | - | |
706 | | - | |
707 | | - | |
708 | | - | |
709 | | - | |
710 | | - | |
711 | | - | |
712 | | - | |
713 | | - | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | 520 | | |
722 | | - | |
723 | | - | |
| 521 | + | |
| 522 | + | |
724 | 523 | | |
725 | 524 | | |
726 | 525 | | |
| |||
812 | 611 | | |
813 | 612 | | |
814 | 613 | | |
815 | | - | |
816 | | - | |
817 | | - | |
818 | | - | |
819 | | - | |
820 | | - | |
821 | | - | |
822 | | - | |
823 | | - | |
824 | | - | |
825 | | - | |
826 | | - | |
827 | | - | |
828 | | - | |
829 | | - | |
830 | | - | |
831 | | - | |
832 | | - | |
833 | | - | |
834 | | - | |
835 | | - | |
836 | | - | |
837 | | - | |
838 | | - | |
839 | | - | |
840 | | - | |
841 | | - | |
842 | | - | |
843 | | - | |
844 | 614 | | |
845 | | - | |
| 615 | + | |
846 | 616 | | |
847 | | - | |
| 617 | + | |
848 | 618 | | |
849 | 619 | | |
850 | 620 | | |
| |||
0 commit comments