Repository navigation
Fix linearize without inputs and name differentiated inputs from the linearization function - #5225
Merged
Merged
Conversation
…e linearization function `linearize(sys, [], outputs)` failed in ForwardDiff with an invalid tag, since the Jacobians with respect to the inputs were prepared for an empty, `Any`-typed input vector. The input vector now has the element type of the state and the input Jacobians are not evaluated when there are no inputs, so that `B` and `D` have zero columns. `LinearizationFunction` stores its input symbols, from which the diagnostic for differentiated inputs takes their names; it previously indexed `inputs(sys)`, which is empty when the inputs of a compiled system are parameters not marked as inputs. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QBgBrXDidWG1G2KF64gAte
Contributor
Benchmark Results (Julia vlts)Time benchmarks
Memory benchmarks
|
Contributor
Benchmark Results (Julia v1)Time benchmarks
Memory benchmarks
|
AayushSabharwal
approved these changes
Sep 29, 2026
|
It seems this fixes #4886 as well, but I'll let you confirm. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Split out of #5173.
Summary
Two fixes in
linearize:linearize(sys, [], outputs)failed in ForwardDiff withInvalid Tag object, since the Jacobians with respect to the inputs were prepared and evaluated for an empty,Any-typed input vector. The input vector now has the element type of the state, and the input Jacobians are not evaluated when there are no inputs;BandDthen have zero columns. The case without unknowns and inputs, which produced anh_xzof the wrong shape, is handled as well.LinearizationFunctionstores its input symbols, and the diagnostic for differentiated inputs names them from there. It previously indexedinputs(sys), which is empty when the inputs of a compiled system are parameters that are not marked as inputs, and threw aBoundsErrorin place of the message.Tests
The testset "Linearization without inputs" in
test/linearize.jlcovers both backends and the case without unknowns; it fails onmasterwith the tag error and passes with this change.🤖 Generated with Claude Code
https://claude.ai/code/session_01QBgBrXDidWG1G2KF64gAte