-
Notifications
You must be signed in to change notification settings - Fork 5
TenSolver Stochastic Benchmark example #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
847f848
TenSolver Stochastic Benchmark example
jvpcms fa9752e
removing auto-generated files
jvpcms f520f7d
readme
jvpcms fbe9b52
markdown render fix
jvpcms fa0e193
grammar improvements
jvpcms c4cb9a0
better description of the hamiltonian equivalence
jvpcms 252297c
adding references
jvpcms e4fdf9f
Address TenSolver example review feedback
bernalde acd63d4
Clear TenSolver notebook outputs
bernalde 82a7900
execute notebook
jvpcms dc0a082
Fix late baseline recalibration
bernalde File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # TenSolver Benchmark Example | ||
|
|
||
| Benchmarking [TenSolver](https://github.com/SECQUOIA/TenSolver.jl) on 23 QUBO instances from the QpLib subset of QUBOLib (instances 308–330). | ||
|
|
||
| ## What's included | ||
|
|
||
| - **Energy distribution visualizations** — heatmap showing how the sampled energy distribution evolves across DMRG iterations for a representative instance. | ||
| - **Performance ratio** — computed against Gurobi's best-known objectives as the reference minimum and random bitstring sampling as the baseline. | ||
| - **Bootstrap analysis** — performance ratio inferred for 1, 10, 100, and 1000 samples per iteration using the stochastic-benchmark framework. | ||
| - **Resource analysis** — `iterations × samples` used as a proxy for compute; interpolation, train/test split, virtual best baseline, and projection experiments. | ||
|
|
||
| ## Data files | ||
|
|
||
| | File | Description | | ||
| |---|---| | ||
| | `results/energy_history.json` | 1000 energy samples per DMRG iteration for all 23 instances | | ||
| | `results/random_baseline.json` | Mean and min energy from 1000 random bitstrings per instance | | ||
| | `results/gurobi_best.json` | Best objective found by Gurobi (900 s limit) per instance | |
|
jvpcms marked this conversation as resolved.
|
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| { | ||
| "308": { | ||
| "best_objective": -806, | ||
| "status": 2, | ||
| "optimal": true | ||
| }, | ||
| "309": { | ||
| "best_objective": -440, | ||
| "status": 2, | ||
| "optimal": true | ||
| }, | ||
| "310": { | ||
| "best_objective": -1686, | ||
| "status": 9, | ||
| "optimal": false | ||
| }, | ||
| "311": { | ||
| "best_objective": -1542, | ||
| "status": 9, | ||
| "optimal": false | ||
| }, | ||
| "312": { | ||
| "best_objective": -1844, | ||
| "status": 9, | ||
| "optimal": false | ||
| }, | ||
| "313": { | ||
| "best_objective": -614, | ||
| "status": 2, | ||
| "optimal": true | ||
| }, | ||
| "314": { | ||
| "best_objective": -1142, | ||
| "status": 2, | ||
| "optimal": true | ||
| }, | ||
| "315": { | ||
| "best_objective": -688, | ||
| "status": 2, | ||
| "optimal": true | ||
| }, | ||
| "316": { | ||
| "best_objective": -514, | ||
| "status": 2, | ||
| "optimal": true | ||
| }, | ||
| "317": { | ||
| "best_objective": -1402, | ||
| "status": 2, | ||
| "optimal": true | ||
| }, | ||
| "318": { | ||
| "best_objective": -900, | ||
| "status": 2, | ||
| "optimal": true | ||
| }, | ||
| "319": { | ||
| "best_objective": -1298, | ||
| "status": 2, | ||
| "optimal": true | ||
| }, | ||
| "320": { | ||
| "best_objective": -2022, | ||
| "status": 9, | ||
| "optimal": false | ||
| }, | ||
| "321": { | ||
| "best_objective": -362, | ||
| "status": 2, | ||
| "optimal": true | ||
| }, | ||
| "322": { | ||
| "best_objective": -1040, | ||
| "status": 2, | ||
| "optimal": true | ||
| }, | ||
| "323": { | ||
| "best_objective": -23964950, | ||
| "status": 9, | ||
| "optimal": false | ||
| }, | ||
| "324": { | ||
| "best_objective": -74347446, | ||
| "status": 2, | ||
| "optimal": true | ||
| }, | ||
| "325": { | ||
| "best_objective": -68476481, | ||
| "status": 2, | ||
| "optimal": true | ||
| }, | ||
| "326": { | ||
| "best_objective": -86899, | ||
| "status": 9, | ||
| "optimal": false | ||
| }, | ||
| "327": { | ||
| "best_objective": -25305, | ||
| "status": 2, | ||
| "optimal": true | ||
| }, | ||
| "328": { | ||
| "best_objective": -50321, | ||
| "status": 9, | ||
| "optimal": false | ||
| }, | ||
| "329": { | ||
| "best_objective": -71422, | ||
| "status": 9, | ||
| "optimal": false | ||
| }, | ||
| "330": { | ||
| "best_objective": -256359, | ||
| "status": 9, | ||
| "optimal": false | ||
| } | ||
| } |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| """Smoke checks for the TenSolver example notebook.""" | ||
| import json | ||
| import os | ||
| from pathlib import Path | ||
|
|
||
| import matplotlib | ||
|
|
||
| matplotlib.use("Agg", force=True) | ||
|
|
||
|
|
||
| REPO_ROOT = Path(__file__).resolve().parents[1] | ||
| NOTEBOOK = REPO_ROOT / "examples" / "TenSolver" / "TenSolver.ipynb" | ||
|
|
||
|
|
||
| def _notebook(): | ||
| return json.loads(NOTEBOOK.read_text()) | ||
|
|
||
|
|
||
| def _code_cell_sources(): | ||
| return [ | ||
| "".join(cell["source"]) | ||
| for cell in _notebook()["cells"] | ||
| if cell["cell_type"] == "code" | ||
| ] | ||
|
|
||
|
|
||
| def test_first_tensolver_code_cell_runs_from_repo_root(monkeypatch): | ||
| """The notebook should locate its data when launched from the repo root.""" | ||
| monkeypatch.chdir(REPO_ROOT) | ||
| os.environ.setdefault("MPLBACKEND", "Agg") | ||
|
|
||
| namespace = {"__name__": "__main__"} | ||
| exec(compile(_code_cell_sources()[0], str(NOTEBOOK), "exec"), namespace) | ||
|
|
||
| assert namespace["HERE"] == REPO_ROOT / "examples" / "TenSolver" | ||
| assert "323" in namespace["all_data"] | ||
|
|
||
|
|
||
| def test_tensolver_notebook_seeds_stochastic_steps(): | ||
| """Bootstrap and train/test split output should be reproducible.""" | ||
| source = "\n".join(_code_cell_sources()) | ||
|
|
||
| assert "RANDOM_SEED = " in source | ||
| assert source.count("np.random.seed(RANDOM_SEED)") >= 2 | ||
|
|
||
|
|
||
| def test_tensolver_notebook_uses_example_dir_for_outputs(): | ||
| """Checkpoint and plot output should stay in the example directory.""" | ||
| source = "\n".join(_code_cell_sources()) | ||
|
|
||
| assert "here=str(HERE)" in source | ||
| assert "fig.savefig(HERE / \"performance.png\")" in source |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.