Add reference spec framework for noise-free benchmark outputs (#924) - #941
Open
grageragarces wants to merge 4 commits into
Open
Add reference spec framework for noise-free benchmark outputs (#924)#941grageragarces wants to merge 4 commits into
grageragarces wants to merge 4 commits into
Conversation
…lkit#924) Introduces a compact, JSON-serialisable reference specification for MQT Bench circuits so downstream users can validate noisy experiments against an ideal ground truth without needing a dense state vector. New files: - benchmarks/_reference.py — ReferenceSpec + SparseReference / UniformReference / SimulateReference / NoneReference / ObjectiveSpec - tests/test_reference.py — 52 tests (all passing) Framework changes: - _registry.py: parallel _REFERENCE_REGISTRY + register_reference decorator - __init__.py: get_reference_spec() public API + lazy-load-aware has_reference() Reference specs implemented for: ghz (sparse), wstate (uniform), bv (sparse + objective), dj (sparse + objective), grover (sparse + marked-states objective), qpeexact (sparse phase readout), randomcircuit (simulate). Closes munich-quantum-toolkit#924
Author
|
Hey @burgholzer! 👋 I've opened a draft PR implementing the reference spec framework proposed in #924.
The remaining benchmarks need someone who knows the generator internals to fill in the right answer. Some thoughts on the obvious ones:
Any guidance on the above would let me fill in the rest. Also very happy to adjust the schema if something doesn't work quite right! |
Author
|
will give it a day for the tests to fail before trying to fix them :) |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
- Annotated GHZ entries dict as dict[str, float] to stop ty inferring LiteralString keys (invariant generic mismatch) - Replaced # type: ignore[misc] workarounds with proper isinstance narrowing guards before all .entries accesses in tests - Added test_has_reference_nonexistent_benchmark to cover the except ValueError branch in has_reference, closing the 2-line coverage gap reported by Codecov
- Replace en dashes with hyphens in ObjectiveSpec docstring (RUF002) - Rename `dynamic` to `_dynamic` in bv.create_reference to mark it as intentionally unused (ARG001) - Add missing docstrings to all public test functions (D103) - Remove default argument from test_wstate_reference_probability (PT028) - Replace float == comparisons with math.isclose / abs checks (RUF069) - Add isinstance narrowing guards before .entries accesses so ty can narrow the ReferenceKind union (replaces # type: ignore[misc]) - Add test_has_reference_nonexistent_benchmark to cover the except ValueError branch in has_reference (closes Codecov gap)
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.
Summary
Implements the reference specification framework proposed in #924.
Each benchmark can now expose a
create_referencefunction that returnsa compact, JSON-serialisable description of the ideal output distribution —
no dense state vectors required.
Distribution kinds
sparse{bitstring: prob}tableuniformsimulatemax_qubits— caller runs statevector simnoneAn optional
objectivefield carries the semantic answer (hidden string,marked states, phase, …) separately from the distribution.
Implemented benchmarks
ghz,wstate,bv,dj,grover,qpeexact,randomcircuitPublic API