hchevva commited on
Commit
82467f9
·
verified ·
1 Parent(s): d0e98cb

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -3
app.py CHANGED
@@ -19,6 +19,7 @@ from quread.heatmap import (
19
  plotly_available,
20
  HeatmapConfig,
21
  )
 
22
  from quread.metrics import (
23
  compute_metrics_from_csv,
24
  to_metrics_csv,
@@ -125,9 +126,27 @@ def apply_cnot(qc, last_counts, control, target):
125
  return qc, last_counts, f"✅ Applied CNOT (q{control} -> q{target})."
126
 
127
 
128
- def sample_shots(qc, shots):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  last_counts = qc.sample(shots=int(shots))
130
- return last_counts, "✅ Sampled shots."
131
 
132
 
133
  def measure_collapse(qc, shots):
@@ -375,6 +394,10 @@ with gr.Blocks(theme=theme, css=CSS, title="Quread.ai — State Vector Studio")
375
  gr.Markdown("---")
376
  gr.Markdown("### Quick Actions")
377
  reset_btn = gr.Button("Reset Simulator", variant="secondary")
 
 
 
 
378
  gr.Markdown("<div class='small-note'>Analytics controls are in the <b>Hardware Analytics</b> tab.</div>")
379
 
380
  # Main
@@ -633,7 +656,14 @@ with gr.Blocks(theme=theme, css=CSS, title="Quread.ai — State Vector Studio")
633
 
634
  sample_btn.click(
635
  fn=sample_shots,
636
- inputs=[qc_state, shots],
 
 
 
 
 
 
 
637
  outputs=[last_counts_state, status],
638
  ).then(
639
  fn=update_views,
 
19
  plotly_available,
20
  HeatmapConfig,
21
  )
22
+ from quread.noise_model import sample_noisy_counts
23
  from quread.metrics import (
24
  compute_metrics_from_csv,
25
  to_metrics_csv,
 
126
  return qc, last_counts, f"✅ Applied CNOT (q{control} -> q{target})."
127
 
128
 
129
+ def sample_shots(
130
+ qc,
131
+ shots,
132
+ noise_preview_enabled,
133
+ readout_scale,
134
+ depolarizing_prob,
135
+ calibration_text,
136
+ ):
137
+ if bool(noise_preview_enabled):
138
+ last_counts = sample_noisy_counts(
139
+ state=qc.state,
140
+ n_qubits=qc.n_qubits,
141
+ shots=int(shots),
142
+ calibration_json=str(calibration_text or ""),
143
+ readout_scale=float(readout_scale),
144
+ depolarizing_prob=float(depolarizing_prob),
145
+ )
146
+ return last_counts, "✅ Sampled noisy hardware-preview shots."
147
+
148
  last_counts = qc.sample(shots=int(shots))
149
+ return last_counts, "✅ Sampled ideal shots."
150
 
151
 
152
  def measure_collapse(qc, shots):
 
394
  gr.Markdown("---")
395
  gr.Markdown("### Quick Actions")
396
  reset_btn = gr.Button("Reset Simulator", variant="secondary")
397
+ with gr.Accordion("Hardware Noise Preview", open=False):
398
+ noise_preview_enabled = gr.Checkbox(label="Enable noise-aware sampling", value=False)
399
+ noise_readout_scale = gr.Slider(0.0, 3.0, value=1.0, step=0.05, label="Readout error scale")
400
+ noise_depolarizing = gr.Slider(0.0, 0.5, value=0.0, step=0.01, label="Depolarizing probability")
401
  gr.Markdown("<div class='small-note'>Analytics controls are in the <b>Hardware Analytics</b> tab.</div>")
402
 
403
  # Main
 
656
 
657
  sample_btn.click(
658
  fn=sample_shots,
659
+ inputs=[
660
+ qc_state,
661
+ shots,
662
+ noise_preview_enabled,
663
+ noise_readout_scale,
664
+ noise_depolarizing,
665
+ calibration_json,
666
+ ],
667
  outputs=[last_counts_state, status],
668
  ).then(
669
  fn=update_views,