Skip to content

refactor(autojac): Stop cloning in Accumulate#511

Merged
ValerianRey merged 1 commit intomainfrom
stop-cloning-in-accumulate
Jan 8, 2026
Merged

refactor(autojac): Stop cloning in Accumulate#511
ValerianRey merged 1 commit intomainfrom
stop-cloning-in-accumulate

Conversation

@ValerianRey
Copy link
Copy Markdown
Contributor

This follows our discussion on whether we should clone or not in Accumulate. The change alone made a test fail, but this test was precisely a very weird usage of Accumulate, where the same tensor dict is accumulated multiple times. So I also changed the test. I think this could have a benefit on memory usage, but not sure if this benefit can happen when memory is at its peak usage (at this point, the Jacobian should be aggregated already, so not in memory anymore, so maybe we don't care that much about an extra gradient in memory there until the completion of this function). But I remember correctly, we used to have some out of memory errors during the Accumulate call, so I might be wrong about this.

Anyway, it seems like a strict improvement.

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

codecov bot commented Jan 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

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

@ValerianRey ValerianRey merged commit 502973f into main Jan 8, 2026
13 checks passed
@ValerianRey ValerianRey deleted the stop-cloning-in-accumulate branch January 28, 2026 15:56
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.

2 participants