Module parity
Expand description
The cross-language parity gate (D26, docs/design/11-documentation-plan.md
§6.2), and the runner that keeps every example executed.
§What this proves
atune’s determinism contract says the parameters of trial n are a pure
function of (study seed, n, space). That promise crosses the binding
boundary too, because atune_py delegates to core’s optimize_with and the
Python sampler factories ignore their seed argument in favour of the study
seed (§1.3.6). So the strongest documentation gate available is: the Rust
and Python versions of an example must agree on the answer — and not
approximately, but bit for bit.
No other HPO framework can run this gate, because none of them promises bit-reproducibility across its bindings.
§Why there are two halves
check-parity runs both arms and compares them, which needs a built wheel.
check-parity --rust-golden compares only the Rust arm against a committed
golden, which needs nothing but the workspace — so it belongs in the fast
per-push gate, where a change in optimiser behaviour reddens CI immediately
rather than waiting for the documentation job (§11).
The goldens are platform-pinned, and each file says so. A parity block
carries float bits, and float bits from cos come from the platform libm,
which is not required to be correctly rounded and may differ between
platforms (§1.3.19b). Every rust.yml job is ubuntu-latest today
(§1.3.23), so one golden per arm is correct and cheap. If the release gate
ever gains a second OS, the choice is per-platform goldens or dropping the
value line — never a tolerance.
Modules§
- block
- The
atune-parity/1block: its grammar, its parser, and the comparison. - manifest
examples/parity.toml— the single source of what must agree.
Constants§
- BLESS 🔒
- The environment variable that rewrites the goldens.
- FACADE_
MANIFEST 🔒 - The facade’s manifest, where an example declares the features it needs.
- GOLDEN_
DIR 🔒 - Where the committed Rust-arm goldens live, relative to the repository root.
Functions§
- capture 🔒
- Runs a command, requiring exit 0 and returning its stdout.
- cargo_
example 🔒 - Runs
cargo run -q -p atune --example <name>and returns its stdout. - check
- Runs the parity gate.
- check_
across_ 🔒languages - Runs both arms of one pair and compares their blocks.
- check_
against_ 🔒golden - Compares one Rust arm against its committed golden.
- golden_
text 🔒 - Renders a golden file: the pinning comment, then the block.
- libm_
identity 🔒 - The C library the float bits above came from, as far as it can be read cheaply.
- python_
origin 🔒 - How a Python arm’s failure names itself.
- python_
program 🔒 - The Python interpreter to drive the Python arms with.
- required_
features 🔒 - The features an example declares through
[[example]] required-features. - run_
examples - Runs every example under
examples/rust/. - run_
python_ 🔒arm - Runs a Python arm and returns its stdout.
- run_
rust_ 🔒arm - Runs a Rust arm and returns its stdout.
- rust_
origin 🔒 - How a Rust arm’s failure names itself.
- strip_
header_ 🔒comments - Drops a golden’s leading
#comment lines.