hchevva commited on
Commit
d8b8170
·
verified ·
1 Parent(s): d473aef

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +114 -0
app.py CHANGED
@@ -20,6 +20,11 @@ from quread.heatmap import (
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,
@@ -519,6 +524,9 @@ with gr.Blocks(theme=theme, css=CSS, title="Quread.ai — State Vector Studio")
519
  cirq_dl = gr.DownloadButton("Cirq")
520
  csv_dl = gr.DownloadButton("CSV")
521
  skill_dl = gr.DownloadButton("Skill script")
 
 
 
522
 
523
  with gr.Tab("Hardware Analytics"):
524
  with gr.Group(elem_classes=["card"]):
@@ -745,6 +753,78 @@ with gr.Blocks(theme=theme, css=CSS, title="Quread.ai — State Vector Studio")
745
  csv_dl.click(fn=dl_csv, inputs=[qc_state], outputs=[csv_dl])
746
  skill_dl.click(fn=dl_skill, inputs=[qc_state, n_qubits], outputs=[skill_dl])
747
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
748
  explain_btn.click(
749
  fn=explain_llm,
750
  inputs=[qc_state, n_qubits, shots, last_explained_hash, explanation_md],
@@ -921,6 +1001,40 @@ with gr.Blocks(theme=theme, css=CSS, title="Quread.ai — State Vector Studio")
921
  outputs=[metrics_csv_dl],
922
  )
923
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
924
  def dl_explain_md(md_text):
925
  return _write_tmp("explanation.md", md_text)
926
 
 
20
  HeatmapConfig,
21
  )
22
  from quread.noise_model import sample_noisy_counts
23
+ from quread.eda_translator import (
24
+ build_eda_mapping,
25
+ to_synopsys_tcl,
26
+ to_cadence_skill_reliability,
27
+ )
28
  from quread.metrics import (
29
  compute_metrics_from_csv,
30
  to_metrics_csv,
 
524
  cirq_dl = gr.DownloadButton("Cirq")
525
  csv_dl = gr.DownloadButton("CSV")
526
  skill_dl = gr.DownloadButton("Skill script")
527
+ with gr.Row():
528
+ synopsys_tcl_dl = gr.DownloadButton("Synopsys TCL (risk)")
529
+ cadence_skill_dl = gr.DownloadButton("Cadence SKILL (risk)")
530
 
531
  with gr.Tab("Hardware Analytics"):
532
  with gr.Group(elem_classes=["card"]):
 
753
  csv_dl.click(fn=dl_csv, inputs=[qc_state], outputs=[csv_dl])
754
  skill_dl.click(fn=dl_skill, inputs=[qc_state, n_qubits], outputs=[skill_dl])
755
 
756
+ def _dl_synopsys_tcl(
757
+ qc,
758
+ n_qubits,
759
+ calibration_text,
760
+ activity_w,
761
+ gate_error_w,
762
+ readout_error_w,
763
+ decoherence_w,
764
+ fidelity_w,
765
+ warning_thr,
766
+ critical_thr,
767
+ ):
768
+ csv_text = to_csv(qc.history)
769
+ weights, thresholds = _metric_controls_to_models(
770
+ activity_w,
771
+ gate_error_w,
772
+ readout_error_w,
773
+ decoherence_w,
774
+ fidelity_w,
775
+ warning_thr,
776
+ critical_thr,
777
+ )
778
+ metrics, _meta = compute_metrics_from_csv(
779
+ csv_text,
780
+ int(n_qubits),
781
+ calibration_json=str(calibration_text or ""),
782
+ state_vector=np.asarray(qc.state, dtype=complex),
783
+ weights=weights,
784
+ thresholds=thresholds,
785
+ )
786
+ mapping = build_eda_mapping(
787
+ metrics,
788
+ cfg=None,
789
+ )
790
+ return _write_tmp("quread_risk_synopsys.tcl", to_synopsys_tcl(mapping))
791
+
792
+ def _dl_cadence_skill(
793
+ qc,
794
+ n_qubits,
795
+ calibration_text,
796
+ activity_w,
797
+ gate_error_w,
798
+ readout_error_w,
799
+ decoherence_w,
800
+ fidelity_w,
801
+ warning_thr,
802
+ critical_thr,
803
+ ):
804
+ csv_text = to_csv(qc.history)
805
+ weights, thresholds = _metric_controls_to_models(
806
+ activity_w,
807
+ gate_error_w,
808
+ readout_error_w,
809
+ decoherence_w,
810
+ fidelity_w,
811
+ warning_thr,
812
+ critical_thr,
813
+ )
814
+ metrics, _meta = compute_metrics_from_csv(
815
+ csv_text,
816
+ int(n_qubits),
817
+ calibration_json=str(calibration_text or ""),
818
+ state_vector=np.asarray(qc.state, dtype=complex),
819
+ weights=weights,
820
+ thresholds=thresholds,
821
+ )
822
+ mapping = build_eda_mapping(
823
+ metrics,
824
+ cfg=None,
825
+ )
826
+ return _write_tmp("quread_risk_cadence.il", to_cadence_skill_reliability(mapping))
827
+
828
  explain_btn.click(
829
  fn=explain_llm,
830
  inputs=[qc_state, n_qubits, shots, last_explained_hash, explanation_md],
 
1001
  outputs=[metrics_csv_dl],
1002
  )
1003
 
1004
+ synopsys_tcl_dl.click(
1005
+ fn=_dl_synopsys_tcl,
1006
+ inputs=[
1007
+ qc_state,
1008
+ n_qubits,
1009
+ calibration_json,
1010
+ w_activity,
1011
+ w_gate,
1012
+ w_readout,
1013
+ w_decoherence,
1014
+ w_fidelity,
1015
+ thr_warning,
1016
+ thr_critical,
1017
+ ],
1018
+ outputs=[synopsys_tcl_dl],
1019
+ )
1020
+
1021
+ cadence_skill_dl.click(
1022
+ fn=_dl_cadence_skill,
1023
+ inputs=[
1024
+ qc_state,
1025
+ n_qubits,
1026
+ calibration_json,
1027
+ w_activity,
1028
+ w_gate,
1029
+ w_readout,
1030
+ w_decoherence,
1031
+ w_fidelity,
1032
+ thr_warning,
1033
+ thr_critical,
1034
+ ],
1035
+ outputs=[cadence_skill_dl],
1036
+ )
1037
+
1038
  def dl_explain_md(md_text):
1039
  return _write_tmp("explanation.md", md_text)
1040