Skip to content

compile_all: a template for compiling everything a package provides - #312

Merged
sshin23 merged 2 commits into
anvil/rename-compilerfrom
anvil/compile-all
Aug 14, 2026
Merged

compile_all: a template for compiling everything a package provides#312
sshin23 merged 2 commits into
anvil/rename-compilerfrom
anvil/compile-all

Conversation

@sshin23

@sshin23 sshin23 commented Aug 14, 2026

Copy link
Copy Markdown
Member

Stacked on #311 (base is that branch) so it can land after it, or fold in if you'd rather.

ExaModelsCompiler declares the verb and owns the keyword contract; a package that ships models implements it for itself in an extension, so providing models never costs a dependency on a compiler toolchain — a benchmark set is a modelling package, and juliac is not something you should acquire by loading one.

compile_all(LuksanVlcekBenchmark; path = "@lvb", sizes = 1000)

Callers name the package; providers implement compile_all(::Val{TheirModule}; …). Val is the uniform handle — every provider spells it the same way, and it works for a package that has no marker type of its own (ExaModelsPower has none today). The module method is a one-line wrapper over it.

One library rather than one per model, because sizes are deferred: the models share a runtime, one compile amortises across all of them, and a consumer selects with CNLPModel(lib, :bearing, n).

Verification

Against LuksanVlcekBenchmark on its recipes branch, with a draft extension over its eighteen models: compiled :rosenrock and :broyden_banded into one library, instantiated both at a size never compiled (37), exact against the in-Julia models on objective and gradient. ExaModelsCompiler suite 246/246.

The docstring carries a complete worked extension (weakdeps stanza, ext module, the argument-function spelling for data-defined models) so a provider implements it by copying. @ohm and @nabla are testing it against ExaModelsPower and COPS/LVB respectively — emp is the interesting case, since its models take an argument function rather than sizes.

🤖 Generated with Claude Code

ExaModelsCompiler declares the verb and owns its keyword contract —
path, only, exclude, and whatever compile_library takes; a package that
ships models implements the Val form for itself in an extension, so
providing models never costs a dependency on a compiler toolchain.
Callers name the package: compile_all(LuksanVlcekBenchmark; path =
"@lvb"), which forwards to the Val method.

select(models; only, exclude) is the shared half, so every provider
offers the same filtering and a typo is refused rather than quietly
compiling a library with a model missing.

Verified against LuksanVlcekBenchmark on its recipes branch: a draft
extension over its eighteen models compiled two of them at a size never
compiled, exact against the in-Julia models on objective and gradient,
with an unknown name in only= refused before any compiling. Suite 246.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Your PR requires formatting changes to meet the project's style guidelines.

Please run:

julia --project=@runic -e 'using Pkg; Pkg.add("Runic")'
julia --project=@runic -e "using Runic; exit(Runic.main(ARGS))" -- --fix <files>

(or git runic anvil/rename-compiler if you have the git wrapper installed)

Note: the full diff is omitted because it can exceed GitHub Actions input limits.

A two-line filter does not earn hub API. The docstring's worked example
no longer advertises only/exclude as a shared contract; a provider that
wants filtering writes it in its own extension, as the LVB draft does.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results


Relative timing: current / main  (values < 1.0 are improvements)

================================================================================
  backend-instance-param          |      obj     cons     grad      jac     hess
================================================================================
  CUDA-OPF-case1354               |    1.003    0.990    0.992    0.978    0.982
  CUDA-OPF-case14                 |    1.023    0.976    0.987    0.990    0.992
  CUDA-OPF-case30000              |    1.051    0.978    0.980    0.995    0.986
  CUDA-chain-10                   |    1.019    0.999    0.982    0.985    0.997
  CUDA-chain-100                  |    0.949    0.989    0.979    0.980    0.984
  CUDA-chain-1000                 |    1.011    1.003    0.994    0.981    0.990
  CUDA-elec-10                    |    1.004    0.985    0.987    0.990    0.988
  CUDA-elec-100                   |    0.974    1.104    1.001    0.995    0.994
  CUDA-elec-1000                  |    1.033    0.939    3.138    0.993   51.854
  CUDA-rosenrock-1000             |    0.988    0.990    0.980    1.001    1.007
  CUDA-rosenrock-10000            |    0.990    0.997    0.982    0.986    0.974
  CUDA-rosenrock-100000           |    1.000    1.000    0.988    0.990    1.013
--------------------------------------------------------------------------------
  AMDGPU-OPF-case1354             |    1.015    0.954    1.049    0.974    1.008
  AMDGPU-OPF-case14               |    1.024    1.015    0.998    0.990    1.007
  AMDGPU-OPF-case30000            |    1.022    1.000    1.000    1.029    1.008
  AMDGPU-chain-10                 |    0.983    0.960    0.989    0.985    0.972
  AMDGPU-chain-100                |    1.004    0.988    0.945    1.002    1.045
  AMDGPU-chain-1000               |    1.003    0.979    0.982    1.033    1.025
  AMDGPU-elec-10                  |    1.041    0.934    0.983    0.996    0.967
  AMDGPU-elec-100                 |    1.034    0.978    1.026    0.996    0.999
  AMDGPU-elec-1000                |    1.013    0.987    1.181    1.003    1.169
  AMDGPU-rosenrock-1000           |    1.003    0.955    0.998    0.966    1.062
  AMDGPU-rosenrock-10000          |    0.950    0.951    0.998    0.974    0.985
  AMDGPU-rosenrock-100000         |    1.440    0.965    1.003    0.960    0.735
--------------------------------------------------------------------------------
  oneAPI-OPF-case1354             |    1.027    2.649    1.497    1.981    1.480
  oneAPI-OPF-case14               |    1.133    0.752    1.574    2.987    2.378
  oneAPI-OPF-case30000            |    4.799    3.819    4.011    1.369    1.312
  oneAPI-chain-10                 |    1.428    5.655    6.817    2.522    6.039
  oneAPI-chain-100                |    1.987    1.404    1.639    1.477    1.191
  oneAPI-chain-1000               |    1.031    1.462    3.264    5.383    2.117
  oneAPI-elec-10                  |    0.891    1.281    2.683    2.781    2.297
  oneAPI-elec-100                 |    0.745    1.619    1.063    2.455    1.443
  oneAPI-elec-1000                |    0.925    1.009    0.964    1.424    0.613
  oneAPI-rosenrock-1000           |    1.252    1.736    2.460    9.476    0.326
  oneAPI-rosenrock-10000          |    4.170    1.085    1.254    1.746    2.065
  oneAPI-rosenrock-100000         |    2.338    1.196    0.859    2.631    1.158
--------------------------------------------------------------------------------
  nothing-OPF-case1354            |    1.027    1.006    1.062    1.026    0.642
  nothing-OPF-case14              |    1.062    1.055    0.967    1.086    1.000
  nothing-OPF-case30000           |    1.007    0.999    1.004    0.990    1.013
  nothing-chain-10                |    1.000    1.011    0.858    0.952    2.230
  nothing-chain-100               |    0.998    0.945    0.879    1.016    1.004
  nothing-chain-1000              |    0.948    0.944    0.943    0.998    1.060
  nothing-elec-10                 |    1.067    1.043    1.010    1.076    1.015
  nothing-elec-100                |    1.006    1.014    1.061    1.057    1.013
  nothing-elec-1000               |    0.999    1.000    1.000    0.999    0.987
  nothing-rosenrock-1000          |    1.013    1.002    1.004    0.976    1.005
  nothing-rosenrock-10000         |    1.003    1.001    0.999    0.980    1.894
  nothing-rosenrock-100000        |    1.010    1.001    0.999    0.982    0.337
================================================================================

@sshin23
sshin23 merged commit 5ca97cb into anvil/rename-compiler Aug 14, 2026
17 checks passed
@sshin23
sshin23 deleted the anvil/compile-all branch August 14, 2026 10:32
@sshin23

sshin23 commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

Two commits since the last review state:

  • a23e698d drops select — a two-line filter does not earn hub API; providers filter their own lists.
  • 4d367dc8 makes the emitted library self-describing, answering the two questions a caller holding only a path could not ask: cnlp_nmodels / cnlp_model_name (the catalogue — the only fixed-name symbols, since every per-model entry point needs a prefix and this is where a prefix comes from) and P_argtype (what a model instantiates from, as a typed signature with optional descriptions — "int|size", "string|…", or a structured model's full field list; every model answers, schema or not, and the signature identifies the entry point without symbol probing).

Gate on the tip: 242/242, including signature assertions for all four instantiation surfaces.

Consumer counterparts are on both masters (CNLPModels.jl d4070e5, cnlpmodels-py 45d3f08): available_models, argtype, schema answering nothing instead of throwing for models without one — plus, Julia-side, the two standard-API methods ExaModel had and CNLPModel lacked: cons_nln! and hprod! (assembled COO Hessian-vector product, the piece matrix-free solvers need).

🤖 Generated with Claude Code

@sshin23

sshin23 commented Aug 14, 2026

Copy link
Copy Markdown
Member Author

This merge landed on anvil/rename-compiler after #311 had already carried that branch into main, so none of it reached main — and the catalogue/argtype commit was pushed after the merge snapshot. Superseded by #313, which is the same three commits cherry-picked onto current main and re-gated there (242/242).

🤖 Generated with Claude Code

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