Skip to content

refactor(autojac): Remove reshaping to/from matrix in Jac#420

Merged
ValerianRey merged 3 commits intomainfrom
simplify-autojac
Sep 14, 2025
Merged

refactor(autojac): Remove reshaping to/from matrix in Jac#420
ValerianRey merged 3 commits intomainfrom
simplify-autojac

Conversation

@ValerianRey
Copy link
Copy Markdown
Contributor

@ValerianRey ValerianRey commented Sep 13, 2025

  • Stop reshaping Jacobians in Jac
  • Factorize _get_vjp between Grad and Jac
  • Add changelog entry

Since the first commit also made _get_vjp be the same between Grad and Jac, I also factorized them.

@ValerianRey ValerianRey added package: autojac cc: refactor Conventional commit type for any refactoring, not user-facing, and not typing or perf improvements labels Sep 13, 2025
@ValerianRey ValerianRey self-assigned this Sep 13, 2025
@ValerianRey ValerianRey added package: autojac cc: refactor Conventional commit type for any refactoring, not user-facing, and not typing or perf improvements labels Sep 13, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Sep 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/torchjd/autojac/_transform/_differentiate.py 100.00% <100.00%> (ø)
src/torchjd/autojac/_transform/_grad.py 100.00% <100.00%> (ø)
src/torchjd/autojac/_transform/_jac.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@PierreQuinton PierreQuinton left a comment

Choose a reason for hiding this comment

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

I don't remember why we have all this things with chunks rather than using chunk_size of vmap (For the chunk_size=1 I get it). I guess there was a good reason to have that so LGTM.

@ValerianRey
Copy link
Copy Markdown
Contributor Author

I don't remember why we have all this things with chunks rather than using chunk_size of vmap (For the chunk_size=1 I get it). I guess there was a good reason to have that so LGTM.

2 reasons IIRC:

  • Avoid using vmap when chunk_size=1, because some modules like RNNs on some version of cuda are not compatible with vmap
  • Be able to not retain graph for the last chunk

@PierreQuinton
Copy link
Copy Markdown
Contributor

Right, this is quite nasty. Good thing we have one memory for two. I think this can be merged, unless we should test some more?

@ValerianRey
Copy link
Copy Markdown
Contributor Author

Yes ready to merge.

@ValerianRey ValerianRey merged commit 5acab1d into main Sep 14, 2025
17 checks passed
@ValerianRey ValerianRey deleted the simplify-autojac branch September 14, 2025 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cc: refactor Conventional commit type for any refactoring, not user-facing, and not typing or perf improvements package: autojac

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No need to reshape to and from matrix in Jac

2 participants