Skip to content

Stack vector field inputs and batch network calls in ArrayDiscretization - #680

Merged
utkuyilmaz1903 merged 1 commit into
SciML:masterfrom
utkuyilmaz1903:multi-field-network-input
Sep 5, 2026
Merged

utkuyilmaz1903 merged 1 commit into
SciML:masterfrom
utkuyilmaz1903:multi-field-network-input

Conversation

@utkuyilmaz1903

Copy link
Copy Markdown
Member

Vector field inputs f([u, v], θ) and f([u, v], θ)[i] now stay in array form. The slices are stacked along a leading axis (array_stack, (k, n...)), so the interior is still one array equation per field and the expression size does not depend on the grid. Any callable works; by default it is applied point by point on X[:, I].

Networks from ModelingToolkitNeuralNets are evaluated in one batched call instead. A small package extension sets batched_callable from the public isneuralnetwork accessor; the runtime passes the whole (k, n...) array to the network (Lux takes one column per sample) and selects output row i. NN(u, θ) is batched too; results agree with the previous point-by-point evaluation to 1e-8 in the tests, so roundoff-level differences are possible.

interior array eqs
vecfn([u, v], θ), registered scalar function 2 matches the symbolic θ[1] u v form to 1e-8 on the DAE path, 1e-6 through mtkcompile
f([u, v], θ)[i], callable parameter 2 same numbers, point by point
NN([u, v], θ)[i] 2 batched; matches the same network without the metadata (point by point) to 1e-8
NN([u], θ)[1] 1 stack of one slice
Brusselator with NN([u, v], θ), periodic 2 the seam points stay pointwise, their count is grid independent
2D grid, both callables 2
f([u, 1.0], θ) 0 falls back: inputs must be slices of one shape

RHS evaluation, batched vs point by point, same network:

grid points single field two fields
101 21 μs vs 84 μs 38 μs vs 181 μs
1001 491 μs vs 1357 μs 1013 μs vs 2170 μs

Not covered: scalar inputs mixed with slices ([u, t]), and θ in any position other than second. Next: a Brusselator UDE section in the tutorial.

@utkuyilmaz1903
utkuyilmaz1903 marked this pull request as ready for review September 5, 2026 16:19
@utkuyilmaz1903
utkuyilmaz1903 merged commit c383e04 into SciML:master Sep 5, 2026
72 checks passed
@utkuyilmaz1903
utkuyilmaz1903 deleted the multi-field-network-input branch September 5, 2026 16:34
ChrisRackauckas added a commit that referenced this pull request Sep 7, 2026
- Trim the array-form capability list from MOLFiniteDifference. (#673)
- Stop infinite expansion when a PDE unknown is missing from the system. (#674)
- Support vector-valued functions in ArrayDiscretization (#675)
- Test ModelingToolkitNeuralNets terms and fix the compiled ODE path (#678)
- Add a tutorial on training a neural network term in a PDE (#679)
- Stack vector field inputs and batch network calls in ArrayDiscretization (#680)
- Add a tutorial on learning the Brusselator reaction with a neural network (#681)
- Stack scalar inputs with field slices in ArrayDiscretization (#682)
- Test callable diffusion coefficients (#683)
- Reconstruct array observables once per PDE field (#676)



Agent-Harness: Claude Code
Agent-Model: claude-opus-5[1m]
Claude-Session: https://claude.ai/code/session_014FEzNTLFutCmTEAZ3zBg5R

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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