lucene icon indicating copy to clipboard operation
lucene copied to clipboard

Can we use Panama Vector API for quantizing vectors?

Open benwtrent opened this issue 4 months ago • 0 comments

Description

It would take a bit of refactoring, but:

    float dx = v - minQuantile;
    float dxc = Math.max(minQuantile, Math.min(maxQuantile, v)) - minQuantile;
    float dxs = scale * dxc;
    float dxq = Math.round(dxs) * alpha;
    if (dest != null) {
      dest[destIndex] = (byte) Math.round(dxs);
    }
    return minQuantile * (v - minQuantile / 2.0F) + (dx - dxq) * dxq;

All these actions seem like they could be done lane-wise. Though, I expect the transformation from FloatVector to byte[] array to be the most expensive part and consequently, might make vectorizing this effectively impossible.

of course, much of the stuff here written for value reuse would have to be adjusted

benwtrent avatar Oct 16 '24 15:10 benwtrent