Vector API and dot product
Paul Sandoz
paul.sandoz at oracle.com
Wed Jan 4 00:16:11 UTC 2023
Hi Chris,
I can see the appeal but I would be reluctant to in effect add just one BLAS level 1 routine [1], perhaps awkwardly located in Arrays (which would almost certainly be the wrong location if there was ever a concerted effort to add a more complete set of BLAS routines to the JDK.)
We would have to consider a few variants for float, double, mixed precision, extended precision (there’s probably good reasons why they are present in LAPACK), and we would need to be vague on the accuracy and reproducibility. We would also likely have to cover primitive arrays and memory segments. Its use with matrix multiply is limited given there are more optimal choices for matrix multiply kernels.
IMO the right time to consider such functionality would be if we ever added an array-like abstraction. Perhaps Valhalla can help us get closer to that. In the interim I would prefer not to do anything specific in the platform.
Paul.
[1]
https://netlib.org/lapack/explore-html/df/d28/group__single__blas__level1_ga37a14d8598319955b711af0d64a6f56e.html
> On Dec 12, 2022, at 6:33 AM, Chris Hegarty <chegar999 at gmail.com> wrote:
>
> Hi,
>
> I'm sure that this must have come up before, but I cannot find it so I'm asking here.
>
> Over in Elasticsearch and Lucene we've been experimenting a little with the incubating Vector API, for use-cases relating to Approximate Nearest Neighbour vector search. We see approx 4x performance improvement in some experiments - which is amazing. Thank you. By far, our most significant use-case is dot product of two k dimensional vectors - float/double arrays.
>
> The Vector API is low-level and incredibly flexible, and will be a great addition to the Platform when it eventually moves out of incubation. But, since dot product is an extremely common operation it could be helpful to provide a "convenience" for it out-of-the-box, say Math.dot(float[], float[]) [*], etc.
>
> Ultimately, I believe that the Vector API is the right approach to supporting the rich set of linear algebra and machine learning algorithms, but there could be a sweet-spot for supporting a minimal set of extremely common functions too. I am explicitly not proposing that the JDK should become a linear algebra library! ;-)
>
> Additionally, `Math::dot` could be added to the platform now, no need to wait, or preview or incubate. The implementation could use already existing internal primitives (without an dependency on Vector API), and eventually become a "simple convenience", when the Vector API is finalized.
>
> I believe that this approach remains largely inline with the goals of the project (as I understand them), but just reframes the potential to deliver small improvements in this area incrementally.
>
> Yes, but whose goina do the work? If the idea is positively received, then I am happy to drive this non-trivial contribution.
>
> -Chris.
>
> [*] or some other location where it can be easily found and imported
More information about the panama-dev
mailing list