feat: qgan generation + final results - #13
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.