Skip to content

Tracking Issue: Pluggable Scalar Functions #7881

Description

@connortsui20

This is a tracking issue for adding pluggable scalar functions to Vortex. Right now, it is impossible for a third-party extension type to add an implementation for scalar function execution and also reordering/optimization.

Motivation

As of writing, the main use case for this is TurboQuant, which we have decided to make a separate logical extension type with a TQDecode and TQEncode scalar function implementation that converts to and from a Vector array. Right now, there is no way for TurboQuant to implement specialized execution for vector scalar functions such as CosineSimilarity, InnerProduct, and L2Norm.

It's also unclear what function signature of the binary operations are (we need CosineSimilarity to accept a Vector on at least 1 of the sides, so does that mean the return type is always Vector but sometimes one of the children can be TurboQuant??)

And it is not obvious if this is actually the way we want to implement this functionality in Vortex (for example, we could just have TQCosineSimilarity and TQInnerProduct, but that seems duplicative). But this feels like a reasonable path forward (and I think in general we want to be more extensible in general, not less).

We would ideally like this sooner than later so that we can get TurboQuant back to a fully functional state (i.e., fully working in the vortex-search-bench benchmarks with the same performance), and then we can delete the implementation in vortex-tensor.

Design

Not really sure what this should look like. However this ends up, it needs to support pluggable return dtype, execution, reordering/optimization, etc. I think this is similar to how Arrays must be pluggable, but it has to additionally support a new return dtype (since Array encodings keep the same dtype).

Steps

  • Unclear

Unresolved questions

  • How do we do this?

Implementation history

cc @gatesn @joseph-isaacs

Activity

  1. added
    tracking-issueShared implementation context for work likely to span multiple PRs.
    on May 11, 2026
  2. robert3005 commented on May 11, 2026

    @robert3005
    Contributor

    I think you're not looking at develop. You can register reduce and execute parent implementations for arbitrary function ids via https://github.com/vortex-data/vortex/blob/develop/vortex-array/src/optimizer/kernels.rs. Which are executed BEFORE vtable functions are executed

  3. connortsui20 commented on May 11, 2026

    @connortsui20
    MemberAuthor

    @robert3005 does this work for scalar functions? I guess it should work if the scalar fn array has already been constructed, and then we can register parent rules that match on if the scalar fn is exactly what we need?

  4. robert3005 commented on May 11, 2026

    @robert3005
    Contributor

    This could work but Expressions have separate optimiser loop that I forgot about.

  5. connortsui20 commented on May 12, 2026

    @connortsui20
    MemberAuthor

    So I think we need an overload for return_dtype in order to support this, which will mean we have to thread the session through a bunch of places...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    tracking-issueShared implementation context for work likely to span multiple PRs.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions