Skip to content

[claude] Normalized Vector refinement (extension) type#7566

Closed
connortsui20 wants to merge 1 commit intodevelopfrom
claude/add-normalized-vector-fkaa6
Closed

[claude] Normalized Vector refinement (extension) type#7566
connortsui20 wants to merge 1 commit intodevelopfrom
claude/add-normalized-vector-fkaa6

Conversation

@connortsui20
Copy link
Copy Markdown
Contributor

Signed-off-by: Connor Tsui connor.tsui20@gmail.com

@connortsui20 connortsui20 changed the title clean up vortex-tensor [Claude] Normalized Vector refinement (extension) type Apr 20, 2026
@connortsui20 connortsui20 changed the title [Claude] Normalized Vector refinement (extension) type [claude] Normalized Vector refinement (extension) type Apr 20, 2026
@connortsui20 connortsui20 changed the base branch from develop to ct/cleanup-tensor April 20, 2026 11:56
@connortsui20 connortsui20 added the changelog/feature A new feature label Apr 20, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 20, 2026

Merging this PR will degrade performance by 11.81%

❌ 1 regressed benchmark
✅ 1162 untouched benchmarks
⏩ 1462 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation new_alp_prim_test_between[f32, 16384] 106.5 µs 120.8 µs -11.81%

Comparing claude/add-normalized-vector-fkaa6 (68261b5) with develop (12457aa)

Open in CodSpeed

Footnotes

  1. 1462 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@connortsui20 connortsui20 marked this pull request as draft April 20, 2026 12:57
Base automatically changed from ct/cleanup-tensor to develop April 20, 2026 13:42
Lift the "rows are unit-norm" invariant out of L2Denorm runtime
validation and into a refinement of Vector. NormalizedVector shares the
same FixedSizeList(float, dim) storage but carries a distinct ExtId so
downstream operators can dispatch on the type-system claim.

Changes:
- Add `vortex-tensor/src/normalized_vector/{mod,vtable,matcher}.rs`
  with `NormalizedVector::try_new` (validates rows) and
  `NormalizedVector::new_unchecked` (lossy callers).
- Extract a shared `validate_vector_storage_dtype` helper from
  `Vector::validate_dtype`; reuse it from `NormalizedVector`.
- Extend `AnyVector` to match both `Vector` and `NormalizedVector`,
  surfacing an `is_normalized` field. Add `AnyNormalizedVector`.
- Tighten `L2Denorm::return_dtype` to require an `AnyNormalizedVector`
  first child, output a sibling plain `Vector`. Replace
  `try_new_array`/`new_array_unchecked` with safe `try_new_array`
  (zero-row cross-check only) plus `new_array` (no cross-check, used
  by lossy callers).
- Refactor `DenormOrientation` into a per-operand `NormalForm`
  classifier and use it from `CosineSimilarity`/`InnerProduct`/
  `L2Norm`. Naked `NormalizedVector` operands now hit the fast path:
  `L2Norm` returns constant `1.0`; `CosineSimilarity` collapses to a
  dot product; `InnerProduct` falls through to the regular dot.
- Propagate the `is_normalized` marker through `SorfTransform`
  (orthogonal transforms preserve L2 norms).
- Update `turboquant_encode` to wrap the quantized FSL via
  `NormalizedVector::new_unchecked` and call the safe `L2Denorm`
  constructor; remove the L2Denorm `unsafe`.
- Drop FixedShapeTensor + L2Denorm support and migrate the affected
  tests; FST remains usable in the other operators.
- Add tests for the new matcher, dtype validation, and naked
  `NormalizedVector` fast paths.

The remaining `unsafe` blocks in this crate are the documented lossy
`NormalizedVector::new_unchecked` call sites and pre-existing
low-level buffer ops unrelated to the invariant.

Verification:
- cargo build -p vortex-tensor
- cargo test -p vortex-tensor (289 passed)
- cargo build -p vector-search-bench
- cargo +nightly fmt --all
- ./scripts/public-api.sh
- cargo clippy -p vortex-tensor --all-targets --all-features

Signed-off-by: Claude <noreply@anthropic.com>
@connortsui20 connortsui20 force-pushed the claude/add-normalized-vector-fkaa6 branch from a1e9907 to 68261b5 Compare April 20, 2026 14:03
@connortsui20 connortsui20 deleted the claude/add-normalized-vector-fkaa6 branch April 20, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants