Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.

Conversation

@baggepinnen
Copy link
Contributor

The SciML function and the corresponding DifferentiationInterface function have different argument order

Vaibhavdixit02 and others added 4 commits August 23, 2024 06:38
Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.23.6 to 1.24.1.
- [Release notes](https://github.com/crate-ci/typos/releases)
- [Changelog](https://github.com/crate-ci/typos/blob/master/CHANGELOG.md)
- [Commits](crate-ci/typos@v1.23.6...v1.24.1)

---
updated-dependencies:
- dependency-name: crate-ci/typos
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
…e-ci/typos-1.24.1

Bump crate-ci/typos from 1.23.6 to 1.24.1
@Vaibhavdixit02
Copy link
Member

Can you change the target branch to v2 #96

@baggepinnen baggepinnen changed the base branch from main to v2 August 26, 2024 12:55
end
elseif cons_vjp == true && cons !== nothing
cons_vjp! = (J, θ, v) -> f.cons_vjp(J, θ, v, p)
cons_vjp! = (J, v, θ) -> f.cons_vjp(J, v, θ, p)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I don't think this is correct. We don't want to have this order as API too since it'll be inconsistent with jvp and be higher mental load.

What makes you think the current implementation is incorrect? https://gdalle.github.io/DifferentiationInterface.jl/DifferentiationInterface/dev/api/#DifferentiationInterface.pullback and https://github.com/jump-dev/MathOptInterface.jl/blob/cb1ad41c3a5ce1d12e83f2be60f10b191b0e22c5/src/nlp.jl#L762-L809 both match my understanding as well

I did spend a bit of time making sure the dimensions here were correct

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you call DI, the argument order is pullback!(cons_oop, J, adtype, θ, v, extras_pullback), but in SciML, the argument order is

- `cons_jvp(Jv,v,x,p)` or `Jv=cons_jvp(v,x,p)`: the Jacobian-vector product of the constraints.
- `cons_vjp(Jv,v,x,p)` or `Jv=cons_vjp(v,x,p)`: the Jacobian-vector product of the constraints.

https://github.com/SciML/SciMLBase.jl/blob/master/src/scimlfunctions.jl#L1833C1-L1834C96

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah lol so I missed the reference closest to home, I'll change that, this order makes less sense to me than the one used here. What do you think?

Copy link
Contributor Author

@baggepinnen baggepinnen Aug 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong opinion here. I'd almost expect v'J(x) to take args v, x and vice versa for J(x)*v, but having them be different might also be confusing. As long as SciML is internally consistent everywhere it can be whatever you prefer.

hv(Hv,u,v,p) or Hv=hv(u,v,p): the Hessian-vector product (d^2 f / du^2) v.takesvafteru, maybe change utox` to be consistent as well?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, thanks for pointing these out 🙌

@Vaibhavdixit02
Copy link
Member

The order of the argument in SciMLBase has been fixed so this isn't needed anymore, thanks for catching this @baggepinnen

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants