UX polish pass: results viz, sample descriptions, delete affordance
Browse filesThree related changes aimed at making both experts and newcomers able
to understand and play with the lab's algorithms through the demo.
UX basics (Batch 1):
- Fix all timing claims to match HF's shared CPU (~2 min, not ~60 s)
- Rename "Fake backend" -> "Noisy simulator" with a plain-English
description ("Simulates a real IBM quantum chip with its measured
noise. Runs locally, no IBM account needed.")
- Add a hover-X delete button on each canvas node, with a matching
hint in the block palette about the Backspace shortcut
- Sample circuit buttons now show a curated one-liner under the name,
replacing the auto-generated "N-qubit circuit, depth D" text
More demo circuits (Batch 2):
- Add 4 new samples: w_state_3q, qft_3q, ry_chain_6q, hardware_efficient_4q
- Each comes with a human-friendly description in the circuit picker
Results visualization (Batch 3):
- ResultsPane now renders per-algorithm cards instead of flat k/v rows:
- QuBound: 0-1 gauge + "lower is better" caption
- QuCAD: kept/removed stats + sparsity-trace sparkline
- CompressVQC: before/after depth bars + gates-removed count
- Fidelity: percent gauge colored by ok/warn/danger bands
- Output: depth/size stats + gate-breakdown bars + ASCII diagram
- Each card has a "what this did" caption up top (for newcomers) and
a details expander with raw summary data (for experts)
- FinalMetrics cards get larger numbers + 2-line plain-language help
- Generic SummaryRow fallback preserved for unknown node types
- README.md +2 -2
- backend/app/services/circuit_service.py +25 -1
- backend/app/services/workflow_service.py +3 -3
- backend/sample_circuits/efficient_su2_4q.qpy +0 -0
- backend/sample_circuits/hardware_efficient_4q.qpy +0 -0
- backend/sample_circuits/qaoa_maxcut_4.qpy +0 -0
- backend/sample_circuits/qft_3q.qpy +0 -0
- backend/sample_circuits/ry_chain_6q.qpy +0 -0
- backend/sample_circuits/vqc_2q_small.qpy +0 -0
- backend/sample_circuits/w_state_3q.qpy +0 -0
- frontend/src/components/CircuitPicker.tsx +22 -9
- frontend/src/components/NodePalette.tsx +3 -1
- frontend/src/components/QNode.tsx +20 -3
- frontend/src/components/ResultsPane.tsx +531 -29
- frontend/src/components/WelcomeTour.tsx +5 -4
- frontend/src/lib/nodeCatalog.ts +3 -2
- scripts/generate_sample_circuits.py +81 -1
|
@@ -26,8 +26,8 @@ sorted from the React-Flow edges.
|
|
| 26 |
- **QuCAD**: ADMM-regularized, noise-aware VQC sparsification.
|
| 27 |
- **QuBound**: LSTM trained on 14 days of real `ibm_fez` calibration data
|
| 28 |
predicts today's error bound for your circuit. Ships with a pickled cache
|
| 29 |
-
of the calibration history, so the demo runs offline (
|
| 30 |
-
on CPU). If an IBM Quantum Platform token is configured, it fetches fresh
|
| 31 |
noise history instead.
|
| 32 |
- **CompressVQC**: QAOA-optimized lookup table for folding redundant
|
| 33 |
parametric rotations on Heron-family hardware.
|
|
|
|
| 26 |
- **QuCAD**: ADMM-regularized, noise-aware VQC sparsification.
|
| 27 |
- **QuBound**: LSTM trained on 14 days of real `ibm_fez` calibration data
|
| 28 |
predicts today's error bound for your circuit. Ships with a pickled cache
|
| 29 |
+
of the calibration history, so the demo runs offline (plan for about
|
| 30 |
+
2 min of LSTM training on HF's shared CPU). If an IBM Quantum Platform token is configured, it fetches fresh
|
| 31 |
noise history instead.
|
| 32 |
- **CompressVQC**: QAOA-optimized lookup table for folding redundant
|
| 33 |
parametric rotations on Heron-family hardware.
|
|
@@ -95,6 +95,30 @@ def summarize(qc: QuantumCircuit, circuit_id: str) -> CircuitInfo:
|
|
| 95 |
|
| 96 |
# ---------- Sample circuits ----------
|
| 97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
def discover_samples(sample_dir: Path = SAMPLE_CIRCUITS_DIR) -> list[SampleCircuit]:
|
| 99 |
"""Look up built-in demo circuits shipped in backend/sample_circuits/."""
|
| 100 |
if not sample_dir.exists():
|
|
@@ -109,7 +133,7 @@ def discover_samples(sample_dir: Path = SAMPLE_CIRCUITS_DIR) -> list[SampleCircu
|
|
| 109 |
SampleCircuit(
|
| 110 |
key=path.stem,
|
| 111 |
display_name=qc.name or path.stem,
|
| 112 |
-
description=
|
| 113 |
num_qubits=qc.num_qubits,
|
| 114 |
source="qpy",
|
| 115 |
)
|
|
|
|
| 95 |
|
| 96 |
# ---------- Sample circuits ----------
|
| 97 |
|
| 98 |
+
# Hand-written one-liners aimed at both beginners (what it's for) and
|
| 99 |
+
# experts (what the structure is). Shown in the left-panel circuit picker.
|
| 100 |
+
# Keep under ~90 chars so the sample button doesn't wrap into three lines.
|
| 101 |
+
SAMPLE_DESCRIPTIONS: dict[str, str] = {
|
| 102 |
+
"bell_state": "The simplest entangled state: two qubits in a Bell pair.",
|
| 103 |
+
"ghz_3q": "Three qubits fully entangled (a GHZ state).",
|
| 104 |
+
"vqc_2q_small": "A tiny trainable quantum circuit with 2 tunable angles.",
|
| 105 |
+
"efficient_su2_4q": "A 4-qubit EfficientSU2 ansatz, a classic quantum-ML building block.",
|
| 106 |
+
"qaoa_maxcut_4": "QAOA solving Max-Cut on a 4-node ring graph.",
|
| 107 |
+
# Batch 2 circuits:
|
| 108 |
+
"w_state_3q": "Another way to entangle 3 qubits: a W state.",
|
| 109 |
+
"qft_3q": "3-qubit Quantum Fourier Transform, a core building block of many algorithms.",
|
| 110 |
+
"ry_chain_6q": "A 6-qubit parameterized RY chain with 12 tunable angles.",
|
| 111 |
+
"hardware_efficient_4q": "4-qubit hardware-efficient ansatz (3 layers of RY+RZ+CX).",
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def _describe(qc: QuantumCircuit, key: str) -> str:
|
| 116 |
+
"""Curated one-liner if we have one, else a brief auto-generated fallback."""
|
| 117 |
+
if key in SAMPLE_DESCRIPTIONS:
|
| 118 |
+
return SAMPLE_DESCRIPTIONS[key]
|
| 119 |
+
return f"{qc.num_qubits}-qubit circuit, depth {qc.depth()}."
|
| 120 |
+
|
| 121 |
+
|
| 122 |
def discover_samples(sample_dir: Path = SAMPLE_CIRCUITS_DIR) -> list[SampleCircuit]:
|
| 123 |
"""Look up built-in demo circuits shipped in backend/sample_circuits/."""
|
| 124 |
if not sample_dir.exists():
|
|
|
|
| 133 |
SampleCircuit(
|
| 134 |
key=path.stem,
|
| 135 |
display_name=qc.name or path.stem,
|
| 136 |
+
description=_describe(qc, path.stem),
|
| 137 |
num_qubits=qc.num_qubits,
|
| 138 |
source="qpy",
|
| 139 |
)
|
|
@@ -54,7 +54,7 @@ def _default_label(node_type: str) -> str:
|
|
| 54 |
return {
|
| 55 |
"input_circuit": "Input circuit",
|
| 56 |
"ibm_backend": "IBM backend",
|
| 57 |
-
"fake_backend": "
|
| 58 |
"qucad": "QuCAD",
|
| 59 |
"qubound": "QuBound",
|
| 60 |
"compvqc": "CompressVQC",
|
|
@@ -167,8 +167,8 @@ def _handle_qubound(node: FlowNode, ctx: dict, settings: Settings) -> StepResult
|
|
| 167 |
|
| 168 |
Default path: load 14-day ibm_fez calibration history from the offline
|
| 169 |
pickle shipped in ``backend/cache/ibm_history/`` and train the LSTM
|
| 170 |
-
locally (~
|
| 171 |
-
credentials or network access.
|
| 172 |
|
| 173 |
Live path (``allow_live_ibm=True`` + token set): pull fresh history
|
| 174 |
from the IBM Quantum Platform API — accurate-as-of-today but slower
|
|
|
|
| 54 |
return {
|
| 55 |
"input_circuit": "Input circuit",
|
| 56 |
"ibm_backend": "IBM backend",
|
| 57 |
+
"fake_backend": "Noisy simulator",
|
| 58 |
"qucad": "QuCAD",
|
| 59 |
"qubound": "QuBound",
|
| 60 |
"compvqc": "CompressVQC",
|
|
|
|
| 167 |
|
| 168 |
Default path: load 14-day ibm_fez calibration history from the offline
|
| 169 |
pickle shipped in ``backend/cache/ibm_history/`` and train the LSTM
|
| 170 |
+
locally (~2 min on HF's shared CPU, a few seconds on a real GPU).
|
| 171 |
+
This lets the demo work without any IBM credentials or network access.
|
| 172 |
|
| 173 |
Live path (``allow_live_ibm=True`` + token set): pull fresh history
|
| 174 |
from the IBM Quantum Platform API — accurate-as-of-today but slower
|
|
Binary files a/backend/sample_circuits/efficient_su2_4q.qpy and b/backend/sample_circuits/efficient_su2_4q.qpy differ
|
|
|
|
Binary file (2.32 kB). View file
|
|
|
|
Binary files a/backend/sample_circuits/qaoa_maxcut_4.qpy and b/backend/sample_circuits/qaoa_maxcut_4.qpy differ
|
|
|
|
Binary file (540 Bytes). View file
|
|
|
|
Binary file (1.31 kB). View file
|
|
|
|
Binary files a/backend/sample_circuits/vqc_2q_small.qpy and b/backend/sample_circuits/vqc_2q_small.qpy differ
|
|
|
|
Binary file (509 Bytes). View file
|
|
|
|
@@ -76,20 +76,33 @@ export function CircuitPicker() {
|
|
| 76 |
<button
|
| 77 |
key={s.key}
|
| 78 |
onClick={() => pick(s.key)}
|
| 79 |
-
className={`w-full text-left px-2 py-1.5 rounded-md
|
| 80 |
active
|
| 81 |
-
? "bg-accent/10 border-accent/50
|
| 82 |
-
: "border-transparent hover:bg-surfaceAlt hover:border-edge
|
| 83 |
}`}
|
| 84 |
disabled={busy === s.key}
|
| 85 |
>
|
| 86 |
-
<
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
|
|
|
| 92 |
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
)}
|
| 94 |
</button>
|
| 95 |
);
|
|
|
|
| 76 |
<button
|
| 77 |
key={s.key}
|
| 78 |
onClick={() => pick(s.key)}
|
| 79 |
+
className={`w-full text-left px-2 py-1.5 rounded-md border transition-colors ${
|
| 80 |
active
|
| 81 |
+
? "bg-accent/10 border-accent/50"
|
| 82 |
+
: "border-transparent hover:bg-surfaceAlt hover:border-edge"
|
| 83 |
}`}
|
| 84 |
disabled={busy === s.key}
|
| 85 |
>
|
| 86 |
+
<div className="flex items-center justify-between gap-2">
|
| 87 |
+
<span
|
| 88 |
+
className={`truncate text-sm ${
|
| 89 |
+
active ? "text-ink" : "text-ink/90"
|
| 90 |
+
}`}
|
| 91 |
+
>
|
| 92 |
+
{s.display_name}
|
| 93 |
</span>
|
| 94 |
+
{busy === s.key ? (
|
| 95 |
+
<Loader2 className="w-3 h-3 animate-spin text-mute" />
|
| 96 |
+
) : (
|
| 97 |
+
<span className="text-[10px] font-mono text-mute shrink-0">
|
| 98 |
+
{s.num_qubits}q
|
| 99 |
+
</span>
|
| 100 |
+
)}
|
| 101 |
+
</div>
|
| 102 |
+
{s.description && (
|
| 103 |
+
<div className="text-[11px] text-mute leading-snug mt-0.5">
|
| 104 |
+
{s.description}
|
| 105 |
+
</div>
|
| 106 |
)}
|
| 107 |
</button>
|
| 108 |
);
|
|
@@ -30,7 +30,9 @@ export function NodePalette() {
|
|
| 30 |
|
| 31 |
<p className="text-[11px] text-mute/70 mt-4 leading-relaxed">
|
| 32 |
Drag a block onto the canvas. Connect right-handle to left-handle to define data
|
| 33 |
-
flow; run order is inferred by topological sort.
|
|
|
|
|
|
|
| 34 |
</p>
|
| 35 |
</div>
|
| 36 |
);
|
|
|
|
| 30 |
|
| 31 |
<p className="text-[11px] text-mute/70 mt-4 leading-relaxed">
|
| 32 |
Drag a block onto the canvas. Connect right-handle to left-handle to define data
|
| 33 |
+
flow; run order is inferred by topological sort. Hover a block on the canvas and
|
| 34 |
+
click the <span className="text-ink">×</span> to remove it (or press{" "}
|
| 35 |
+
<span className="kbd">Backspace</span> with a block selected).
|
| 36 |
</p>
|
| 37 |
</div>
|
| 38 |
);
|
|
@@ -1,4 +1,5 @@
|
|
| 1 |
-
import { Handle, Position, type NodeProps } from "@xyflow/react";
|
|
|
|
| 2 |
import { NODE_BY_KIND, type NodeKind } from "../lib/nodeCatalog";
|
| 3 |
|
| 4 |
export interface QNodeData extends Record<string, unknown> {
|
|
@@ -12,10 +13,14 @@ export interface QNodeData extends Record<string, unknown> {
|
|
| 12 |
* We deliberately keep each node simple (icon + label + 1-2 param hints) — the
|
| 13 |
* full parameter editor / results viewer lives in the ResultsPane on the
|
| 14 |
* right. Noisy per-node inline editors make the graph hard to read.
|
|
|
|
|
|
|
|
|
|
| 15 |
*/
|
| 16 |
-
export function QNode({ data, selected }: NodeProps) {
|
| 17 |
const d = data as QNodeData;
|
| 18 |
const spec = NODE_BY_KIND[d.kind];
|
|
|
|
| 19 |
if (!spec) return null;
|
| 20 |
const Icon = spec.icon;
|
| 21 |
|
|
@@ -24,10 +29,22 @@ export function QNode({ data, selected }: NodeProps) {
|
|
| 24 |
|
| 25 |
return (
|
| 26 |
<div
|
| 27 |
-
className={`node-card transition-colors ${
|
| 28 |
selected ? "shadow-glow !border-accent/60" : ""
|
| 29 |
} ${spec.accentRing}`}
|
| 30 |
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
<div className="flex items-center gap-2">
|
| 32 |
<span
|
| 33 |
className={`w-7 h-7 rounded-md border ${spec.accentRing} bg-surface flex items-center justify-center ${spec.accent} shrink-0`}
|
|
|
|
| 1 |
+
import { Handle, Position, useReactFlow, type NodeProps } from "@xyflow/react";
|
| 2 |
+
import { X } from "lucide-react";
|
| 3 |
import { NODE_BY_KIND, type NodeKind } from "../lib/nodeCatalog";
|
| 4 |
|
| 5 |
export interface QNodeData extends Record<string, unknown> {
|
|
|
|
| 13 |
* We deliberately keep each node simple (icon + label + 1-2 param hints) — the
|
| 14 |
* full parameter editor / results viewer lives in the ResultsPane on the
|
| 15 |
* right. Noisy per-node inline editors make the graph hard to read.
|
| 16 |
+
*
|
| 17 |
+
* A small × button appears on hover so users can delete a node without
|
| 18 |
+
* knowing the Backspace shortcut.
|
| 19 |
*/
|
| 20 |
+
export function QNode({ id, data, selected }: NodeProps) {
|
| 21 |
const d = data as QNodeData;
|
| 22 |
const spec = NODE_BY_KIND[d.kind];
|
| 23 |
+
const { deleteElements } = useReactFlow();
|
| 24 |
if (!spec) return null;
|
| 25 |
const Icon = spec.icon;
|
| 26 |
|
|
|
|
| 29 |
|
| 30 |
return (
|
| 31 |
<div
|
| 32 |
+
className={`node-card group relative transition-colors ${
|
| 33 |
selected ? "shadow-glow !border-accent/60" : ""
|
| 34 |
} ${spec.accentRing}`}
|
| 35 |
>
|
| 36 |
+
<button
|
| 37 |
+
type="button"
|
| 38 |
+
aria-label="Delete this block"
|
| 39 |
+
title="Delete this block"
|
| 40 |
+
className="nodrag absolute -top-2 -right-2 w-5 h-5 rounded-full bg-surface border border-edge text-mute hover:text-danger hover:border-danger/60 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10"
|
| 41 |
+
onClick={(e) => {
|
| 42 |
+
e.stopPropagation();
|
| 43 |
+
deleteElements({ nodes: [{ id }] });
|
| 44 |
+
}}
|
| 45 |
+
>
|
| 46 |
+
<X className="w-3 h-3" strokeWidth={2.5} />
|
| 47 |
+
</button>
|
| 48 |
<div className="flex items-center gap-2">
|
| 49 |
<span
|
| 50 |
className={`w-7 h-7 rounded-md border ${spec.accentRing} bg-surface flex items-center justify-center ${spec.accent} shrink-0`}
|
|
@@ -37,8 +37,9 @@ function EmptyHint() {
|
|
| 37 |
result card here — noise bounds, fidelity, compression stats, transpiled depth.
|
| 38 |
</p>
|
| 39 |
<p className="mt-2">
|
| 40 |
-
QuBound takes
|
| 41 |
-
calibration data). Other blocks are
|
|
|
|
| 42 |
</p>
|
| 43 |
</div>
|
| 44 |
);
|
|
@@ -52,7 +53,8 @@ function RunningHint() {
|
|
| 52 |
Executing pipeline…
|
| 53 |
</div>
|
| 54 |
<div className="mt-2 text-[11px] leading-relaxed">
|
| 55 |
-
QuBound training can take
|
|
|
|
| 56 |
</div>
|
| 57 |
</div>
|
| 58 |
);
|
|
@@ -101,29 +103,483 @@ function StepCard({ step }: { step: StepResult }) {
|
|
| 101 |
{step.message}
|
| 102 |
</div>
|
| 103 |
)}
|
| 104 |
-
{step.summary && Object.keys(step.summary).length > 0 && (
|
| 105 |
-
<
|
| 106 |
-
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
))}
|
| 109 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 110 |
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
</div>
|
| 112 |
);
|
| 113 |
}
|
| 114 |
|
| 115 |
-
|
| 116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
if (k === "diagram_text" && typeof v === "string") {
|
|
|
|
|
|
|
|
|
|
| 118 |
return (
|
| 119 |
-
<
|
| 120 |
-
<
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
</details>
|
| 127 |
);
|
| 128 |
}
|
| 129 |
if (typeof v === "object" && v !== null) {
|
|
@@ -161,25 +617,71 @@ function fmt(v: unknown): string {
|
|
| 161 |
return String(v);
|
| 162 |
}
|
| 163 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
function FinalMetrics({ metrics }: { metrics: Record<string, unknown> }) {
|
| 165 |
-
const
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
"
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
return (
|
| 174 |
<div className="panel p-3">
|
| 175 |
<div className="text-xs font-semibold uppercase tracking-wider text-mute mb-2">
|
| 176 |
Key metrics
|
| 177 |
</div>
|
| 178 |
<div className="grid grid-cols-2 gap-2">
|
| 179 |
-
{
|
| 180 |
-
<div key={
|
| 181 |
-
<div className="text-[10px] text-mute uppercase">{
|
| 182 |
-
<div className=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
</div>
|
| 184 |
))}
|
| 185 |
</div>
|
|
|
|
| 37 |
result card here — noise bounds, fidelity, compression stats, transpiled depth.
|
| 38 |
</p>
|
| 39 |
<p className="mt-2">
|
| 40 |
+
QuBound takes about 2 minutes on HF's shared CPU (training an LSTM
|
| 41 |
+
over 14 days of real IBM Fez calibration data). Other blocks are
|
| 42 |
+
near-instant.
|
| 43 |
</p>
|
| 44 |
</div>
|
| 45 |
);
|
|
|
|
| 53 |
Executing pipeline…
|
| 54 |
</div>
|
| 55 |
<div className="mt-2 text-[11px] leading-relaxed">
|
| 56 |
+
QuBound training can take about 2 minutes on HF's shared CPU.
|
| 57 |
+
Please don't close the tab.
|
| 58 |
</div>
|
| 59 |
</div>
|
| 60 |
);
|
|
|
|
| 103 |
{step.message}
|
| 104 |
</div>
|
| 105 |
)}
|
| 106 |
+
{step.status === "ok" && step.summary && Object.keys(step.summary).length > 0 && (
|
| 107 |
+
<StepBody step={step} />
|
| 108 |
+
)}
|
| 109 |
+
</div>
|
| 110 |
+
);
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
/** Dispatch the step summary to a node-type-specific card; fall back to generic rows. */
|
| 114 |
+
function StepBody({ step }: { step: StepResult }) {
|
| 115 |
+
const s = step.summary;
|
| 116 |
+
switch (step.node_type) {
|
| 117 |
+
case "qubound":
|
| 118 |
+
return <QuBoundCard s={s} />;
|
| 119 |
+
case "qucad":
|
| 120 |
+
return <QuCADCard s={s} />;
|
| 121 |
+
case "compvqc":
|
| 122 |
+
return <CompressVQCCard s={s} />;
|
| 123 |
+
case "fidelity":
|
| 124 |
+
return <FidelityCard s={s} />;
|
| 125 |
+
case "output":
|
| 126 |
+
return <OutputCard s={s} />;
|
| 127 |
+
case "input_circuit":
|
| 128 |
+
return <InputCircuitCard s={s} />;
|
| 129 |
+
case "fake_backend":
|
| 130 |
+
case "ibm_backend":
|
| 131 |
+
return <BackendCard s={s} />;
|
| 132 |
+
default:
|
| 133 |
+
return <GenericSummary s={s} />;
|
| 134 |
+
}
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
/* ========================================================================== */
|
| 138 |
+
/* Per-algorithm result cards */
|
| 139 |
+
/* ========================================================================== */
|
| 140 |
+
|
| 141 |
+
/** QuBound — predicted error bound in [0, 1] + lay explanation. */
|
| 142 |
+
function QuBoundCard({ s }: { s: Record<string, unknown> }) {
|
| 143 |
+
const raw = s["predicted_error_bound"];
|
| 144 |
+
const value = typeof raw === "number" ? raw : undefined;
|
| 145 |
+
const source = String(s["source"] ?? "");
|
| 146 |
+
|
| 147 |
+
return (
|
| 148 |
+
<div className="mt-2 space-y-2">
|
| 149 |
+
<Caption>
|
| 150 |
+
<span className="text-ink font-medium">What QuBound did:</span>{" "}
|
| 151 |
+
trained an LSTM on 14 days of chip calibration, then predicted how much
|
| 152 |
+
error today's noise would add to your circuit. Lower is better.
|
| 153 |
+
</Caption>
|
| 154 |
+
{value !== undefined && (
|
| 155 |
+
<div className="flex items-center gap-3">
|
| 156 |
+
<Gauge value={value} />
|
| 157 |
+
<div className="flex-1">
|
| 158 |
+
<div className="text-[10px] uppercase tracking-wider text-mute">
|
| 159 |
+
predicted error bound
|
| 160 |
+
</div>
|
| 161 |
+
<div className="font-mono text-ink text-lg">{value.toFixed(4)}</div>
|
| 162 |
+
<div className="text-[10px] text-mute">
|
| 163 |
+
{value < 0.05
|
| 164 |
+
? "very low — noise should barely matter"
|
| 165 |
+
: value < 0.15
|
| 166 |
+
? "moderate — noise will visibly affect outputs"
|
| 167 |
+
: "high — this circuit is likely noise-dominated on today's chip"}
|
| 168 |
+
</div>
|
| 169 |
+
</div>
|
| 170 |
+
</div>
|
| 171 |
+
)}
|
| 172 |
+
<details className="text-[11px] text-mute">
|
| 173 |
+
<summary className="cursor-pointer hover:text-ink">
|
| 174 |
+
run details ({source || "cached"})
|
| 175 |
+
</summary>
|
| 176 |
+
<div className="mt-1 pl-2 border-l border-edge space-y-0.5">
|
| 177 |
+
{Object.entries(s).map(([k, v]) => (
|
| 178 |
+
<KvRow key={k} k={k} v={v} />
|
| 179 |
))}
|
| 180 |
</div>
|
| 181 |
+
</details>
|
| 182 |
+
</div>
|
| 183 |
+
);
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
/** QuCAD — parameter sparsification. Show kept/total + sparsity trace. */
|
| 187 |
+
function QuCADCard({ s }: { s: Record<string, unknown> }) {
|
| 188 |
+
const original = numOr(s["original_parameters"], 0);
|
| 189 |
+
const kept = numOr(s["kept_parameters"], 0);
|
| 190 |
+
const trace = Array.isArray(s["sparsity_trace"])
|
| 191 |
+
? (s["sparsity_trace"] as number[])
|
| 192 |
+
: [];
|
| 193 |
+
const removed = original - kept;
|
| 194 |
+
const pct = original > 0 ? (removed / original) * 100 : 0;
|
| 195 |
+
|
| 196 |
+
return (
|
| 197 |
+
<div className="mt-2 space-y-2">
|
| 198 |
+
<Caption>
|
| 199 |
+
<span className="text-ink font-medium">What QuCAD did:</span>{" "}
|
| 200 |
+
sparsified the variational circuit, zeroing out parameters that hurt
|
| 201 |
+
fidelity under the chip's noise. Fewer parameters means fewer gates
|
| 202 |
+
to execute, which often means lower total error.
|
| 203 |
+
</Caption>
|
| 204 |
+
{original > 0 && (
|
| 205 |
+
<div className="grid grid-cols-3 gap-2">
|
| 206 |
+
<Stat label="kept" value={`${kept}`} sub={`of ${original}`} />
|
| 207 |
+
<Stat label="removed" value={`${removed}`} sub={`${pct.toFixed(0)}%`} />
|
| 208 |
+
<Stat
|
| 209 |
+
label="final loss"
|
| 210 |
+
value={numOr(s["final_loss"], NaN).toFixed(4)}
|
| 211 |
+
/>
|
| 212 |
+
</div>
|
| 213 |
+
)}
|
| 214 |
+
{trace.length > 1 && (
|
| 215 |
+
<div>
|
| 216 |
+
<div className="text-[10px] uppercase tracking-wider text-mute mb-1">
|
| 217 |
+
sparsity per ADMM iteration (lower = more sparse)
|
| 218 |
+
</div>
|
| 219 |
+
<Sparkline data={trace} height={40} />
|
| 220 |
+
</div>
|
| 221 |
)}
|
| 222 |
+
<details className="text-[11px] text-mute">
|
| 223 |
+
<summary className="cursor-pointer hover:text-ink">raw summary</summary>
|
| 224 |
+
<div className="mt-1 pl-2 border-l border-edge space-y-0.5">
|
| 225 |
+
{Object.entries(s).map(([k, v]) => (
|
| 226 |
+
<KvRow key={k} k={k} v={v} />
|
| 227 |
+
))}
|
| 228 |
+
</div>
|
| 229 |
+
</details>
|
| 230 |
</div>
|
| 231 |
);
|
| 232 |
}
|
| 233 |
|
| 234 |
+
/** CompressVQC — depth before vs after, gates removed. */
|
| 235 |
+
function CompressVQCCard({ s }: { s: Record<string, unknown> }) {
|
| 236 |
+
const before = numOr(s["original_depth"], 0);
|
| 237 |
+
const after = numOr(s["compressed_depth"], before);
|
| 238 |
+
const removed = numOr(s["gates_removed"], 0);
|
| 239 |
+
const shrinkPct = before > 0 ? ((before - after) / before) * 100 : 0;
|
| 240 |
+
|
| 241 |
+
return (
|
| 242 |
+
<div className="mt-2 space-y-2">
|
| 243 |
+
<Caption>
|
| 244 |
+
<span className="text-ink font-medium">What CompressVQC did:</span>{" "}
|
| 245 |
+
folded redundant parametric rotations using a QAOA-optimized lookup
|
| 246 |
+
table. A shorter circuit runs faster and picks up less decoherence.
|
| 247 |
+
</Caption>
|
| 248 |
+
{before > 0 && (
|
| 249 |
+
<DepthCompare before={before} after={after} />
|
| 250 |
+
)}
|
| 251 |
+
<div className="grid grid-cols-2 gap-2">
|
| 252 |
+
<Stat label="gates removed" value={`${removed}`} />
|
| 253 |
+
<Stat label="depth reduction" value={`${shrinkPct.toFixed(0)}%`} />
|
| 254 |
+
</div>
|
| 255 |
+
<details className="text-[11px] text-mute">
|
| 256 |
+
<summary className="cursor-pointer hover:text-ink">raw summary</summary>
|
| 257 |
+
<div className="mt-1 pl-2 border-l border-edge space-y-0.5">
|
| 258 |
+
{Object.entries(s).map(([k, v]) => (
|
| 259 |
+
<KvRow key={k} k={k} v={v} />
|
| 260 |
+
))}
|
| 261 |
+
</div>
|
| 262 |
+
</details>
|
| 263 |
+
</div>
|
| 264 |
+
);
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
/** Fidelity — 0-1, higher is better. */
|
| 268 |
+
function FidelityCard({ s }: { s: Record<string, unknown> }) {
|
| 269 |
+
const f = numOr(s["fidelity"], NaN);
|
| 270 |
+
const good = f >= 0.95;
|
| 271 |
+
const mid = f >= 0.8 && f < 0.95;
|
| 272 |
+
const tone = good ? "text-ok" : mid ? "text-warn" : "text-danger";
|
| 273 |
+
|
| 274 |
+
return (
|
| 275 |
+
<div className="mt-2 space-y-2">
|
| 276 |
+
<Caption>
|
| 277 |
+
<span className="text-ink font-medium">What this measures:</span>{" "}
|
| 278 |
+
how close the noisy circuit's output distribution is to the ideal
|
| 279 |
+
(noiseless) one. 1.0 is perfect; 0 is unrelated.
|
| 280 |
+
</Caption>
|
| 281 |
+
{Number.isFinite(f) && (
|
| 282 |
+
<div className="flex items-center gap-3">
|
| 283 |
+
<Gauge value={f} inverted />
|
| 284 |
+
<div className="flex-1">
|
| 285 |
+
<div className="text-[10px] uppercase tracking-wider text-mute">
|
| 286 |
+
estimated fidelity
|
| 287 |
+
</div>
|
| 288 |
+
<div className={`font-mono text-lg ${tone}`}>
|
| 289 |
+
{(f * 100).toFixed(2)}%
|
| 290 |
+
</div>
|
| 291 |
+
<div className="text-[10px] text-mute">
|
| 292 |
+
{good
|
| 293 |
+
? "very close to ideal"
|
| 294 |
+
: mid
|
| 295 |
+
? "noticeable noise, but usable"
|
| 296 |
+
: "heavily degraded by noise"}
|
| 297 |
+
</div>
|
| 298 |
+
</div>
|
| 299 |
+
</div>
|
| 300 |
+
)}
|
| 301 |
+
</div>
|
| 302 |
+
);
|
| 303 |
+
}
|
| 304 |
+
|
| 305 |
+
/** Output — depth, size, ops, diagram, transpiled stats. */
|
| 306 |
+
function OutputCard({ s }: { s: Record<string, unknown> }) {
|
| 307 |
+
const ops = (s["ops"] as Record<string, number> | undefined) ?? {};
|
| 308 |
+
const opEntries = Object.entries(ops).sort((a, b) => b[1] - a[1]);
|
| 309 |
+
const maxOp = opEntries.length > 0 ? opEntries[0][1] : 0;
|
| 310 |
+
const depth = numOr(s["depth"], 0);
|
| 311 |
+
const size = numOr(s["size"], 0);
|
| 312 |
+
const transpiled = numOr(s["transpiled_depth"], NaN);
|
| 313 |
+
const diagram = typeof s["diagram_text"] === "string" ? (s["diagram_text"] as string) : "";
|
| 314 |
+
|
| 315 |
+
return (
|
| 316 |
+
<div className="mt-2 space-y-2">
|
| 317 |
+
<Caption>
|
| 318 |
+
<span className="text-ink font-medium">Final circuit:</span> what
|
| 319 |
+
actually runs after every upstream block has had its say.
|
| 320 |
+
</Caption>
|
| 321 |
+
<div className="grid grid-cols-3 gap-2">
|
| 322 |
+
<Stat label="depth" value={`${depth}`} />
|
| 323 |
+
<Stat label="size" value={`${size}`} sub="total gates" />
|
| 324 |
+
<Stat
|
| 325 |
+
label="transpiled depth"
|
| 326 |
+
value={Number.isFinite(transpiled) ? `${transpiled}` : "—"}
|
| 327 |
+
sub="on target chip"
|
| 328 |
+
/>
|
| 329 |
+
</div>
|
| 330 |
+
{opEntries.length > 0 && (
|
| 331 |
+
<div>
|
| 332 |
+
<div className="text-[10px] uppercase tracking-wider text-mute mb-1">
|
| 333 |
+
gate breakdown
|
| 334 |
+
</div>
|
| 335 |
+
<div className="space-y-0.5">
|
| 336 |
+
{opEntries.slice(0, 8).map(([name, count]) => (
|
| 337 |
+
<OpBar key={name} name={name} count={count} max={maxOp} />
|
| 338 |
+
))}
|
| 339 |
+
</div>
|
| 340 |
+
</div>
|
| 341 |
+
)}
|
| 342 |
+
{diagram && (
|
| 343 |
+
<details className="text-[11px]">
|
| 344 |
+
<summary className="cursor-pointer text-mute hover:text-ink">
|
| 345 |
+
ASCII circuit diagram
|
| 346 |
+
</summary>
|
| 347 |
+
<pre className="mt-1 font-mono text-[10px] leading-tight p-2 bg-canvas/60 border border-edge rounded overflow-x-auto text-ink">
|
| 348 |
+
{diagram}
|
| 349 |
+
</pre>
|
| 350 |
+
</details>
|
| 351 |
+
)}
|
| 352 |
+
</div>
|
| 353 |
+
);
|
| 354 |
+
}
|
| 355 |
+
|
| 356 |
+
/** Input circuit summary (diagram + counts). */
|
| 357 |
+
function InputCircuitCard({ s }: { s: Record<string, unknown> }) {
|
| 358 |
+
return (
|
| 359 |
+
<div className="mt-2 space-y-2">
|
| 360 |
+
<div className="grid grid-cols-3 gap-2">
|
| 361 |
+
<Stat label="qubits" value={`${numOr(s["num_qubits"], 0)}`} />
|
| 362 |
+
<Stat label="depth" value={`${numOr(s["depth"], 0)}`} />
|
| 363 |
+
<Stat label="params" value={`${numOr(s["num_parameters"], 0)}`} />
|
| 364 |
+
</div>
|
| 365 |
+
{typeof s["diagram_text"] === "string" && (
|
| 366 |
+
<details className="text-[11px]">
|
| 367 |
+
<summary className="cursor-pointer text-mute hover:text-ink">
|
| 368 |
+
ASCII circuit diagram
|
| 369 |
+
</summary>
|
| 370 |
+
<pre className="mt-1 font-mono text-[10px] leading-tight p-2 bg-canvas/60 border border-edge rounded overflow-x-auto text-ink">
|
| 371 |
+
{s["diagram_text"] as string}
|
| 372 |
+
</pre>
|
| 373 |
+
</details>
|
| 374 |
+
)}
|
| 375 |
+
</div>
|
| 376 |
+
);
|
| 377 |
+
}
|
| 378 |
+
|
| 379 |
+
/** Backend card — minimal info. */
|
| 380 |
+
function BackendCard({ s }: { s: Record<string, unknown> }) {
|
| 381 |
+
const name = String(s["backend_name"] ?? "");
|
| 382 |
+
return (
|
| 383 |
+
<div className="mt-2 text-[11px] text-mute">
|
| 384 |
+
{name && (
|
| 385 |
+
<div>
|
| 386 |
+
backend: <span className="font-mono text-ink">{name}</span>
|
| 387 |
+
</div>
|
| 388 |
+
)}
|
| 389 |
+
{s["live"] === true && (
|
| 390 |
+
<div className="text-warn">live IBM calibration</div>
|
| 391 |
+
)}
|
| 392 |
+
{s["fallback"] != null && (
|
| 393 |
+
<div>
|
| 394 |
+
fallback: <span className="font-mono text-ink">{String(s["fallback"])}</span>
|
| 395 |
+
</div>
|
| 396 |
+
)}
|
| 397 |
+
</div>
|
| 398 |
+
);
|
| 399 |
+
}
|
| 400 |
+
|
| 401 |
+
/** Generic fallback — the previous flat k/v list. */
|
| 402 |
+
function GenericSummary({ s }: { s: Record<string, unknown> }) {
|
| 403 |
+
return (
|
| 404 |
+
<div className="mt-2 space-y-1">
|
| 405 |
+
{Object.entries(s).map(([k, v]) => (
|
| 406 |
+
<KvRow key={k} k={k} v={v} />
|
| 407 |
+
))}
|
| 408 |
+
</div>
|
| 409 |
+
);
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
/* ========================================================================== */
|
| 413 |
+
/* Shared viz primitives */
|
| 414 |
+
/* ========================================================================== */
|
| 415 |
+
|
| 416 |
+
/** A big-number stat tile used in the per-algorithm cards. */
|
| 417 |
+
function Stat({ label, value, sub }: { label: string; value: string; sub?: string }) {
|
| 418 |
+
return (
|
| 419 |
+
<div className="panel px-2 py-1.5 text-center">
|
| 420 |
+
<div className="text-[10px] uppercase tracking-wider text-mute">{label}</div>
|
| 421 |
+
<div className="font-mono text-ink text-sm leading-tight">{value}</div>
|
| 422 |
+
{sub && <div className="text-[10px] text-mute leading-tight">{sub}</div>}
|
| 423 |
+
</div>
|
| 424 |
+
);
|
| 425 |
+
}
|
| 426 |
+
|
| 427 |
+
/** Plain-language caption sitting above the numbers. */
|
| 428 |
+
function Caption({ children }: { children: React.ReactNode }) {
|
| 429 |
+
return (
|
| 430 |
+
<p className="text-[11px] text-mute leading-relaxed">{children}</p>
|
| 431 |
+
);
|
| 432 |
+
}
|
| 433 |
+
|
| 434 |
+
/**
|
| 435 |
+
* A horizontal meter from 0 to 1.
|
| 436 |
+
*
|
| 437 |
+
* - default (`inverted=false`): low values are green ("low error is good"
|
| 438 |
+
* for QuBound), high values are red.
|
| 439 |
+
* - `inverted`: high values are green ("high fidelity is good").
|
| 440 |
+
*/
|
| 441 |
+
function Gauge({ value, inverted = false }: { value: number; inverted?: boolean }) {
|
| 442 |
+
const v = Math.max(0, Math.min(1, value));
|
| 443 |
+
const pct = v * 100;
|
| 444 |
+
// Color bands.
|
| 445 |
+
const good = inverted ? v >= 0.95 : v < 0.05;
|
| 446 |
+
const mid = inverted ? v >= 0.8 && v < 0.95 : v >= 0.05 && v < 0.15;
|
| 447 |
+
const color = good
|
| 448 |
+
? "var(--color-ok, #2dd4bf)"
|
| 449 |
+
: mid
|
| 450 |
+
? "var(--color-warn, #f4a261)"
|
| 451 |
+
: "var(--color-danger, #f72585)";
|
| 452 |
+
return (
|
| 453 |
+
<div className="w-32 shrink-0">
|
| 454 |
+
<div className="relative h-2.5 w-full rounded-full bg-canvas border border-edge overflow-hidden">
|
| 455 |
+
<div
|
| 456 |
+
className="absolute inset-y-0 left-0"
|
| 457 |
+
style={{ width: `${pct}%`, background: color }}
|
| 458 |
+
/>
|
| 459 |
+
</div>
|
| 460 |
+
<div className="flex justify-between text-[9px] text-mute mt-0.5 font-mono">
|
| 461 |
+
<span>0</span>
|
| 462 |
+
<span>1</span>
|
| 463 |
+
</div>
|
| 464 |
+
</div>
|
| 465 |
+
);
|
| 466 |
+
}
|
| 467 |
+
|
| 468 |
+
/** Compact comparison of two integer values as side-by-side proportional bars. */
|
| 469 |
+
function DepthCompare({ before, after }: { before: number; after: number }) {
|
| 470 |
+
const max = Math.max(before, after, 1);
|
| 471 |
+
return (
|
| 472 |
+
<div className="space-y-1">
|
| 473 |
+
<CompareBar label="before" value={before} max={max} tone="mute" />
|
| 474 |
+
<CompareBar label="after" value={after} max={max} tone="ok" />
|
| 475 |
+
</div>
|
| 476 |
+
);
|
| 477 |
+
}
|
| 478 |
+
|
| 479 |
+
function CompareBar({
|
| 480 |
+
label,
|
| 481 |
+
value,
|
| 482 |
+
max,
|
| 483 |
+
tone,
|
| 484 |
+
}: {
|
| 485 |
+
label: string;
|
| 486 |
+
value: number;
|
| 487 |
+
max: number;
|
| 488 |
+
tone: "ok" | "mute";
|
| 489 |
+
}) {
|
| 490 |
+
const pct = max > 0 ? (value / max) * 100 : 0;
|
| 491 |
+
const bg =
|
| 492 |
+
tone === "ok"
|
| 493 |
+
? "bg-ok/70"
|
| 494 |
+
: "bg-mute/40";
|
| 495 |
+
return (
|
| 496 |
+
<div className="flex items-center gap-2 text-[11px]">
|
| 497 |
+
<div className="w-14 text-mute shrink-0">{label}</div>
|
| 498 |
+
<div className="flex-1 h-3 rounded bg-canvas border border-edge overflow-hidden relative">
|
| 499 |
+
<div className={`h-full ${bg}`} style={{ width: `${pct}%` }} />
|
| 500 |
+
</div>
|
| 501 |
+
<div className="w-10 text-right font-mono text-ink">{value}</div>
|
| 502 |
+
</div>
|
| 503 |
+
);
|
| 504 |
+
}
|
| 505 |
+
|
| 506 |
+
/** Horizontal bar for a single gate count. */
|
| 507 |
+
function OpBar({ name, count, max }: { name: string; count: number; max: number }) {
|
| 508 |
+
const pct = max > 0 ? (count / max) * 100 : 0;
|
| 509 |
+
return (
|
| 510 |
+
<div className="flex items-center gap-2 text-[11px]">
|
| 511 |
+
<div className="w-14 text-mute font-mono truncate shrink-0">{name}</div>
|
| 512 |
+
<div className="flex-1 h-2 rounded bg-canvas border border-edge overflow-hidden">
|
| 513 |
+
<div className="h-full bg-accent/50" style={{ width: `${pct}%` }} />
|
| 514 |
+
</div>
|
| 515 |
+
<div className="w-8 text-right font-mono text-ink">{count}</div>
|
| 516 |
+
</div>
|
| 517 |
+
);
|
| 518 |
+
}
|
| 519 |
+
|
| 520 |
+
/** Tiny SVG sparkline. Data assumed to be non-negative integers. */
|
| 521 |
+
function Sparkline({ data, height = 32 }: { data: number[]; height?: number }) {
|
| 522 |
+
if (data.length < 2) return null;
|
| 523 |
+
const w = 200;
|
| 524 |
+
const h = height;
|
| 525 |
+
const max = Math.max(...data, 1);
|
| 526 |
+
const min = Math.min(...data, 0);
|
| 527 |
+
const range = Math.max(max - min, 1);
|
| 528 |
+
const pts = data
|
| 529 |
+
.map((v, i) => {
|
| 530 |
+
const x = (i / (data.length - 1)) * (w - 4) + 2;
|
| 531 |
+
const y = h - 2 - ((v - min) / range) * (h - 4);
|
| 532 |
+
return `${x.toFixed(1)},${y.toFixed(1)}`;
|
| 533 |
+
})
|
| 534 |
+
.join(" ");
|
| 535 |
+
return (
|
| 536 |
+
<svg
|
| 537 |
+
viewBox={`0 0 ${w} ${h}`}
|
| 538 |
+
className="w-full h-auto"
|
| 539 |
+
preserveAspectRatio="none"
|
| 540 |
+
>
|
| 541 |
+
<polyline
|
| 542 |
+
points={pts}
|
| 543 |
+
fill="none"
|
| 544 |
+
stroke="currentColor"
|
| 545 |
+
strokeWidth={1.5}
|
| 546 |
+
className="text-accent2"
|
| 547 |
+
/>
|
| 548 |
+
{data.map((v, i) => {
|
| 549 |
+
const x = (i / (data.length - 1)) * (w - 4) + 2;
|
| 550 |
+
const y = h - 2 - ((v - min) / range) * (h - 4);
|
| 551 |
+
return (
|
| 552 |
+
<circle
|
| 553 |
+
key={i}
|
| 554 |
+
cx={x}
|
| 555 |
+
cy={y}
|
| 556 |
+
r={2}
|
| 557 |
+
fill="currentColor"
|
| 558 |
+
className="text-accent2"
|
| 559 |
+
/>
|
| 560 |
+
);
|
| 561 |
+
})}
|
| 562 |
+
</svg>
|
| 563 |
+
);
|
| 564 |
+
}
|
| 565 |
+
|
| 566 |
+
/* ========================================================================== */
|
| 567 |
+
/* Generic row helpers */
|
| 568 |
+
/* ========================================================================== */
|
| 569 |
+
|
| 570 |
+
function KvRow({ k, v }: { k: string; v: unknown }) {
|
| 571 |
if (k === "diagram_text" && typeof v === "string") {
|
| 572 |
+
return null; // handled by dedicated card
|
| 573 |
+
}
|
| 574 |
+
if (Array.isArray(v)) {
|
| 575 |
return (
|
| 576 |
+
<div className="flex justify-between items-center gap-2 text-[11px]">
|
| 577 |
+
<span className="text-mute">{k}</span>
|
| 578 |
+
<span className="font-mono text-ink truncate max-w-[60%] text-right">
|
| 579 |
+
[{v.slice(0, 6).map(String).join(", ")}
|
| 580 |
+
{v.length > 6 ? ", …" : ""}]
|
| 581 |
+
</span>
|
| 582 |
+
</div>
|
|
|
|
| 583 |
);
|
| 584 |
}
|
| 585 |
if (typeof v === "object" && v !== null) {
|
|
|
|
| 617 |
return String(v);
|
| 618 |
}
|
| 619 |
|
| 620 |
+
function numOr(v: unknown, fallback: number): number {
|
| 621 |
+
return typeof v === "number" && Number.isFinite(v) ? v : fallback;
|
| 622 |
+
}
|
| 623 |
+
|
| 624 |
+
/* ========================================================================== */
|
| 625 |
+
/* Final metrics */
|
| 626 |
+
/* ========================================================================== */
|
| 627 |
+
|
| 628 |
function FinalMetrics({ metrics }: { metrics: Record<string, unknown> }) {
|
| 629 |
+
const items: { key: string; label: string; help: string; big: string; tone?: string }[] = [];
|
| 630 |
+
|
| 631 |
+
if (typeof metrics["qubound_error_bound"] === "number") {
|
| 632 |
+
const v = metrics["qubound_error_bound"] as number;
|
| 633 |
+
items.push({
|
| 634 |
+
key: "qubound_error_bound",
|
| 635 |
+
label: "predicted error bound",
|
| 636 |
+
help: "How much error QuBound expects today's noise to add. Lower is better.",
|
| 637 |
+
big: v.toFixed(4),
|
| 638 |
+
tone: v < 0.05 ? "text-ok" : v < 0.15 ? "text-warn" : "text-danger",
|
| 639 |
+
});
|
| 640 |
+
}
|
| 641 |
+
if (typeof metrics["fidelity"] === "number") {
|
| 642 |
+
const v = metrics["fidelity"] as number;
|
| 643 |
+
items.push({
|
| 644 |
+
key: "fidelity",
|
| 645 |
+
label: "fidelity",
|
| 646 |
+
help: "Similarity between noisy and ideal output. Higher is better.",
|
| 647 |
+
big: `${(v * 100).toFixed(2)}%`,
|
| 648 |
+
tone: v >= 0.95 ? "text-ok" : v >= 0.8 ? "text-warn" : "text-danger",
|
| 649 |
+
});
|
| 650 |
+
}
|
| 651 |
+
if (typeof metrics["transpiled_depth"] === "number") {
|
| 652 |
+
items.push({
|
| 653 |
+
key: "transpiled_depth",
|
| 654 |
+
label: "transpiled depth",
|
| 655 |
+
help: "Circuit depth after compiling for the target chip's gate set.",
|
| 656 |
+
big: String(metrics["transpiled_depth"]),
|
| 657 |
+
});
|
| 658 |
+
}
|
| 659 |
+
if (typeof metrics["gates_removed"] === "number") {
|
| 660 |
+
items.push({
|
| 661 |
+
key: "gates_removed",
|
| 662 |
+
label: "gates removed",
|
| 663 |
+
help: "How many redundant rotations CompressVQC folded away.",
|
| 664 |
+
big: String(metrics["gates_removed"]),
|
| 665 |
+
});
|
| 666 |
+
}
|
| 667 |
+
|
| 668 |
+
if (items.length === 0) return null;
|
| 669 |
+
|
| 670 |
return (
|
| 671 |
<div className="panel p-3">
|
| 672 |
<div className="text-xs font-semibold uppercase tracking-wider text-mute mb-2">
|
| 673 |
Key metrics
|
| 674 |
</div>
|
| 675 |
<div className="grid grid-cols-2 gap-2">
|
| 676 |
+
{items.map((m) => (
|
| 677 |
+
<div key={m.key} className="panel-alt p-2">
|
| 678 |
+
<div className="text-[10px] text-mute uppercase">{m.label}</div>
|
| 679 |
+
<div className={`font-mono text-lg ${m.tone ?? "text-ink"}`}>
|
| 680 |
+
{m.big}
|
| 681 |
+
</div>
|
| 682 |
+
<div className="text-[10px] text-mute leading-snug mt-0.5">
|
| 683 |
+
{m.help}
|
| 684 |
+
</div>
|
| 685 |
</div>
|
| 686 |
))}
|
| 687 |
</div>
|
|
@@ -592,7 +592,7 @@ function PipelineSVG() {
|
|
| 592 |
))}
|
| 593 |
|
| 594 |
<PipelineNode x={20} y={40} color="#4cc9f0" label="Circuit" sub="SOURCE" kind="circuit" />
|
| 595 |
-
<PipelineNode x={190} y={40} color="#4cc9f0" label="
|
| 596 |
<PipelineNode x={360} y={40} color="#f72585" label="QuBound" sub="ALGORITHM" kind="algo" />
|
| 597 |
<PipelineNode x={530} y={40} color="#e6ebff" label="Output" sub="SINK" kind="out" />
|
| 598 |
</svg>
|
|
@@ -696,10 +696,11 @@ function TrySlide() {
|
|
| 696 |
A default pipeline is already loaded.
|
| 697 |
</h2>
|
| 698 |
<p className="text-mute text-sm">
|
| 699 |
-
Pick one of the
|
| 700 |
<span className="kbd">Run pipeline</span> in the canvas toolbar. The
|
| 701 |
-
first run trains an LSTM on 14 days of calibration
|
| 702 |
-
|
|
|
|
| 703 |
</p>
|
| 704 |
</div>
|
| 705 |
|
|
|
|
| 592 |
))}
|
| 593 |
|
| 594 |
<PipelineNode x={20} y={40} color="#4cc9f0" label="Circuit" sub="SOURCE" kind="circuit" />
|
| 595 |
+
<PipelineNode x={190} y={40} color="#4cc9f0" label="Noisy simulator" sub="BACKEND" kind="backend" />
|
| 596 |
<PipelineNode x={360} y={40} color="#f72585" label="QuBound" sub="ALGORITHM" kind="algo" />
|
| 597 |
<PipelineNode x={530} y={40} color="#e6ebff" label="Output" sub="SINK" kind="out" />
|
| 598 |
</svg>
|
|
|
|
| 696 |
A default pipeline is already loaded.
|
| 697 |
</h2>
|
| 698 |
<p className="text-mute text-sm">
|
| 699 |
+
Pick one of the sample circuits on the left, then hit{" "}
|
| 700 |
<span className="kbd">Run pipeline</span> in the canvas toolbar. The
|
| 701 |
+
first run trains an LSTM on 14 days of calibration, so plan for
|
| 702 |
+
about two minutes on the shared HF CPU. Don't close the tab while
|
| 703 |
+
it's running.
|
| 704 |
</p>
|
| 705 |
</div>
|
| 706 |
|
|
@@ -48,9 +48,10 @@ export const NODE_CATALOG: NodeSpec[] = [
|
|
| 48 |
},
|
| 49 |
{
|
| 50 |
kind: "fake_backend",
|
| 51 |
-
label: "
|
| 52 |
family: "backend",
|
| 53 |
-
description:
|
|
|
|
| 54 |
icon: Server,
|
| 55 |
accent: "text-accent",
|
| 56 |
accentRing: "border-accent/40",
|
|
|
|
| 48 |
},
|
| 49 |
{
|
| 50 |
kind: "fake_backend",
|
| 51 |
+
label: "Noisy simulator",
|
| 52 |
family: "backend",
|
| 53 |
+
description:
|
| 54 |
+
"Simulates a real IBM quantum chip with its measured noise. Runs locally, no IBM account needed.",
|
| 55 |
icon: Server,
|
| 56 |
accent: "text-accent",
|
| 57 |
accentRing: "border-accent/40",
|
|
@@ -91,12 +91,92 @@ def ghz_3q() -> QuantumCircuit:
|
|
| 91 |
return qc
|
| 92 |
|
| 93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
BUILDERS = [
|
| 95 |
bell_state,
|
| 96 |
ghz_3q,
|
|
|
|
| 97 |
vqc_2q_small,
|
| 98 |
-
|
| 99 |
qaoa_maxcut_4,
|
|
|
|
|
|
|
|
|
|
| 100 |
]
|
| 101 |
|
| 102 |
|
|
|
|
| 91 |
return qc
|
| 92 |
|
| 93 |
|
| 94 |
+
def w_state_3q() -> QuantumCircuit:
|
| 95 |
+
"""3-qubit W state.
|
| 96 |
+
|
| 97 |
+
W-state entanglement is robust to qubit loss; a didactic contrast to
|
| 98 |
+
GHZ. Built via the standard RY + controlled-RY + CX construction.
|
| 99 |
+
"""
|
| 100 |
+
qc = QuantumCircuit(3, name="w_state_3q")
|
| 101 |
+
theta0 = 2.0 * np.arccos(1.0 / np.sqrt(3.0))
|
| 102 |
+
qc.ry(theta0, 0)
|
| 103 |
+
qc.x(0)
|
| 104 |
+
qc.cry(2.0 * np.arccos(1.0 / np.sqrt(2.0)), 0, 1)
|
| 105 |
+
qc.x(0)
|
| 106 |
+
qc.cx(1, 2)
|
| 107 |
+
qc.cx(0, 1)
|
| 108 |
+
qc.x(0)
|
| 109 |
+
return qc
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
def qft_3q() -> QuantumCircuit:
|
| 113 |
+
"""3-qubit Quantum Fourier Transform.
|
| 114 |
+
|
| 115 |
+
Core building block of Shor, phase estimation, and many quantum signal
|
| 116 |
+
algorithms. Non-parameterized, so CompressVQC + Fidelity show clear
|
| 117 |
+
before/after results on it.
|
| 118 |
+
"""
|
| 119 |
+
qc = QuantumCircuit(3, name="qft_3q")
|
| 120 |
+
qc.h(0)
|
| 121 |
+
qc.cp(np.pi / 2, 0, 1)
|
| 122 |
+
qc.cp(np.pi / 4, 0, 2)
|
| 123 |
+
qc.h(1)
|
| 124 |
+
qc.cp(np.pi / 2, 1, 2)
|
| 125 |
+
qc.h(2)
|
| 126 |
+
qc.swap(0, 2)
|
| 127 |
+
return qc
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
def ry_chain_6q() -> QuantumCircuit:
|
| 131 |
+
"""6-qubit RY chain — a bigger VQC for QuCAD to sparsify.
|
| 132 |
+
|
| 133 |
+
Two RY layers (12 params total) and a linear CX chain between them.
|
| 134 |
+
Gives QuCAD enough parameters that its sparsity trace moves visibly
|
| 135 |
+
over the 3 default ADMM iterations.
|
| 136 |
+
"""
|
| 137 |
+
qc = QuantumCircuit(6, name="ry_chain_6q")
|
| 138 |
+
params_a = [Parameter(f"a_{i}") for i in range(6)]
|
| 139 |
+
params_b = [Parameter(f"b_{i}") for i in range(6)]
|
| 140 |
+
for i, p in enumerate(params_a):
|
| 141 |
+
qc.ry(p, i)
|
| 142 |
+
for i in range(5):
|
| 143 |
+
qc.cx(i, i + 1)
|
| 144 |
+
for i, p in enumerate(params_b):
|
| 145 |
+
qc.ry(p, i)
|
| 146 |
+
return qc
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def hardware_efficient_4q() -> QuantumCircuit:
|
| 150 |
+
"""4-qubit hardware-efficient ansatz.
|
| 151 |
+
|
| 152 |
+
Three layers of RY+RZ on each qubit, interleaved with linear CX
|
| 153 |
+
entanglers. A classic warm-start ansatz for VQE / VQC on
|
| 154 |
+
superconducting hardware.
|
| 155 |
+
"""
|
| 156 |
+
qc = QuantumCircuit(4, name="hardware_efficient_4q")
|
| 157 |
+
layers = 3
|
| 158 |
+
for L in range(layers):
|
| 159 |
+
for q in range(4):
|
| 160 |
+
qc.ry(Parameter(f"ry_{L}_{q}"), q)
|
| 161 |
+
qc.rz(Parameter(f"rz_{L}_{q}"), q)
|
| 162 |
+
if L < layers - 1:
|
| 163 |
+
for i in range(3):
|
| 164 |
+
qc.cx(i, i + 1)
|
| 165 |
+
return qc
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
# Ordered from smallest/simplest (top of list) to largest — this is the
|
| 169 |
+
# order the circuit picker displays in the UI.
|
| 170 |
BUILDERS = [
|
| 171 |
bell_state,
|
| 172 |
ghz_3q,
|
| 173 |
+
w_state_3q,
|
| 174 |
vqc_2q_small,
|
| 175 |
+
qft_3q,
|
| 176 |
qaoa_maxcut_4,
|
| 177 |
+
vqc_efficient_su2_4q,
|
| 178 |
+
hardware_efficient_4q,
|
| 179 |
+
ry_chain_6q,
|
| 180 |
]
|
| 181 |
|
| 182 |
|