perf: batch array-valued distribution parameters into a single fill - #171
Open
vchamarthi wants to merge 1 commit into
Open
perf: batch array-valued distribution parameters into a single fill#171vchamarthi wants to merge 1 commit into
vchamarthi wants to merge 1 commit into
Conversation
vchamarthi
requested review from
antonwolfy,
jharlow-intel,
ndgrigorian,
vlad-perevezentsev and
xaleryb
as code owners
September 4, 2026 03:42
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
When a distribution parameter is an array rather than a scalar,
vec_cont1_array/vec_cont2_arrayinvoke the fill once per element:That is 100,000 VSL calls for a 100,000-element array.
For location and scale families the parameters can be applied after the draw
instead, so one call covers the whole request:
These are exact identities, not approximations.
Routed:
normal,uniform,exponential,laplace,gumbel,logistic,rayleigh,lognormal.Not routed:
gamma,beta,f,chisquare,vonmises,wald,triangular,pareto,weibull,power, and the discrete distributions.Their parameters change the shape, so no affine step recovers them.
gammaiskept in the benchmark below as a control.
Numbers
Xeon Gold 6338, single thread, N=100k, ns/element, min of 2 runs. Intel-channel
mkl/mkl-devel2026.1.0-intel_236, meson build. Baseline and patchedinstalled in separate conda envs.
Scalar-parameter paths are untouched and not measured here.
Streams change
Array-parameter streams change: the draw is now standardised and transformed
rather than parameterised up front. Scalar-parameter paths are byte-identical.
Noted in the changelog.
Testing
master, so they are invariant guards rather than fitted to this change.
assert_allclose).crit 0.00364: all pass.
sizehandling and error cases compared against stocknumpy: agree, including incompatible
sizeraisingValueError.6b7962f.Notes for reviewers
_param_out_shapereimplements the shape and compatibility logic rather thanreusing the multi-iterator, since the batched path has no iterator. It raises
ValueError("size is not compatible with inputs")where the old pathsurfaced numpy's broadcast error text for some inputs. Same exception type,
different message.
lognormalis built on the normal fill, not the lognormal one: its parameterssit inside the exponential, so an affine step cannot apply them to a
standardised lognormal.
test_uniform_array_bounds_return_ndarraycovers this path and stillpasses.