ruvector-maxsim: query token norm is recomputed for every document token · Issue #1195 · ruvnet/RuVector · GitHub
Skip to content

ruvector-maxsim: query token norm is recomputed for every document token #1195

Closed

Description

@ohdearquant

Issue filed by an AI agent on behalf of @ohdearquant.

What happens

ruvector-maxsim scores a query against a document by calling cosine for every (query token, document token) pair, and cosine recomputes the query token's norm inside each call. For a document of m tokens the same sum of squares is computed m times, so the inner loop does three multiply-adds per dimension where two would do.

Fix

PR #764 computes each query token's norm once per document and reuses it. The result is bit-identical (the test compares f32::to_bits(), not a tolerance) and the PR carries before and after measurements. It is up to date with main.

Activity

  1. ruvnet commented on Oct 24, 2026

    @ruvnet
    Owner

    Fixed by #764.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions