Conversation
Introduce a float32 sparse vector that stores only non-zero entries, fully satisfies the Vector interface, and includes basic unit tests. Co-authored-by: Ilia Gyrdymov <gyrdym@users.noreply.github.com>
cursor
Bot
force-pushed
the
cursor/float32-vector-sparse-f5ac
branch
from
July 27, 2026 21:22
a839996 to
d439048
Compare
Co-authored-by: Ilia Gyrdymov <gyrdym@users.noreply.github.com>
Compare against any Vector by length and elements, and hash the full logical value sequence so equal sparse vectors share hashCode. Co-authored-by: Ilia Gyrdymov <gyrdym@users.noreply.github.com>
Hash length and stored index/value pairs with a stronger mixing finalizer instead of scanning the full dense logical vector. Co-authored-by: Ilia Gyrdymov <gyrdym@users.noreply.github.com>
Move sparse vector hashing helpers to lib/src/common/hash with dedicated unit tests for each function. Co-authored-by: Ilia Gyrdymov <gyrdym@users.noreply.github.com>
Keep Float32VectorSparse.sqrt on the sparse path when nnz is below half the length; otherwise densify for SIMD-friendly evaluation. Co-authored-by: Ilia Gyrdymov <gyrdym@users.noreply.github.com>
Mirror sqrt: keep the sparse path below half density, otherwise densify for SIMD-friendly abs. Co-authored-by: Ilia Gyrdymov <gyrdym@users.noreply.github.com>
Co-authored-by: Ilia Gyrdymov <gyrdym@users.noreply.github.com>
Keep the sparse path for positive exponents when clearly sparse; otherwise densify. Zero/negative exponents keep their existing behavior. Co-authored-by: Ilia Gyrdymov <gyrdym@users.noreply.github.com>
Use the sparse path for scalar *, scalar /, and vector * when clearly sparse; otherwise densify for SIMD-friendly evaluation. Co-authored-by: Ilia Gyrdymov <gyrdym@users.noreply.github.com>
Introduce a fill value for missing indices so exp can map fill 0 -> 1 and stay sparse. Aggregations and element access honor fill; structural multiply densifies when fill is non-zero. Co-authored-by: Ilia Gyrdymov <gyrdym@users.noreply.github.com>
Return Float32VectorSparse to classic zero-fill semantics. exp goes back to a dense path, which better matches on-device text workloads. Co-authored-by: Ilia Gyrdymov <gyrdym@users.noreply.github.com>
Remove the nnz heuristic from * and scalar / so text-style sparse vectors stay compressed for the common on-device workloads. Co-authored-by: Ilia Gyrdymov <gyrdym@users.noreply.github.com>
Exercise sparse vectors end-to-end without mocks: large-vocab BoW storage, cosine ranking against a dense baseline, feature intersection, and live set updates. Co-authored-by: Ilia Gyrdymov <gyrdym@users.noreply.github.com>
Co-authored-by: Ilia Gyrdymov <gyrdym@users.noreply.github.com>
Co-authored-by: Ilia Gyrdymov <gyrdym@users.noreply.github.com>
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.
Summary
Adds
Float32VectorSparse, a float32 sparse vector implementation that satisfies the fullVectorinterface.Details
Float32VectorSparse.fromMap(Map<int, num> source, {required int length})0.0==/hashCodeby vector values (works acrossVectorimplementations from the sparse side)[],sum,dot,norm,min/max,abs, scalar*//, sparse*,set,subvectorVectorfor correctnessNotes
Branch rebased onto rewritten
master.