Skip to content

Execute tensor L2 norm with RowFn - #9347

Draft
connortsui20 wants to merge 6 commits into
ct/row-fn-primitive-comparisonsfrom
ct/row-fn-tensor-l2
Draft

Execute tensor L2 norm with RowFn#9347
connortsui20 wants to merge 6 commits into
ct/row-fn-primitive-comparisonsfrom
ct/row-fn-tensor-l2

Conversation

@connortsui20

@connortsui20 connortsui20 commented Aug 11, 2026

Copy link
Copy Markdown
Member

Rationale for this change

Moves tensor L2 norm to the shared row executor while preserving the existing storage semantics.

What changes are included in this PR?

Top-level constants still reduce once, and Normalized arrays still return their authoritative stored norms. Masked constants use validity-aware row execution. Tests cover tensor shapes, constants, nulls, vectors, and normalized storage.

Rust 1.97.1 one-CGU fat-LTO results improve dense and nullable widths by up to 46%; width 256 remains within 3%. Non-null constant inputs regress by 19–33%, while nullable constants improve by 83–94%.

What APIs are changed? Are there any user-facing changes?

There are no public API or behavior changes. L2Norm implements RowFn and receives the standard scalar-function vtable automatically.

@codspeed-hq

codspeed-hq Bot commented Aug 11, 2026

Copy link
Copy Markdown

Merging this PR will regress 4 benchmarks

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚡ 28 improved benchmarks
❌ 4 regressed benchmarks
✅ 1998 untouched benchmarks
🆕 6 new benchmarks
⏩ 89 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation column_x_column[256] 143.7 µs 179.9 µs -20.11%
Simulation cold_misaligned[(64, 256)] 4.4 ms 5.3 ms -17.14%
Simulation column_x_column[32] 159.1 µs 191.5 µs -16.92%
Simulation encode_varbinview[(10000, 2)] 2.1 ms 2.3 ms -10.96%
Simulation compare_u8_constant 890.3 µs 282 µs ×3.2
Simulation compare_i32_constant 1,184.1 µs 516.3 µs ×2.3
Simulation case_when_nary_10_conditions[10000] 1,987.7 µs 998.8 µs +99.01%
Simulation case_when_all_false[100000] 2.1 ms 1.1 ms +90.3%
Simulation case_when_all_true[100000] 2.1 ms 1.1 ms +89.84%
Simulation case_when_simple[100000] 2.3 ms 1.3 ms +80.39%
Simulation case_when_nary_equality_lookup[10000] 1,147.7 µs 644.8 µs +78%
Simulation case_when_without_else[100000] 2.4 ms 1.3 ms +75.7%
Simulation case_when_nary_3_conditions[10000] 766.6 µs 462.9 µs +65.59%
Simulation case_when_nary_early_dominant[10000] 763.7 µs 463.1 µs +64.91%
Simulation non_nullable[2] 691 µs 473.8 µs +45.84%
Simulation nullable[2] 682.2 µs 478 µs +42.74%
Simulation case_when_all_false[10000] 343.5 µs 242.7 µs +41.54%
Simulation case_when_all_true[10000] 346.9 µs 247.4 µs +40.24%
Simulation case_when_simple[10000] 373 µs 272.1 µs +37.07%
Simulation case_when_without_else[10000] 391.6 µs 291.6 µs +34.3%
... ... ... ... ... ...

ℹ️ Only the first 20 benchmarks are displayed. Go to the app to view all benchmarks.

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing ct/row-fn-tensor-l2 (6c84e6e) with ct/row-fn-primitive-comparisons (8c215b8)

Open in CodSpeed

Footnotes

  1. 89 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 ready for review August 11, 2026 16:05
@connortsui20
connortsui20 marked this pull request as draft August 11, 2026 16:24
@connortsui20

Copy link
Copy Markdown
Member Author

Here are the local L2 norm benchmark results from the final Rust 1.97.1 run.

The comparison used a develop baseline with benchmark-only backfills (1edd0fca) and the full RowFn stack (8ca9fc73). Later stack layers do not change L2 norm source, but unrelated code-placement effects can still affect these binaries.

The machine was an AMD Ryzen 9 7950X running Linux. The build used rustc 1.97.1, LLVM 22.1.6, one CGU, fat LTO, and -C target-cpu=native. Each target used two warm runs and seven alternating measured pairs. Each process used 100 samples with a 0.25–0.5 second measurement window on CPU 4.

Negative changes are faster. The values are medians across the seven paired runs.

Dense and nullable widths improve by as much as 45.91%. Width 256 remains within 2.93%. Non-null constants regress by 18.82–33.24%, while nullable constants improve by 83.36–93.90%.

All L2 norm results: 12 cases
Input Width Baseline RowFn stack Change
constant 256 10.400 µs 13.720 µs +33.24%
constant 32 1.859 µs 2.479 µs +33.17%
constant 2 1.179 µs 1.399 µs +18.82%
non-null 256 9.449 µs 9.619 µs +1.69%
nullable 256 10.240 µs 9.959 µs -2.93%
non-null 32 6.969 µs 6.529 µs -6.31%
nullable 32 7.779 µs 6.869 µs -11.70%
non-null 2 31.580 µs 17.180 µs -45.60%
nullable 2 32.400 µs 17.530 µs -45.91%
nullable constant 256 174.500 µs 28.710 µs -83.36%
nullable constant 2 183.400 µs 18.860 µs -89.75%
nullable constant 32 163.200 µs 9.979 µs -93.90%

@connortsui20
connortsui20 force-pushed the ct/row-fn-tensor-l2 branch 2 times, most recently from 15ca838 to 3d25f2a Compare August 13, 2026 15:40
@connortsui20
connortsui20 force-pushed the ct/row-fn-tensor-l2 branch 2 times, most recently from 0ba300a to cfd5741 Compare August 13, 2026 18:37
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant