Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

`pick_batchsize` spends ~1 µs constructing `BatchSizeSettings{B}(N)` with a run-time `B`

Open Beginner friendly
#1,075 0 comments 0 reactions 0 assignees View on GitHub

@devmotion is already working on this.

Since Oct 5, 2026.

  • #1076 by @devmotion — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
julia
Domain
performance

Research direction

Read pick_batchsize(::AutoForwardDiff{nothing}, N) and pick_batchsize(::AutoEnzyme, N) in DifferentiationInterface, then run the supplied benchmark on Julia 1.12.7. Compare the batch-size settings and timings against the concrete-type example; done looks like equivalent settings with lower overhead for batch-size selection and the reported sparse-Jacobian operations.

Written by the indexing model from the issue text.

Description

pick_batchsize(::AutoForwardDiff{nothing}, N) and pick_batchsize(::AutoEnzyme, N) call BatchSizeSettings{B}(N) with a B that is only known at run time. On Julia 1.12.7 with DI 0.7.17 this takes about 1.1 µs. Computing all type parameters first and calling the concrete type gives the same value in about 0.13 µs:

using DifferentiationInterface, ForwardDiff, Chairmarks
const DI = DifferentiationInterface

partial(B, N) = DI.BatchSizeSettings{B}(N)
function concrete(B, N)
    singlebatch = B == N
    aligned = (B == N == 0) || (N % B == 0)
    return DI.BatchSizeSettings{B, singlebatch, aligned}(N)
end
@assert partial(1, 1) === concrete(1, 1) && partial(8, 13) === concrete(8, 13)

@be 1 DI.pick_batchsize(AutoForwardDiff(), _)                 # 1145 ns, 6 allocs
@be 1 DI.pick_batchsize(AutoForwardDiff(; chunksize = 1), _)  #  746 ns, 2 allocs
@be 1 partial(_, _)                                           # 1138 ns, 6 allocs
@be 1 concrete(_, _)                                          #  128 ns, 1 alloc

This dominates unprepared sparse Jacobians of cheap functions. For f!(y, x) = (y .= 2 .* x) with n = 8, a known diagonal pattern and GreedyColoringAlgorithm(), using concrete in pick_batchsize(::AutoForwardDiff{nothing}, N) takes jacobian!(f!, y, J, backend, x) from 1.88 µs to 0.72 µs and prepare_jacobian from 1.71 µs to 0.56 µs.

Dominant language
Julia
Stars
314
Forks
36
Avg merge
2h 14m
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from JuliaDiff/DifferentiationInterface.jl

All issues in JuliaDiff/DifferentiationInterface.jl

Similar issues

More Julia issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.