Skip to content

feat: qgan generation + final results - #13

Merged
a1exxd0 merged 9 commits into
mainfrom
alex/testing-and-qgan
Jun 7, 2026
Merged

feat: qgan generation + final results#13
a1exxd0 merged 9 commits into
mainfrom
alex/testing-and-qgan

Conversation

@a1exxd0

@a1exxd0 a1exxd0 commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

a1exxd0 and others added 9 commits June 7, 2026 03:09
…ng driver

The "move scenario_generation into src/" commit left a byte-identical (and in
places stale) top-level copy. src/scenario_generation is canonical: pytest's
pythonpath=["src"] resolves there, and its io.py/inspect_generated.py are the
refactored versions. Delete the top-level duplicate.

Add scripts/train_qgan.py: trains the experimental adversarial Born-machine
generator on a synthetic n=12 spec and validates generated marginals/correlations
against the Gaussian-copula target. (The canonical QCBM loader uses analytic
angles and needs no training; this exercises the qGAN path.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Trainer (src/scenario_generation/qgan_trainer.py):
- Generator objective evaluated as the EXACT expectation over the Born
  distribution (was Monte-Carlo sampled) -> noise-free; gradient is a central
  finite difference on that exact expectation (hardware analogue: parameter
  shift). Non-saturating objective max E_p[log D]. Adam for both generator and
  (regularised) discriminator. Best-circuit tracking by exact moment error.
- fit() now accepts an optional prebuilt circuit + target samples so a
  hand-built (sparse, hardware-friendly) ansatz can be trained.

Result on the n=12 block: moment error -95.4% vs the analytic seed; marginal
MAE 0.024->0.010, corr MAE 0.089->0.052.

scripts/train_qgan.py: --mode dense (full graph) and --mode hw (inflated
marginals above the QPU noise floor + max-degree-2 chain), saving the trained
hw circuit for submission.

scripts/run_qgan_hardware.py: submit the trained hw circuit to a QPU (dry-run by
default). Validated on ibm_boston (job d8ibjps2upec739m142g, 100k shots): 22
two-qubit gates, 0 SWAPs, 12/12 marginals above the readout floor, marginal RMSE
vs ideal 0.012, chain joint RMSE vs ideal 0.0039.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
scripts/build_dataset.py samples correlated binary default scenarios from every
generator, side-by-side, across the real G-SIB network and the synthetic network
specs (16- and 54-node). Writes per source/generator CSV + compressed NPZ, the
SystemSpec (spec.json), per-generator fit quality (moments.json), and a top-level
manifest.json indexing shapes, seeds and moment errors.

Generators: Bernoulli, Gaussian copula, Student-t copula, entangled Born machine.
IsingBoltzmann is excluded -- it freezes into a degenerate all-default state on
sparse low-PD networks (real-net marginal RMSE ~1.0). A degeneracy flag in
moments.json guards the remaining generators.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add data/scenario_dataset/ (3 sources x 4 generators, 4000 samples each, CSV +
NPZ) plus a README documenting provenance and the rare-event caveat on the real
network. Point build_dataset.py's default --out-dir at the tracked path so
regeneration (deterministic, seed=12345) overwrites the committed copy.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@a1exxd0
a1exxd0 merged commit 6b97464 into main Jun 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant