Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp batch size handling #575

Merged
merged 25 commits into from
Oct 14, 2024
Merged

Revamp batch size handling #575

merged 25 commits into from
Oct 14, 2024

Conversation

gdalle
Copy link
Member

@gdalle gdalle commented Oct 13, 2024

Versions

  • Bump DI to v0.6.13

DI source

  • Define BatchSizeSettings to store every necessary information about batches:
    • batch size B
    • whether we need a single batch or several
    • whether the batch size is aligned with the input size (zero remainder)
  • Revamp jacobian and hessian to use these BatchSizeSettings. Add a custom out-of-place jacobian and hessian for the single-batch case which does not use mapreduce
  • Add reasonable batch size selector borrowed from ForwardDiff, to use in Enzyme so that x = ones(17) requires 2 batches of 9 instead of 2 batches of 16.
  • Throw errors on traits and batch size selection for AutoSparse and SecondOrder

DI extensions

  • ForwardDiff (and PolyesterForwardDiff): Implement BatchSizeSettings
  • Enzyme: Implement BatchSizeSettings
  • StaticArrays:
    • Implement custom row stacking (only column stacking was available so far)
    • Override BatchSizeSettings for x::StaticArray and backend::Union{AutoForwardDiff{nothing},AutoEnzyme} to take batch size = input length
  • SparseMatrixColorings:
    • Revamp jacobian and hessian to use BatchSizeSettings
    • Perform batch size selection based on the number of groups, not the total number of dimensions!!!

DI docs

  • Discuss batching in the advanced explanations

DIT source

  • Improve scenario batch size thresholding

@codecov-commenter
Copy link

codecov-commenter commented Oct 13, 2024

Codecov Report

Attention: Patch coverage is 96.60194% with 7 lines in your changes missing coverage. Please review.

Project coverage is 97.48%. Comparing base (fd7580c) to head (0e43dd5).

Files with missing lines Patch % Lines
...fferentiationInterface/src/first_order/jacobian.jl 93.47% 3 Missing ⚠️
...DifferentiationInterfacePolyesterForwardDiffExt.jl 33.33% 2 Missing ⚠️
...raysExt/DifferentiationInterfaceStaticArraysExt.jl 71.42% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #575      +/-   ##
==========================================
- Coverage   97.52%   97.48%   -0.04%     
==========================================
  Files         108      109       +1     
  Lines        4970     5050      +80     
==========================================
+ Hits         4847     4923      +76     
- Misses        123      127       +4     
Flag Coverage Δ
DI 98.59% <96.46%> (-0.09%) ⬇️
DIT 95.17% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gdalle gdalle marked this pull request as draft October 13, 2024 19:13
@gdalle gdalle changed the title Revamp batch size selection Revamp batch size selection + improve Enzyme for StaticArrays Oct 14, 2024
@gdalle gdalle changed the title Revamp batch size selection + improve Enzyme for StaticArrays Revamp batch size handling Oct 14, 2024
@gdalle gdalle marked this pull request as ready for review October 14, 2024 16:03
@gdalle gdalle merged commit 4496997 into main Oct 14, 2024
43 checks passed
@gdalle gdalle deleted the gd/batch branch October 14, 2024 20:06
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.

2 participants