Skip to content

docs(scaling): note that scaling shifts solver tolerance meaning - #945

Merged
FabianHofmann merged 1 commit into
masterfrom
docs/scaling-tolerance-caveat
Sep 8, 2026
Merged

docs(scaling): note that scaling shifts solver tolerance meaning#945
FabianHofmann merged 1 commit into
masterfrom
docs/scaling-tolerance-caveat

Conversation

@FabianHofmann

Copy link
Copy Markdown
Collaborator

The scaling feature is nice, but scaling changes the numbers the solver
actually works on. That also changes what the solver's tolerances mean, and I
think a short note of caution about this in the docs would help users avoid
surprises.

Note

The following content was generated by AI.

Changes proposed in this Pull Request

  • Add a caveat to the Notes and caveats section of the numerical-scaling
    tutorial (examples/numerical-scaling.ipynb, rendered at
    numerical-scaling.html).
  • The new bullet explains that a solver applies its feasibility and optimality
    tolerances to the scaled problem, not to the original units. So a fixed
    tolerance maps to different absolute tolerances per row and column once you
    scale, and a scaled run matches an unscaled run only up to solver tolerance,
    not bit-for-bit.
  • It closes with two practical hints: rescale if a solver reports numerical
    trouble, and re-check the tolerances if you rely on tight ones.

Docs-only change. Built locally with the docs extra; the page renders and the
new bullet appears.

Checklist

  • AI-generated content is marked (see AGENTS.md).
  • Code changes are sufficiently documented; i.e. new functions contain docstrings and further explanations may be given in doc.
  • Unit tests for new features were added (if applicable).
  • A note for the release notes doc/release_notes.rst of the upcoming release is included.
  • I consent to the release of this PR's code under the MIT license.

Add a caveat to the numerical-scaling notebook explaining that solver
feasibility and optimality tolerances apply to the scaled problem, so a
fixed tolerance maps to different absolute tolerances in original units.
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

Build cost — v1 vs legacy

v1 build peak & time relative to legacy, on this commit — not a comparison against master (that is CodSpeed).

peak — v1 / legacy time — v1 / legacy
peak v1/legacy time v1/legacy
Full table (time + peak, mean)
benchmarks/drivers/test_build.py::test_build[basic-n=10]
                  time (s)         peak (KiB) 
 name                 mean   │           mean 
──────────────────────────────────────────────
 (legacy)   0.07687 (1.09)   │   15.03 (1.00) 
 (v1)        0.07056 (1.0)   │    15.00 (1.0) 

benchmarks/drivers/test_build.py::test_build[basic-n=250]
                  time (s)         peak (MiB) 
 name                 mean   │           mean 
──────────────────────────────────────────────
 (legacy)   0.08547 (1.09)   │   12.04 (1.00) 
 (v1)        0.07847 (1.0)   │    12.04 (1.0) 

benchmarks/drivers/test_build.py::test_build[cumsum-severity=0]
                  time (s)        peak (KiB) 
 name                 mean   │          mean 
─────────────────────────────────────────────
 (legacy)   0.03333 (1.09)   │   15.20 (1.0) 
 (v1)        0.03061 (1.0)   │   15.20 (1.0) 

benchmarks/drivers/test_build.py::test_build[cumsum-severity=100]
                  time (s)        peak (MiB) 
 name                 mean   │          mean 
─────────────────────────────────────────────
 (legacy)   0.05336 (1.11)   │   44.93 (1.0) 
 (v1)        0.04823 (1.0)   │   44.93 (1.0) 

benchmarks/drivers/test_build.py::test_build[cumsum-severity=50]
                  time (s)        peak (MiB) 
 name                 mean   │          mean 
─────────────────────────────────────────────
 (legacy)   0.03737 (1.08)   │   11.51 (1.0) 
 (v1)         0.0346 (1.0)   │   11.51 (1.0) 

benchmarks/drivers/test_build.py::test_build[expression_arithmetic-n=10]
                  time (s)         peak (KiB) 
 name                 mean   │           mean 
──────────────────────────────────────────────
 (legacy)   0.08616 (1.07)   │   24.34 (1.06) 
 (v1)        0.08042 (1.0)   │    23.04 (1.0) 

benchmarks/drivers/test_build.py::test_build[expression_arithmetic-n=250]
                  time (s)         peak (MiB) 
 name                 mean   │           mean 
──────────────────────────────────────────────
 (legacy)   0.09715 (1.07)   │   16.12 (1.00) 
 (v1)        0.09117 (1.0)   │    16.12 (1.0) 

benchmarks/drivers/test_build.py::test_build[knapsack-n=10000]
                  time (s)          peak (KiB) 
 name                 mean   │            mean 
───────────────────────────────────────────────
 (legacy)   0.02085 (1.10)   │   752.18 (1.10) 
 (v1)        0.01901 (1.0)   │    685.15 (1.0) 

benchmarks/drivers/test_build.py::test_build[knapsack-n=100]
                  time (s)        peak (KiB) 
 name                 mean   │          mean 
─────────────────────────────────────────────
 (legacy)   0.02034 (1.09)   │   3.12 (1.33) 
 (v1)         0.0186 (1.0)   │    2.34 (1.0) 

benchmarks/drivers/test_build.py::test_build[kvl_cycles-severity=0]
                  time (s)          peak (MiB) 
 name                 mean   │            mean 
───────────────────────────────────────────────
 (legacy)   0.06822 (1.23)   │   126.16 (1.44) 
 (v1)        0.05539 (1.0)   │     87.71 (1.0) 

benchmarks/drivers/test_build.py::test_build[kvl_cycles-severity=100]
                 time (s)          peak (MiB) 
 name                mean   │            mean 
──────────────────────────────────────────────
 (legacy)   0.0677 (1.24)   │   126.16 (1.44) 
 (v1)       0.05462 (1.0)   │     87.71 (1.0) 

benchmarks/drivers/test_build.py::test_build[kvl_cycles-severity=50]
                  time (s)          peak (MiB) 
 name                 mean   │            mean 
───────────────────────────────────────────────
 (legacy)   0.06815 (1.24)   │   126.16 (1.44) 
 (v1)        0.05488 (1.0)   │     87.71 (1.0) 

benchmarks/drivers/test_build.py::test_build[masked-n=100]
                  time (s)          peak (KiB) 
 name                 mean   │            mean 
───────────────────────────────────────────────
 (legacy)   0.04814 (1.02)   │    715.12 (1.0) 
 (v1)        0.04705 (1.0)   │   787.73 (1.10) 

benchmarks/drivers/test_build.py::test_build[masked-n=10]
                  time (s)        peak (KiB) 
 name                 mean   │          mean 
─────────────────────────────────────────────
 (legacy)   0.04614 (1.11)   │   4.54 (1.27) 
 (v1)        0.04158 (1.0)   │    3.57 (1.0) 

benchmarks/drivers/test_build.py::test_build[merge_balance-severity=0]
                 time (s)          peak (KiB) 
 name                mean   │            mean 
──────────────────────────────────────────────
 (legacy)   0.3209 (1.05)   │   704.12 (1.09) 
 (v1)        0.3046 (1.0)   │    643.85 (1.0) 

benchmarks/drivers/test_build.py::test_build[merge_balance-severity=100]
                time (s)        peak (MiB) 
 name               mean   │          mean 
───────────────────────────────────────────
 (legacy)   0.339 (1.05)   │   18.34 (1.0) 
 (v1)       0.3222 (1.0)   │   18.34 (1.0) 

benchmarks/drivers/test_build.py::test_build[merge_balance-severity=50]
                 time (s)       peak (MiB) 
 name                mean   │         mean 
───────────────────────────────────────────
 (legacy)   0.3325 (1.05)   │   9.54 (1.0) 
 (v1)        0.3167 (1.0)   │   9.54 (1.0) 

benchmarks/drivers/test_build.py::test_build[milp-n=10]
                  time (s)        peak (KiB) 
 name                 mean   │          mean 
─────────────────────────────────────────────
 (legacy)   0.06482 (1.08)   │   3.77 (1.12) 
 (v1)        0.05979 (1.0)   │    3.37 (1.0) 

benchmarks/drivers/test_build.py::test_build[milp-n=50]
                  time (s)          peak (KiB) 
 name                 mean   │            mean 
───────────────────────────────────────────────
 (legacy)   0.06551 (1.09)   │   216.59 (1.10) 
 (v1)        0.05999 (1.0)   │    196.23 (1.0) 

benchmarks/drivers/test_build.py::test_build[nodal_balance-severity=0]
                  time (s)         peak (KiB) 
 name                 mean   │           mean 
──────────────────────────────────────────────
 (legacy)   0.03351 (1.11)   │   938.49 (1.0) 
 (v1)         0.0302 (1.0)   │   938.49 (1.0) 

benchmarks/drivers/test_build.py::test_build[nodal_balance-severity=100]
                  time (s)       peak (MiB) 
 name                 mean   │         mean 
────────────────────────────────────────────
 (legacy)   0.03495 (1.10)   │   9.66 (1.0) 
 (v1)         0.0319 (1.0)   │   9.66 (1.0) 

benchmarks/drivers/test_build.py::test_build[nodal_balance-severity=50]
                  time (s)       peak (MiB) 
 name                 mean   │         mean 
────────────────────────────────────────────
 (legacy)   0.03448 (1.10)   │   5.32 (1.0) 
 (v1)        0.03123 (1.0)   │   5.32 (1.0) 

benchmarks/drivers/test_build.py::test_build[nodal_balance_sparse-severity=0]
                  time (s)       peak (MiB) 
 name                 mean   │         mean 
────────────────────────────────────────────
 (legacy)   0.01885 (1.01)   │   1.47 (1.0) 
 (v1)         0.0186 (1.0)   │   1.47 (1.0) 

benchmarks/drivers/test_build.py::test_build[nodal_balance_sparse-severity=100]
                  time (s)       peak (MiB) 
 name                 mean   │         mean 
────────────────────────────────────────────
 (legacy)   0.01871 (1.02)   │   1.47 (1.0) 
 (v1)        0.01841 (1.0)   │   1.47 (1.0) 

benchmarks/drivers/test_build.py::test_build[nodal_balance_sparse-severity=50]
                  time (s)       peak (MiB) 
 name                 mean   │         mean 
────────────────────────────────────────────
 (legacy)   0.01873 (1.01)   │   1.47 (1.0) 
 (v1)        0.01847 (1.0)   │   1.47 (1.0) 

benchmarks/drivers/test_build.py::test_build[piecewise-n=1000]
                 time (s)          peak (KiB) 
 name                mean   │            mean 
──────────────────────────────────────────────
 (legacy)   0.1645 (1.06)   │   946.85 (1.06) 
 (v1)        0.1548 (1.0)   │    891.54 (1.0) 

benchmarks/drivers/test_build.py::test_build[piecewise-n=10]
                 time (s)         peak (KiB) 
 name                mean   │           mean 
─────────────────────────────────────────────
 (legacy)   0.1597 (1.06)   │   12.01 (1.00) 
 (v1)        0.1513 (1.0)   │    11.99 (1.0) 

benchmarks/drivers/test_build.py::test_build[qp-n=1000]
                  time (s)          peak (KiB) 
 name                 mean   │            mean 
───────────────────────────────────────────────
 (legacy)   0.04162 (1.08)   │   147.70 (1.06) 
 (v1)         0.0384 (1.0)   │    139.87 (1.0) 

benchmarks/drivers/test_build.py::test_build[qp-n=10]
                  time (s)        peak (KiB) 
 name                 mean   │          mean 
─────────────────────────────────────────────
 (legacy)   0.04095 (1.08)   │   2.60 (1.09) 
 (v1)        0.03794 (1.0)   │    2.38 (1.0) 

benchmarks/drivers/test_build.py::test_build[rolling-severity=0]
                  time (s)          peak (KiB) 
 name                 mean   │            mean 
───────────────────────────────────────────────
 (legacy)   0.03426 (1.10)   │   696.75 (1.03) 
 (v1)        0.03122 (1.0)   │    673.70 (1.0) 

benchmarks/drivers/test_build.py::test_build[rolling-severity=100]
                  time (s)         peak (MiB) 
 name                 mean   │           mean 
──────────────────────────────────────────────
 (legacy)    0.09897 (1.0)   │   137.97 (1.0) 
 (v1)       0.09989 (1.01)   │   137.97 (1.0) 

benchmarks/drivers/test_build.py::test_build[rolling-severity=50]
                  time (s)        peak (MiB) 
 name                 mean   │          mean 
─────────────────────────────────────────────
 (legacy)   0.05983 (1.07)   │   69.22 (1.0) 
 (v1)         0.0559 (1.0)   │   69.22 (1.0) 

benchmarks/drivers/test_build.py::test_build[sos-n=1000]
                  time (s)          peak (KiB) 
 name                 mean   │            mean 
───────────────────────────────────────────────
 (legacy)   0.03988 (1.12)   │   402.33 (1.00) 
 (v1)        0.03553 (1.0)   │    402.30 (1.0) 

benchmarks/drivers/test_build.py::test_build[sos-n=10]
                  time (s)        peak (KiB) 
 name                 mean   │          mean 
─────────────────────────────────────────────
 (legacy)   0.03906 (1.12)   │   3.19 (1.19) 
 (v1)        0.03489 (1.0)   │    2.69 (1.0) 

benchmarks/drivers/test_build.py::test_build[sparse_network-n=10]
                  time (s)         peak (KiB) 
 name                 mean   │           mean 
──────────────────────────────────────────────
 (legacy)   0.04292 (1.08)   │   29.00 (1.54) 
 (v1)        0.03962 (1.0)   │    18.84 (1.0) 

benchmarks/drivers/test_build.py::test_build[sparse_network-n=250]
                  time (s)         peak (MiB) 
 name                 mean   │           mean 
──────────────────────────────────────────────
 (legacy)   0.05686 (1.17)   │   37.95 (1.43) 
 (v1)        0.04866 (1.0)   │    26.51 (1.0) 

benchmarks/drivers/test_build.py::test_build[storage-n=10]
                  time (s)          peak (KiB) 
 name                 mean   │            mean 
───────────────────────────────────────────────
 (legacy)     0.0815 (1.0)   │    410.93 (1.0) 
 (v1)       0.08217 (1.01)   │   427.84 (1.04) 

benchmarks/drivers/test_build.py::test_build[storage-n=250]
                  time (s)         peak (MiB) 
 name                 mean   │           mean 
──────────────────────────────────────────────
 (legacy)    0.08946 (1.0)   │     9.94 (1.0) 
 (v1)       0.09125 (1.02)   │   10.22 (1.03) 

📊 Interactive plots + CSV: download the semantics-report-v1-vs-legacy artifact from this run.

Report-only · not a gate · refreshed on every push · obsolete once legacy is dropped.

@codspeed-hq

codspeed-hq Bot commented Sep 8, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 19.48%

⚡ 3 improved benchmarks
✅ 178 untouched benchmarks
⏩ 181 skipped benchmarks1

Performance Changes

Benchmark BASE HEAD Efficiency
test_to_lp[nodal_balance-severity=0] 3.4 MB 2.6 MB +28.36%
test_to_lp[nodal_balance_sparse-severity=100] 4 MB 3.4 MB +16.51%
test_to_lp[cumsum-severity=100] 208.9 MB 183.2 MB +14.05%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing docs/scaling-tolerance-caveat (39434cc) with master (ce6779a)

Open in CodSpeed

Footnotes

  1. 181 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@FabianHofmann
FabianHofmann merged commit 718c0c1 into master Sep 8, 2026
25 checks passed
@FabianHofmann
FabianHofmann deleted the docs/scaling-tolerance-caveat branch September 8, 2026 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant