Skip to content

compile one observed function for all CopyParamsByTemplate fallback batches#4692

Merged
AayushSabharwal merged 2 commits into
SciML:masterfrom
KristofferC:kc/one_copy_params_f
Jul 1, 2026
Merged

compile one observed function for all CopyParamsByTemplate fallback batches#4692
AayushSabharwal merged 2 commits into
SciML:masterfrom
KristofferC:kc/one_copy_params_f

Conversation

@KristofferC

Copy link
Copy Markdown
Contributor

CopyParamsByTemplate compiled a separate observed function for each
non-contiguous batch of symbolic-fallback parameters. Each compile pays
build_function_wrapper's large fixed per-call cost, so N batches cost N
times that overhead. Compile a single observed function over all fallback
symbols instead, and have FallbackSlice template entries index into its
result.

This takes a fairly large model from

9.754838 seconds (152.03 M allocations: 5.776 GiB, 13.88% gc time, 0.00% compilation time)

to

8.626415 seconds (142.11 M allocations: 5.325 GiB, 13.98% gc time, 0.00% compilation time)

… batches

`CopyParamsByTemplate` compiled a separate observed function for each
non-contiguous batch of symbolic-fallback parameters. Each compile pays
`build_function_wrapper`'s large fixed per-call cost, so N batches cost N
times that overhead. Compile a single observed function over all fallback
symbols instead, and have `FallbackSlice` template entries index into its
result.
@AayushSabharwal AayushSabharwal merged commit ff57cab into SciML:master Jul 1, 2026
69 of 89 checks passed
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.

2 participants