Make normalized tensor shortcuts explicit - #9513
Conversation
Merging this PR will degrade performance by 7.36%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | column_x_extension_constant[256] |
650.4 µs | 834 µs | -22.01% |
| ❌ | Simulation | column_x_extension_constant[2] |
290.9 µs | 355.4 µs | -18.16% |
| ❌ | Simulation | column_x_extension_constant[32] |
230 µs | 273 µs | -15.72% |
| ⚡ | WallTime | words_gather_scalar[65536] |
9.4 µs | 8.3 µs | +13.39% |
| ⚡ | Simulation | compress_fsst[(500, 64, 8)] |
585.9 µs | 523.7 µs | +11.88% |
| 🆕 | Simulation | normalized_assume[2] |
N/A | 159.3 µs | N/A |
| 🆕 | Simulation | normalized_assume[256] |
N/A | 84.2 µs | N/A |
| 🆕 | Simulation | normalized_assume[32] |
N/A | 88.2 µs | N/A |
| 🆕 | Simulation | normalized_exact[2] |
N/A | 261.7 µs | N/A |
| 🆕 | Simulation | normalized_exact[256] |
N/A | 113.7 µs | N/A |
| 🆕 | Simulation | normalized_exact[32] |
N/A | 120.4 µs | N/A |
| 🆕 | Simulation | normalized_assume[2] |
N/A | 36.6 µs | N/A |
| 🆕 | Simulation | normalized_assume[256] |
N/A | 25 µs | N/A |
| 🆕 | Simulation | normalized_assume[32] |
N/A | 25 µs | N/A |
| 🆕 | Simulation | normalized_exact[2] |
N/A | 847.6 µs | N/A |
| 🆕 | Simulation | normalized_exact[256] |
N/A | 232.8 µs | N/A |
| 🆕 | Simulation | normalized_exact[32] |
N/A | 267.8 µs | N/A |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing ct/norm-compute-mode (76656f1) with develop (9876921)
Footnotes
-
442 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. ↩
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
4c3a203 to
76656f1
Compare
Rationale for this change
Normalizedis a physical encoding whose direction is only approximately unit length, so trusting it belongs to scalar-function policy instead of a logicalUnitVectordtype.What changes are included in this PR?
Adds
NormMode::{Exact, AssumeNormalized}to cosine similarity and L2 norm. Exact mode measures physical direction norms, while assumed mode retains the current shortcut; both modes persist, and legacy metadata keeps its existing behavior.What APIs are changed? Are there any user-facing changes?
CosineSimilarity::try_new,L2Norm::try_new, andbuild_similarity_search_treenow require an explicitNormMode. This adds no logical dtype or Arrow extension type.