Skip to content

Commit f01e083

Browse files
authored
Surf dems2 (#294)
* Expand surface sweep reporting and analysis * Improve surface sweep plotting and docs * Refactor surface sweep reporting: unified matplotlib plots, multi-shard merge, PDF report, FSS threshold fit - Kill hand-rolled SVG plot writers; use matplotlib for both SVG and PDF via unified figure builders - Split 340-line main() into focused helpers (resolve_backends, duration schedule, config banner, sweep loop, post-analysis) - Add fit-quality warnings (fit_rms >= fit_epsilon), gate threshold fits on >=3 distances - Fix _estimate_threshold to use per-round rate crossing (was using projected-over-d-rounds which underestimates) - Add multi-shard merge via merge_sweep_shards(): accumulate shots across runs, re-fit from merged points - Add JSON-only replay: --render-plots regenerates all plots from saved JSON without rerunning simulation - Add multi-page PDF report (--save-report-pdf / --report-pdf) with styled cover, section dividers, appendix - Wire in Wang-Harrington-Preskill FSS threshold fit from pecos.analysis.threshold_curve (arXiv:quant-ph/0207088) - Annotate per-round plots with below-threshold power-law exponents and threshold markers with uncertainty bands - Per-basis curves now use log-log axes; consistent color palette across all plot types - Fix dashboard rebuild ordering in surface_sweep_report.py - Add 28 unit tests covering fit math, merge semantics, JSON round-trip, PDF generation, plot ordering * Fix grug-scout review issues: heterogeneous merge safety, strict zips, type clarity * Fix clippy map_unwrap_or in pecos-random time_seed * Apply clippy 1.95 auto-fixes across workspace * Reformat after clippy 1.95 auto-fixes * Fix remaining clippy 1.95 lints: checked_div, while_let_loop, sort_by_key, counter_loop * Update lockfiles
1 parent 00f889e commit f01e083

47 files changed

Lines changed: 4408 additions & 1005 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 27 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/pecos-build/src/download.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub fn download_cached(info: &DownloadInfo) -> Result<Vec<u8>> {
5050
log::info!("Downloading {} (will be cached)", info.name);
5151

5252
let client = reqwest::blocking::Client::builder()
53-
.timeout(std::time::Duration::from_secs(300))
53+
.timeout(std::time::Duration::from_mins(5))
5454
.connect_timeout(std::time::Duration::from_secs(30))
5555
.build()
5656
.map_err(|e| Error::Http(e.to_string()))?;

crates/pecos-build/src/llvm/installer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ fn download_and_verify_with_retry(url: &str, dest: &PathBuf, archive_name: &str)
191191
}
192192

193193
// Check for empty downloads (CDN/rate limit issues)
194-
let file_size = fs::metadata(dest).map(|m| m.len()).unwrap_or(0);
194+
let file_size = fs::metadata(dest).map_or(0, |m| m.len());
195195
if file_size == 0 {
196196
if attempt < MAX_RETRIES {
197197
eprintln!("Download returned empty file (possible CDN issue)");

crates/pecos-cli/src/cli/rust_cmd.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,7 @@ fn is_tool_available(tool: &str) -> bool {
168168
Command::new(tool)
169169
.args(["--version"])
170170
.output()
171-
.map(|o| o.status.success())
172-
.unwrap_or(false)
171+
.is_ok_and(|o| o.status.success())
173172
}
174173

175174
/// Run a cargo command and return success status

crates/pecos-cli/src/cli/selene_cmd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ fn run_list() -> Result<()> {
377377
let installed_lib = dist_dir.join(&lib_filename);
378378

379379
if installed_lib.exists() {
380-
let size = installed_lib.metadata().map(|m| m.len()).unwrap_or(0);
380+
let size = installed_lib.metadata().map_or(0, |m| m.len());
381381
println!(" (installed, {size} bytes)");
382382
} else {
383383
println!(" (not installed)");

crates/pecos-core/src/circuit_diagram.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,13 +1303,13 @@ impl CircuitDiagram {
13031303
let fill_hex = t.fill.strip_prefix('#').unwrap_or(&t.fill);
13041304
let stroke_hex = t.stroke.strip_prefix('#').unwrap_or(&t.stroke);
13051305
let text_hex = t.text.strip_prefix('#').unwrap_or(&t.text);
1306-
writeln!(out, " \\definecolor{{{name}Fill}}{{HTML}}{{{fill_hex}}}",).unwrap();
1306+
writeln!(out, " \\definecolor{{{name}Fill}}{{HTML}}{{{fill_hex}}}").unwrap();
13071307
writeln!(
13081308
out,
13091309
" \\definecolor{{{name}Stroke}}{{HTML}}{{{stroke_hex}}}",
13101310
)
13111311
.unwrap();
1312-
writeln!(out, " \\definecolor{{{name}Text}}{{HTML}}{{{text_hex}}}",).unwrap();
1312+
writeln!(out, " \\definecolor{{{name}Text}}{{HTML}}{{{text_hex}}}").unwrap();
13131313
}
13141314

13151315
// Styles.
@@ -1537,7 +1537,7 @@ impl CircuitDiagram {
15371537

15381538
match cell {
15391539
DiagramCell::Wire => {
1540-
writeln!(out, " {node_id} [label=\"\", shape=point, width=0.01];",)
1540+
writeln!(out, " {node_id} [label=\"\", shape=point, width=0.01];")
15411541
.unwrap();
15421542
}
15431543
DiagramCell::Gate(s, family) => {
@@ -1569,7 +1569,7 @@ impl CircuitDiagram {
15691569
.unwrap();
15701570
}
15711571
DiagramCell::Crossing | DiagramCell::Connector => {
1572-
writeln!(out, " {node_id} [label=\"\", shape=point, width=0.05];",)
1572+
writeln!(out, " {node_id} [label=\"\", shape=point, width=0.05];")
15731573
.unwrap();
15741574
}
15751575
DiagramCell::LabeledConnector(s) => {

crates/pecos-engines/src/byte_message/debug.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ pub fn dump_batch_raw(data: &[u8]) -> String {
211211
qubits_offset + gate_header.num_qubits as usize * size_of::<u32>();
212212

213213
match gate_header.gate_type {
214-
32 => {
214+
32
215215
// RZ
216-
if params_offset + size_of::<f64>() <= payload.len() {
216+
if params_offset + size_of::<f64>() <= payload.len() => {
217217
let theta = f64::from_le_bytes([
218218
payload[params_offset],
219219
payload[params_offset + 1],
@@ -227,10 +227,9 @@ pub fn dump_batch_raw(data: &[u8]) -> String {
227227

228228
writeln!(output, " Theta: {theta}").unwrap();
229229
}
230-
}
231-
36 => {
230+
36
232231
// R1XY
233-
if params_offset + 2 * size_of::<f64>() <= payload.len() {
232+
if params_offset + 2 * size_of::<f64>() <= payload.len() => {
234233
let phi = f64::from_le_bytes([
235234
payload[params_offset],
236235
payload[params_offset + 1],
@@ -256,7 +255,6 @@ pub fn dump_batch_raw(data: &[u8]) -> String {
256255
writeln!(output, " Phi: {phi}").unwrap();
257256
writeln!(output, " Theta: {theta}").unwrap();
258257
}
259-
}
260258
_ => {}
261259
}
262260
}

crates/pecos-engines/src/sim_builder.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,8 @@ impl SimBuilder {
196196
/// Use automatic worker count based on available CPUs
197197
#[must_use]
198198
pub fn auto_workers(mut self) -> Self {
199-
self.config.workers = std::thread::available_parallelism()
200-
.map(std::num::NonZero::get)
201-
.unwrap_or(4);
199+
self.config.workers =
200+
std::thread::available_parallelism().map_or(4, std::num::NonZero::get);
202201
self
203202
}
204203

crates/pecos-engines/tests/noise_determinism.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn compare_messages(msg1: &ByteMessage, msg2: &ByteMessage) -> bool {
117117
let results_left = msg1.outcomes().unwrap_or_default();
118118
let results_right = msg2.outcomes().unwrap_or_default();
119119
if quantum_ops_left != quantum_ops_right {
120-
eprintln!("Quantum operations differ: {quantum_ops_left:?} vs {quantum_ops_right:?}",);
120+
eprintln!("Quantum operations differ: {quantum_ops_left:?} vs {quantum_ops_right:?}");
121121
return false;
122122
}
123123
if results_left != results_right {

crates/pecos-hugr/src/engine.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2351,7 +2351,7 @@ mod tests {
23512351
.expect("Failed to generate commands");
23522352
// Empty circuits should produce empty or minimal messages
23532353
let is_empty = msg.is_empty().unwrap_or(true);
2354-
let has_no_ops = msg.quantum_ops().map(|ops| ops.is_empty()).unwrap_or(true);
2354+
let has_no_ops = msg.quantum_ops().map_or(true, |ops| ops.is_empty());
23552355
assert!(is_empty || has_no_ops);
23562356
}
23572357

0 commit comments

Comments
 (0)