Neutralise dev-process metadata in code comments
Browse filesEarlier audits caught keyword-level leaks (tokens, paths, emails). This
pass goes one level up: comments throughout the codebase narrated the
project's history — "Jovin's Streamlit prototype", "the handover
snapshot", "Jovin's old prototype's flowChartProto", "Batch 2
circuits", etc. — which read like internal team notes rather than
product code, and exposed the development trajectory (research handover
→ rewrite → packaging) to anyone reading the public repo.
Replaced or trimmed the offending comments while keeping legitimate
attribution (e.g., "author: Tong Li" in qshot/__init__.py docstring).
No behavior change: docstrings + line comments only.
Files touched:
- qlib/qiskit_utils.py – module docstring rewritten
- qlib/qucad.py – default-config attribution generalised
- qlib/compvqc.py – "the original prototype did..." → factual
- qlib/qshot/__init__.py – "handover snapshot" → "reference code"
- app/services/workflow_service.py – Qshot docstring de-narrated
- app/services/circuit_service.py – stray "Batch 2 circuits:" deleted
- app/routes/backends.py – fake-backend list comment clarified
- scripts/generate_sample_circuits.py – test-circuit docstring
- frontend/src/lib/autoConnect.ts – two comments lose flowChartProto
+ "Jovin's old prototype" refs
Out of scope: backend/qlib/qshot/recommend_shots_v4.py contains "research
repo layout / handover package layout" wording in its own runtime error
strings. That file is Tong Li's upstream code, intentionally vendored
unmodified, so leaving it as-is.
- backend/app/routes/backends.py +2 -1
- backend/app/services/circuit_service.py +0 -1
- backend/app/services/workflow_service.py +2 -2
- backend/qlib/compvqc.py +5 -5
- backend/qlib/qiskit_utils.py +5 -8
- backend/qlib/qshot/__init__.py +4 -4
- backend/qlib/qucad.py +2 -1
- frontend/src/lib/autoConnect.ts +3 -4
- scripts/generate_sample_circuits.py +1 -1
|
@@ -10,7 +10,8 @@ from app.schemas import BackendInfo
|
|
| 10 |
router = APIRouter()
|
| 11 |
|
| 12 |
|
| 13 |
-
# Static list of the three fake backends
|
|
|
|
| 14 |
_FAKE_BACKENDS: list[dict] = [
|
| 15 |
{
|
| 16 |
"name": "FakeFez",
|
|
|
|
| 10 |
router = APIRouter()
|
| 11 |
|
| 12 |
|
| 13 |
+
# Static list of the three Heron-family fake backends supported by the
|
| 14 |
+
# `_load_fake_backend` helper in workflow_service.
|
| 15 |
_FAKE_BACKENDS: list[dict] = [
|
| 16 |
{
|
| 17 |
"name": "FakeFez",
|
|
@@ -104,7 +104,6 @@ SAMPLE_DESCRIPTIONS: dict[str, str] = {
|
|
| 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.",
|
|
|
|
| 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 |
"w_state_3q": "Another way to entangle 3 qubits: a W state.",
|
| 108 |
"qft_3q": "3-qubit Quantum Fourier Transform, a core building block of many algorithms.",
|
| 109 |
"ry_chain_6q": "A 6-qubit parameterized RY chain with 12 tunable angles.",
|
|
@@ -278,8 +278,8 @@ def _handle_compvqc(node: FlowNode, ctx: dict, _settings: Settings) -> StepResul
|
|
| 278 |
def _handle_qshot(node: FlowNode, ctx: dict, _settings: Settings) -> StepResult:
|
| 279 |
"""Qshot — noise-aware shot-count recommender.
|
| 280 |
|
| 281 |
-
Qshot is self-contained by design
|
| 282 |
-
|
| 283 |
calibration data through a bundled noise JSON. So this handler
|
| 284 |
ignores any upstream `ctx["backend"]`; the user steers noise via
|
| 285 |
the node's ``noise_snapshot`` parameter.
|
|
|
|
| 278 |
def _handle_qshot(node: FlowNode, ctx: dict, _settings: Settings) -> StepResult:
|
| 279 |
"""Qshot — noise-aware shot-count recommender.
|
| 280 |
|
| 281 |
+
Qshot is self-contained by design: the recommender picks its own
|
| 282 |
+
`AerSimulator`, runs its own transpile pass, and consumes
|
| 283 |
calibration data through a bundled noise JSON. So this handler
|
| 284 |
ignores any upstream `ctx["backend"]`; the user steers noise via
|
| 285 |
the node's ``noise_snapshot`` parameter.
|
|
@@ -228,11 +228,11 @@ def resultsCompressVQC(result: SimpleNamespace, original_qc: QuantumCircuit) ->
|
|
| 228 |
compressed_qc.append(new_gate, qargs, cargs)
|
| 229 |
|
| 230 |
# NOTE: we deliberately do NOT transpile the compressed circuit
|
| 231 |
-
# here.
|
| 232 |
-
#
|
| 233 |
-
#
|
| 234 |
-
#
|
| 235 |
-
#
|
| 236 |
return compressed_qc
|
| 237 |
|
| 238 |
|
|
|
|
| 228 |
compressed_qc.append(new_gate, qargs, cargs)
|
| 229 |
|
| 230 |
# NOTE: we deliberately do NOT transpile the compressed circuit
|
| 231 |
+
# here. Doing the obvious ``transpile(..., basis_gates=['sx', 'rz',
|
| 232 |
+
# 'cx', 'id'], optimization_level=3)`` would move the compression
|
| 233 |
+
# benefit into the transpiler's pocket and make before/after
|
| 234 |
+
# comparisons confusing. The service layer handles backend-specific
|
| 235 |
+
# transpilation at the point where it's needed.
|
| 236 |
return compressed_qc
|
| 237 |
|
| 238 |
|
|
@@ -1,15 +1,12 @@
|
|
| 1 |
"""Small Qiskit helpers used by the pipeline.
|
| 2 |
|
| 3 |
-
|
| 4 |
-
from Jovin's Streamlit prototype; most of them were superseded by the
|
| 5 |
-
FastAPI service layer (circuit loading lives in
|
| 6 |
-
``app/services/circuit_service.py``, transpilation is inlined at the
|
| 7 |
-
call site, and matplotlib drawing is never used in headless serving).
|
| 8 |
-
|
| 9 |
-
What remains is the one helper still consumed at runtime:
|
| 10 |
``simpleFidelityEstimator``, called from
|
| 11 |
``workflow_service._handle_fidelity`` to score the output circuit
|
| 12 |
-
against the all-zeros state.
|
|
|
|
|
|
|
|
|
|
| 13 |
"""
|
| 14 |
|
| 15 |
from __future__ import annotations
|
|
|
|
| 1 |
"""Small Qiskit helpers used by the pipeline.
|
| 2 |
|
| 3 |
+
Currently exports a single helper consumed at runtime:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
``simpleFidelityEstimator``, called from
|
| 5 |
``workflow_service._handle_fidelity`` to score the output circuit
|
| 6 |
+
against the all-zeros state. Other utilities that used to live here
|
| 7 |
+
were absorbed into the service layer (circuit loading in
|
| 8 |
+
``app/services/circuit_service.py``; transpilation inlined at the call
|
| 9 |
+
site; matplotlib drawing dropped, since serving is headless).
|
| 10 |
"""
|
| 11 |
|
| 12 |
from __future__ import annotations
|
|
@@ -1,9 +1,9 @@
|
|
| 1 |
"""Qshot — Noise-aware shot-count recommender.
|
| 2 |
|
| 3 |
-
Packaged version of the
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
construction cost.
|
| 8 |
|
| 9 |
Integration notes
|
|
|
|
| 1 |
"""Qshot — Noise-aware shot-count recommender.
|
| 2 |
|
| 3 |
+
Packaged version of the JQub lab's Qshot reference code (author: Tong
|
| 4 |
+
Li). Wraps `QshotRecommender` with a lazy-loaded singleton and a stable
|
| 5 |
+
registry of bundled noise snapshots so the backend's workflow service
|
| 6 |
+
can request a recommendation without worrying about paths or
|
| 7 |
construction cost.
|
| 8 |
|
| 9 |
Integration notes
|
|
@@ -43,7 +43,8 @@ QUCAD_DEFAULT_ITERATIONS = 5
|
|
| 43 |
QUCAD_DEFAULT_LAM = 0.01
|
| 44 |
QUCAD_DEFAULT_RHO = 500.0
|
| 45 |
"""ADMM hyperparameters: ``lam`` is the ℓ1 weight, ``rho`` the quadratic
|
| 46 |
-
penalty coefficient. Defaults match
|
|
|
|
| 47 |
|
| 48 |
COBYLA_MAXITER = 20
|
| 49 |
"""Inner-loop COBYLA iterations per ADMM outer iteration."""
|
|
|
|
| 43 |
QUCAD_DEFAULT_LAM = 0.01
|
| 44 |
QUCAD_DEFAULT_RHO = 500.0
|
| 45 |
"""ADMM hyperparameters: ``lam`` is the ℓ1 weight, ``rho`` the quadratic
|
| 46 |
+
penalty coefficient. Defaults match the values in the QuCAD paper's
|
| 47 |
+
reference implementation."""
|
| 48 |
|
| 49 |
COBYLA_MAXITER = 20
|
| 50 |
"""Inner-loop COBYLA iterations per ADMM outer iteration."""
|
|
@@ -24,8 +24,8 @@
|
|
| 24 |
// * **Edge semantics are just execution order.** The backend runs Kahn
|
| 25 |
// topological sort over the graph and shares state via a single ctx
|
| 26 |
// dict; there's no such thing as a "data" vs "side-channel" edge.
|
| 27 |
-
// So a single flat chain is sufficient — no need
|
| 28 |
-
//
|
| 29 |
// * **We never produce a cycle.** Family order is a strict total
|
| 30 |
// order, so edges always point down the order and the graph stays a
|
| 31 |
// DAG.
|
|
@@ -252,8 +252,7 @@ export function autoConnect(
|
|
| 252 |
// so the algorithm can read the noise model. That's a side-channel, not
|
| 253 |
// a pipeline step. Mark it visually with a dashed stroke + small label
|
| 254 |
// so readers of the graph can tell "this block feeds calibration data,
|
| 255 |
-
// not a transformed circuit" at a glance.
|
| 256 |
-
// flowChartProto, which dashed the same edge.
|
| 257 |
//
|
| 258 |
// Exception: Qshot (kind === "qshot") is self-contained and ignores
|
| 259 |
// ctx["backend"] entirely. Putting a "noise profile" label on a
|
|
|
|
| 24 |
// * **Edge semantics are just execution order.** The backend runs Kahn
|
| 25 |
// topological sort over the graph and shares state via a single ctx
|
| 26 |
// dict; there's no such thing as a "data" vs "side-channel" edge.
|
| 27 |
+
// So a single flat chain is sufficient — no need to model
|
| 28 |
+
// "backend → algorithm" as a separate noise-profile branch.
|
| 29 |
// * **We never produce a cycle.** Family order is a strict total
|
| 30 |
// order, so edges always point down the order and the graph stays a
|
| 31 |
// DAG.
|
|
|
|
| 252 |
// so the algorithm can read the noise model. That's a side-channel, not
|
| 253 |
// a pipeline step. Mark it visually with a dashed stroke + small label
|
| 254 |
// so readers of the graph can tell "this block feeds calibration data,
|
| 255 |
+
// not a transformed circuit" at a glance.
|
|
|
|
| 256 |
//
|
| 257 |
// Exception: Qshot (kind === "qshot") is self-contained and ignores
|
| 258 |
// ctx["backend"] entirely. Putting a "noise profile" label on a
|
|
@@ -35,7 +35,7 @@ def bell_state() -> QuantumCircuit:
|
|
| 35 |
|
| 36 |
|
| 37 |
def vqc_2q_small() -> QuantumCircuit:
|
| 38 |
-
"""Tiny 2-qubit parameterised VQC
|
| 39 |
qc = QuantumCircuit(2, name="vqc_2q_small")
|
| 40 |
theta_0 = Parameter("theta_0")
|
| 41 |
theta_1 = Parameter("theta_1")
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
def vqc_2q_small() -> QuantumCircuit:
|
| 38 |
+
"""Tiny 2-qubit parameterised VQC for smoke-testing the pipeline."""
|
| 39 |
qc = QuantumCircuit(2, name="vqc_2q_small")
|
| 40 |
theta_0 = Parameter("theta_0")
|
| 41 |
theta_1 = Parameter("theta_1")
|