You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
)</code></pre><h2id="Batch-mode"><aclass="docs-heading-anchor" href="#Batch-mode">Batch mode</a><aid="Batch-mode-1"></a><aclass="docs-heading-anchor-permalink" href="#Batch-mode" title="Permalink"></a></h2><h3id="Multiple-tangents"><aclass="docs-heading-anchor" href="#Multiple-tangents">Multiple tangents</a><aid="Multiple-tangents-1"></a><aclass="docs-heading-anchor-permalink" href="#Multiple-tangents" title="Permalink"></a></h3><p>The <ahref="../../api/#DifferentiationInterface.jacobian"><code>jacobian</code></a> and <ahref="../../api/#DifferentiationInterface.hessian"><code>hessian</code></a> operators compute matrices by repeatedly applying lower-level operators (<ahref="../../api/#DifferentiationInterface.pushforward"><code>pushforward</code></a>, <ahref="../../api/#DifferentiationInterface.pullback"><code>pullback</code></a> or <ahref="../../api/#DifferentiationInterface.hvp"><code>hvp</code></a>) to a set of tangents. The tangents usually correspond to basis elements of the appropriate vector space. We could call the lower-level operator on each tangent separately, but some packages (<ahref="https://github.com/JuliaDiff/ForwardDiff.jl">ForwardDiff.jl</a> and <ahref="https://github.com/EnzymeAD/Enzyme.jl">Enzyme.jl</a>) have optimized implementations to handle multiple tangents at once.</p><p>This behavior is often called "vector mode" AD, but we call it "batch mode" to avoid confusion with Julia's <code>Vector</code> type. As a matter of fact, the optimal batch size <span>$B$</span> (number of simultaneous tangents) is usually very small, so tangents are passed within an <code>NTuple</code> and not a <code>Vector</code>. When the underlying vector space has dimension <span>$N$</span>, the operators <code>jacobian</code> and <code>hessian</code> process <span>$\lceil N / B \rceil$</span> batches of size <span>$B$</span> each.</p><h3id="Optimal-batch-size"><aclass="docs-heading-anchor" href="#Optimal-batch-size">Optimal batch size</a><aid="Optimal-batch-size-1"></a><aclass="docs-heading-anchor-permalink" href="#Optimal-batch-size" title="Permalink"></a></h3><p>For every backend which does not support batch mode, the batch size is set to <span>$B = 1$</span>. But for <ahref="https://sciml.github.io/ADTypes.jl/stable/#ADTypes.AutoForwardDiff"><code>AutoForwardDiff</code></a> and <ahref="https://sciml.github.io/ADTypes.jl/stable/#ADTypes.AutoEnzyme"><code>AutoEnzyme</code></a>, more complicated rules apply. If the backend object has a pre-determined batch size <span>$B_0$</span>, then we always set <span>$B = B_0$</span>. In particular, this will throw errors when <span>$N < B_0$</span>. On the other hand, without a pre-determined batch size, we apply backend-specific heuristics to pick <span>$B$</span> based on <span>$N$</span>.</p></article><navclass="docs-footer"><aclass="docs-footer-prevpage" href="../backends/">« Backends</a><aclass="docs-footer-nextpage" href="../../faq/limitations/">Limitations »</a><divclass="flexbox-break"></div><pclass="footer-message">Powered by <ahref="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <ahref="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><divclass="modal" id="documenter-settings"><divclass="modal-background"></div><divclass="modal-card"><headerclass="modal-card-head"><pclass="modal-card-title">Settings</p><buttonclass="delete"></button></header><sectionclass="modal-card-body"><p><labelclass="label">Theme</label><divclass="select"><selectid="documenter-themepicker"><optionvalue="auto">Automatic (OS)</option><optionvalue="documenter-light">documenter-light</option><optionvalue="documenter-dark">documenter-dark</option><optionvalue="catppuccin-latte">catppuccin-latte</option><optionvalue="catppuccin-frappe">catppuccin-frappe</option><optionvalue="catppuccin-macchiato">catppuccin-macchiato</option><optionvalue="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <ahref="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.16.1 on <spanclass="colophon-date" title="Wednesday 18 February 2026 17:19">Wednesday 18 February 2026</span>. Using Julia version 1.12.5.</p></section><footerclass="modal-card-foot"></footer></div></div></div></body></html>
9
+
)</code></pre><h2id="Batch-mode"><aclass="docs-heading-anchor" href="#Batch-mode">Batch mode</a><aid="Batch-mode-1"></a><aclass="docs-heading-anchor-permalink" href="#Batch-mode" title="Permalink"></a></h2><h3id="Multiple-tangents"><aclass="docs-heading-anchor" href="#Multiple-tangents">Multiple tangents</a><aid="Multiple-tangents-1"></a><aclass="docs-heading-anchor-permalink" href="#Multiple-tangents" title="Permalink"></a></h3><p>The <ahref="../../api/#DifferentiationInterface.jacobian"><code>jacobian</code></a> and <ahref="../../api/#DifferentiationInterface.hessian"><code>hessian</code></a> operators compute matrices by repeatedly applying lower-level operators (<ahref="../../api/#DifferentiationInterface.pushforward"><code>pushforward</code></a>, <ahref="../../api/#DifferentiationInterface.pullback"><code>pullback</code></a> or <ahref="../../api/#DifferentiationInterface.hvp"><code>hvp</code></a>) to a set of tangents. The tangents usually correspond to basis elements of the appropriate vector space. We could call the lower-level operator on each tangent separately, but some packages (<ahref="https://github.com/JuliaDiff/ForwardDiff.jl">ForwardDiff.jl</a> and <ahref="https://github.com/EnzymeAD/Enzyme.jl">Enzyme.jl</a>) have optimized implementations to handle multiple tangents at once.</p><p>This behavior is often called "vector mode" AD, but we call it "batch mode" to avoid confusion with Julia's <code>Vector</code> type. As a matter of fact, the optimal batch size <span>$B$</span> (number of simultaneous tangents) is usually very small, so tangents are passed within an <code>NTuple</code> and not a <code>Vector</code>. When the underlying vector space has dimension <span>$N$</span>, the operators <code>jacobian</code> and <code>hessian</code> process <span>$\lceil N / B \rceil$</span> batches of size <span>$B$</span> each.</p><h3id="Optimal-batch-size"><aclass="docs-heading-anchor" href="#Optimal-batch-size">Optimal batch size</a><aid="Optimal-batch-size-1"></a><aclass="docs-heading-anchor-permalink" href="#Optimal-batch-size" title="Permalink"></a></h3><p>For every backend which does not support batch mode, the batch size is set to <span>$B = 1$</span>. But for <ahref="https://sciml.github.io/ADTypes.jl/stable/#ADTypes.AutoForwardDiff"><code>AutoForwardDiff</code></a> and <ahref="https://sciml.github.io/ADTypes.jl/stable/#ADTypes.AutoEnzyme"><code>AutoEnzyme</code></a>, more complicated rules apply. If the backend object has a pre-determined batch size <span>$B_0$</span>, then we always set <span>$B = B_0$</span>. In particular, this will throw errors when <span>$N < B_0$</span>. On the other hand, without a pre-determined batch size, we apply backend-specific heuristics to pick <span>$B$</span> based on <span>$N$</span>.</p></article><navclass="docs-footer"><aclass="docs-footer-prevpage" href="../backends/">« Backends</a><aclass="docs-footer-nextpage" href="../../faq/limitations/">Limitations »</a><divclass="flexbox-break"></div><pclass="footer-message">Powered by <ahref="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> and the <ahref="https://julialang.org/">Julia Programming Language</a>.</p></nav></div><divclass="modal" id="documenter-settings"><divclass="modal-background"></div><divclass="modal-card"><headerclass="modal-card-head"><pclass="modal-card-title">Settings</p><buttonclass="delete"></button></header><sectionclass="modal-card-body"><p><labelclass="label">Theme</label><divclass="select"><selectid="documenter-themepicker"><optionvalue="auto">Automatic (OS)</option><optionvalue="documenter-light">documenter-light</option><optionvalue="documenter-dark">documenter-dark</option><optionvalue="catppuccin-latte">catppuccin-latte</option><optionvalue="catppuccin-frappe">catppuccin-frappe</option><optionvalue="catppuccin-macchiato">catppuccin-macchiato</option><optionvalue="catppuccin-mocha">catppuccin-mocha</option></select></div></p><hr/><p>This document was generated with <ahref="https://github.com/JuliaDocs/Documenter.jl">Documenter.jl</a> version 1.17.0 on <spanclass="colophon-date" title="Tuesday 3 March 2026 12:25">Tuesday 3 March 2026</span>. Using Julia version 1.12.5.</p></section><footerclass="modal-card-foot"></footer></div></div></div></body></html>
0 commit comments