Commit History
-
Precomputed cache: schema gate + live-API regeneration
TheYuchenThe 36 shipped entries predated the provenance rework (no transformation/distribution/seed fields) yet still validated as RunResponses, so a hit would render a crippled first run. Worse-and- better at once: every key was already unreachable — the key hashes QPY bytes (changed by the qiskit upgrade) and the script's preset mirror had drifted from the frontend's defaultData (JS `500` vs Python `500.0`, missing fidelity params). * run_cache: stamp cache_schema=2 on write, treat unstamped/old entries as misses (logged once per key); writes scrub the seed envelope (disk cache is seed-free by design; per-step seed_used stays as the honest record). 6 new unit tests; lane now 86 green. * Delete the 36 dead files; regenerate qucad+compvqc x 9 samples (18 entries) from the LIVE Space via the new resumable scripts/regenerate_precomputed_cache_live.py, which refuses to run unless local qiskit == live /api/health qiskit (key parity). Torch-heavy presets (qubound/qshot/full) stay unca…61a5f88
-
Code quality cleanup + first unit-test seed
Yuchen YuanPost-audit polish on the bug-fix wave from the last 9 commits: * Hoist function-level constants to module top so they're discoverable and reusable: _FAKE_BACKENDS_AVAILABLE, _FIDELITY_METHODS, _FIDELITY_UNBOUND_POLICIES, _COMPVQC_MAX_QP_VARS, _COMPVQC_ROTATION_GATES. * Move 'import re' from inside _format_exception_for_user to the file's top-level imports. * Standardise validation error phrasing on 'Choose one of: ...' (was a mix of 'Allowed values:' and 'Choose one of:'). * Add the same name-validation rigour to _handle_ibm_backend that _handle_fake_backend has — refuse empty / non-string names with a clear message, and surface IBM's resolution failure through _format_exception_for_user instead of letting it bubble as a 500. * Drop the now-unused '_qpy_bytes' alias from run_cache.py; the one remaining call site uses the canonical name directly. * Drop the trivial _is_known_fake_backend wrapper; inline the membership test at the one …6962cb3
-
Global code-quality polish: DRY + named constants + leak cleanup
Yuchen Yuan +1: Claude Opus 4.7 (1M context)Targeted refactor pass based on a structured audit. Pure maintainability wins; no behaviour changes. Frontend: collapse 8 popovers into one hook 8 components (AuthButton, ThemeSwitcher, MoreMenu, PapersPopover, SupportPopover, DevelopersPopover, BlockPicker, PresetPicker) each carried an identical 16-line "close on mousedown + Escape" effect block. Extracted to lib/useDismissOn.ts; ~150 lines deleted, one hook to audit instead of eight. useDismissOn(open, rootRef, useCallback(() => setOpen(false), [])) Behaviour is intentionally identical to the inlined block so older git-blame on the call sites stays coherent. Backend: consolidate effective-user-id resolution routes/plugins.py and routes/workflow.py each carried a subtly different implementation of "session cookie wins over query_user_id, anon hf_ prefix is reserved". Pulled into auth_service.resolve_effective_user_id(request, query, *, required). - required=True path raises ValueError → routes/plugins maps to 400 - required=…57f0b3e
-
Backend copy: extend QuAIM description and cache motivation to four algorithms
Yuchen YuanTwo more places that hadn't caught up with Qshot landing: - main.py FastAPI description ("/docs" page header) still listed only QuCAD/QuBound/CompressVQC. Add Qshot. - run_cache.py module docstring referenced "the three preset pipelines" and "four presets x six samples". Both numbers were stale (5 presets, 9 samples; the precompute matrix is 36 cache entries). Generalise the wording so it doesn't have to be edited on every preset/sample addition, and note current counts inline.ede3688 -
Comment-vs-behavior audit: fix four real mismatches
Yuchen Yuan- run_cache: docstring claimed `_normalize_node` drops node id, code actually keeps it. Rewrite docstring to match behavior + explain why the cache still hits in practice (frontend presets and precompute script both use the same n1, n2... convention). - precompute_preset_results: qshot preset existed in frontend but was missing from the script's PRESETS dict, so qshot+ry_chain_6q always cache-missed. Add it. - viz/Sparkline: docstring said "non-negative integers" but the code defensively handles negatives (Math.min(...data, 0)) and short arrays (returns null on len<2). Rewrite docstring to match. - ResultsPane: EmptyHint said QuBound takes "about 2 minutes" while RunningHint says "1-3 minutes" for QuBound or Qshot. Unify both to 1-3 min and mention both slow paths.8e6747e
-
Cache pipeline runs by (circuit, graph) content hash
Yuchen Yuan +1: Claude Opus 4.7For the demo flow -- pick a sample, pick a preset, hit Run -- the server was re-executing the full QuCAD + LSTM + QAOA stack every click, which is 30-90s per preset. Most visitors just want to see what each algorithm produces on a bundled sample; they bounce long before the pipeline finishes. This commit adds a read-only, content-addressed cache for run responses. Key is sha256(qpy_bytes(circuit) + normalized(nodes+edges) + use_live_ibm) truncated to 16 hex chars. The /workflow/run handler looks up the key before dispatching run_pipeline; hits return the stored RunResponse with from_cache=true. Live-IBM runs always bypass the cache, since calibration drifts and the point of "live" is to hit hardware. The precompute script under scripts/ runs every PRESET x every sample and serializes responses to backend/cache/precomputed_runs/<key>.json. Those files are checked in and bundled into the image, so first-visit users see results in <1s with a "cached" pill in the ResultsPane header expla…e4e737d