Calibrate the cost models used by structural-computing's router via wall-clock measurements on your machine.
Project description
structural-computing-bench
Calibrate the cost models used by
structural-computing's
router by measuring actual wall-clock performance of its leaf
evaluators on your machine and fitting a power-law / exponential model
to the measurements.
The router decides which evaluator to dispatch to based on a predicted runtime. The shipped predictions are hand-picked defaults; this repo produces machine-specific replacements so the predictions match what your hardware actually does.
Why a separate repo
The benchmark machinery is heavier than the core library — timing
primitives, GC handling, curve fitting, problem generators, plus
optional plotting / reporting. Keeping it out of the
structural-computing PyPI package means:
- Users installing the framework don't pull in unused benchmarking code.
- The bench repo can grow heavier deps later (matplotlib, scipy, hypothesis) without bloating the core.
- Calibration runs can have their own CI and don't interleave with framework PRs.
The output is a small calibration_data.py (or .json) file that the
framework's structural_computing.calibration.apply_calibration() loads
to update the router's coefficients at runtime.
Quick start
pip install -e .
python scripts/run_calibration.py --out calibration_data/my_machine.py
then in your application:
import importlib.util, importlib
spec = importlib.util.spec_from_file_location(
"my_calibration", "calibration_data/my_machine.py")
mod = importlib.util.module_from_spec(spec); spec.loader.exec_module(mod)
from structural_computing.calibration import apply_calibration
apply_calibration(mod.CALIBRATED_COSTS)
# Now the router uses your machine's measured constants.
What gets measured
| Leaf evaluator | Problem generator | Default sizes |
|---|---|---|
_count_solutions_leaf |
random GF(2) affine | n ∈ [4, 8, 12, 16, 20, 24] |
_matching_count_leaf (T2) |
n-cycle (planar) | n ∈ [4, 6, 8, 10, 12, 14, 16] |
_matching_count_leaf (T4) |
K_{n,n} bipartite | n ∈ [2, 3, 4, 5] |
_matchgate_rank_leaf |
symmetric arity-n sig | n ∈ [2, 4, 6, 8, 10, 12] |
For each, the harness:
- Generates a deterministic problem of size
n. - Runs the leaf evaluator
repeat=5times. - Records the median elapsed seconds (median is robust to GC pauses).
- Fits both
time ≈ a * n^b(power law) andtime ≈ a * exp(b * n)(exponential); reports whichever has lower log-residual as the preferred model.
License
MIT-with-attribution to Edward Chalk / sapientronic.ai.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file structural_computing_bench-0.1.0a1.tar.gz.
File metadata
- Download URL: structural_computing_bench-0.1.0a1.tar.gz
- Upload date:
- Size: 17.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6916595369602a72976d3f724fffcd8f75469418a8535084dac7e81f26a490eb
|
|
| MD5 |
34a9ddc8934398cdab60bf238c25be41
|
|
| BLAKE2b-256 |
c01e2dc4d87ecce318025f023eb4bb9b23390537dd88f9ae980eb982346a29fa
|
File details
Details for the file structural_computing_bench-0.1.0a1-py3-none-any.whl.
File metadata
- Download URL: structural_computing_bench-0.1.0a1-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3fb5de2454bd63dc0209e1cededae06ffc3ac667e46fd2b16ca8ead9bd7322b7
|
|
| MD5 |
2c6a2b383cd45822a02296f38042bec9
|
|
| BLAKE2b-256 |
445e82f47bffc477341f3b20bfe1007762f9f8863aae5db08faa8da5df5e8f68
|