Skip to content

Propagate ParameterArrayAssignments to SCC subsystems#4698

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

Propagate ParameterArrayAssignments to SCC subsystems#4698
AayushSabharwal merged 2 commits into
SciML:masterfrom
KristofferC:kc/parameter_array_assignment_propagate_scc_subsystem

Conversation

@KristofferC

Copy link
Copy Markdown
Contributor

This PR is on top of #4697 because it is kind of the same idea. The difference here is that we need to do a little bit of bookkeeping to keep track of the extra cachesyms that each subsystem appends.

This takes ODEProblem construction for a somewhat large model from

6.921406 seconds (108.02 M allocations: 4.142 GiB, 13.60% gc time)

to

  5.740030 seconds (93.43 M allocations: 3.779 GiB, 10.40% gc time)

AI-generated commit message:


🤖

The parameter array-variable decomposition computed by
compute_array_variable_buffer_idxs is, like the parameter reordering, a pure
function of the shared parameter layout. Compute the param-only decomposition
once and propagate it to every SCC subsystem.

The per-SCC callers (generate_rhs, generate_update_A, generate_update_b)
append cachesyms as a suffix of the parameter slice, so the cache stores only
the parameter buffers and build_function_wrapper decomposes the (small)
cachesym tail on top of the cached result, shifting its slice-relative buffer
indices past the parameter buffers. The callers pass n_param_buffers (the
number of reorder_parameters buffers before the cachesyms) to mark the
boundary. cachesyms are prior-SCC unknowns / CSE temporaries -- never array
parameters -- so their array-variable keyset is disjoint from the parameters',
making the split identical to decomposing the whole slice.


The parameter array-variable decomposition computed by
`compute_array_variable_buffer_idxs` is, like the parameter reordering, a pure
function of the shared parameter layout. Compute the param-only decomposition
once and propagate it to every SCC subsystem.

The per-SCC callers (`generate_rhs`, `generate_update_A`, `generate_update_b`)
append `cachesyms` as a suffix of the parameter slice, so the cache stores only
the parameter buffers and `build_function_wrapper` decomposes the (small)
cachesym tail on top of the cached result, shifting its slice-relative buffer
indices past the parameter buffers. The callers pass `n_param_buffers` (the
number of `reorder_parameters` buffers before the cachesyms) to mark the
boundary. cachesyms are prior-SCC unknowns / CSE temporaries -- never array
parameters -- so their array-variable keyset is disjoint from the parameters',
making the split identical to decomposing the whole slice.
@AayushSabharwal AayushSabharwal merged commit 652839b 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