Ship the MIR JIT in the wheels, so forward sensitivities run on a machine with no C compiler
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 18/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- build-system, cli
Research direction
The work spans the cibuildwheel configuration, _codegen_jit_backend in _codegen.py, the capabilities() output, and the vendored MIR under third_party/mir. Start by reading the mir.yml CI job and the compiler-probe logic in _codegen.py, then check how BNGSIM_ENABLE_MIR reaches the wheel build. Done means a wheel with no C compiler on PATH runs a forward sensitivity to the closed-form answer, while cc is still used where present.
Written by the indexing model from the issue text.
Description
Forward sensitivities compile generated C, so a wheel install needs a C compiler where it runs. Containers, cluster compute nodes and stock Windows often have none, and there a run with sensitivity_params raises CodegenToolchainError (#1690). The vendored MIR JIT compiles the same C in-process with no compiler, but the published wheels build without it (BNGSIM_ENABLE_MIR is OFF, and HAS_MIR is False).
Why it was off, and why that no longer holds
When the MIR CI job landed, #2 recorded that MIR stays out of the wheels for now. The blocker was that MIR handled some errors by calling exit(), so a model it could not compile would end the user's Python process instead of raising an error. Binary size and shipping a vendored compiler were the other reasons.
That blocker is fixed. Since #1215, MirJit gives each MIR context its own allocator, code allocator and error function, and each returns to MirJit::compile, which raises RuntimeError (third_party/mir/README.md.bngsim, "Running out"). The other known MIR problems are fixed or covered:
- The SIGILL under Rosetta is fixed by a local carry (#1216).
mir.ymlchecks MIR againstccon Linux, macOS x86_64, macOS arm64 and Windows: bit-identical on x86_64, within about 1e-13 on arm64, where clang fuses multiply-adds and MIR does not.- The library adds about 1 MB to a wheel.
What to do
- Build MIR into the wheels. Set
BNGSIM_ENABLE_MIR=ONin the cibuildwheel configuration, for every platform the wheels cover. Check the wheel sizes and thatcapabilities()["features"]["mir"]is true in each. - Fall back to MIR when there is no compiler. A MIR build uses the JIT only when
BNGSIM_CODEGEN_JIT=miris set (_codegen_jit_backendin_codegen.py). Without a fallback, a wheel with MIR in it still raisesCodegenToolchainErroron a machine with no compiler. Keepccfirst where it is present, sincecc -O3makes faster code, and use MIR where the compiler probe finds none.BNGSIM_CODEGEN_JIT=mirstill forces MIR. - Test the case MIR is for.
mir.ymlnever takes the compilers offPATH(its header says so), so nothing tests a machine with no compiler. Add a wheel smoke test that runs a sensitivity with an emptyPATHand an empty codegen cache, as in #1690's repro, and checks the answer against the closed form. - Refresh the vendored MIR first, or decide not to. #1490 is open: upstream merged aarch64 and x86-64 code-generation fixes after our pin. Shipping MIR to every user makes that refresh matter more.
- Update what says a compiler is needed. The README,
docs/installation.md, the sensitivities, steady-state and codegen guides, the agent guide's "What needs what" table, and thecapabilities()["missing"]["mir"]text. TheCodegenToolchainErrormessage should no longer be what a wheel user hits.
Done when
pip install bngsimon a machine with no C compiler runs forward sensitivities, and a wheel test checks it.ccis still used where it is present.- The docs and
capabilities()say a compiler is optional for wheel installs.
Closes #1690 when done. Part of #1689.
- Dominant language
- Python
- Stars
- 3
- Forks
- 6
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 295
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lanl/bngsim
-
testing
Difficulty 1/5 Under an hour Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
bug correctness concern
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
bug latent bug low priority
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
benchmarks/README: 'perl BNG2.pl model.bngl' runs the whole protocol, not just generate_networkOpendocumentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
software-mansion-labs/Diplomat#20 ·
Maintainers usually reply within 1 day
-
[Windows] Hidden title bar: a maximized window restored from minimized on a secondary monitor gets the primary monitor's work area as its client areaPossibly taken @lijy91 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
libnativeapi/nativeapi#53 · 1 reaction ·
Maintainers usually reply within 1 day
-
View Counts discarded due to field name mismatchPossibly taken @rsiva0400 claimed this today. Opensite-bug triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Model version publishes the new UK firm entity as a personPossibly taken @vahid-ahmadi claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
PolicyEngine/policyengine.py#764 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
spcl/HPCAgent-Bench#264 ·
Maintainers usually reply within 1 day