Repository navigation
Process exact full chunks in const array distance kernels - #104625
alexey-milovidov merged 17 commits into
Conversation
Use inclusive full-chunk loop bounds in `arrayNorm` and `arrayDistance` so inputs whose length is exactly divisible by the vector width do not fall back to the scalar tail. Add exact-boundary stateless coverage and a focused performance test for norm and distance functions.
alexey-milovidov
left a comment
There was a problem hiding this comment.
Thanks, amazing finding!
|
Workflow [PR], commit [ce75632] Summary: ✅
AI ReviewSummaryThis PR now narrows to processing exact full chunks in the AVX-512 const-left Missing context / blind spots
Tests
Final VerdictStatus: Minimum required action: provide completed before/after performance evidence for the current head, preferably from the new |
Update the existing `arrayNorm` reference for the new accumulation order. Add exact and near-exact `cosineDistance` boundary checks to cover the modified loop bounds.
These changes to CI workflow / infrastructure files were unrelated to the purpose of this pull request and were introduced accidentally (stale base branch). Restoring them to match `master`.
|
Merged Verified the change locally on an ARM build:
Remaining CI failures are unrelated to this loop-bound change and not invoking the affected functions:
|
|
📊 Cloud Performance Report 🟢 AI verdict: This PR is a narrow off-by-one fix to the AVX-512 kernels of L2Distance/cosineDistance (arrayDistance.cpp), plus new performance and stateless tests. None of the flagged ClickBench or TPC-H queries use vector-distance functions, so none of these deltas can be attributed to the change. The smaller-magnitude flags (clickbench Q15/Q22 and tpch Q8) were downgraded as environment variance; a few large deltas (clickbench Q23, tpch Q7/Q20) clear the automatic high-confidence trust bar and stay flagged, but they are equally unrelated to the diff and should be read as run-to-run/build variance. clickbench🟢 1 improved · Flagged queries (3 of 43)
q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 2 improved · Flagged queries (4 of 22)
q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. Debug info
|
…full-chunks # Conflicts: # src/Functions/array/arrayNorm.cpp
|
Merged While this PR was open, The distance functions in Verified locally (built The remaining CI red is an unrelated |
The shared vectorized loops in `arrayDistance` are instantiated for every distance kernel, so the exact-full-chunk boundary change affects `L1Distance`, `L2SquaredDistance`, `LpDistance`, and `LinfDistance` too, not only `L2Distance` and `cosineDistance`. Extend the stateless test `04107_vector_norm_full_chunk` with exact-boundary (length 16) and one-past-the-boundary (length 17) assertions for the other distance functions, exercising both the materialized and the `executeWithLeftArgConst` const-left paths, and extend the performance test `norm_distance_exact_chunks` to measure all changed kernels. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Status: all review threads are resolved and CI is green except a single failure in BuzzHouse (arm_asan_ubsan): Related: #106846 No further changes are needed here; the PR is ready to merge once that flake is disregarded or fixed. |
|
Restarted the failed |
…full-chunks # Conflicts: # src/Functions/array/arrayDistance.cpp
|
Merged While this PR was open, However, Compiled |
Scope the stateless and performance tests to the remaining PR surface: the AVX-512 const-left paths for `L2Distance` and `cosineDistance`. Add exact-boundary coverage for `Array(Float32)`, `Array(Float64)`, and `Array(BFloat16)`, including BF16 coverage with `allow_experimental_bfloat16_type`. Related: ClickHouse#104625
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered by tests: 12/12 (100.00%) | Lost baseline coverage (was covered on master, now uncovered in this PR): 7 line(s) · Uncovered code |
The remaining diff fixes the exact full-chunk boundary in the hand-written AVX-512 const-left
arrayDistancekernels. This is the path used when a constant query vector is compared with an array column.The affected kernels are
L2DistanceandcosineDistanceforArray(Float32),Array(Float64), andArray(BFloat16). The previous loop condition used<, so when the array length was exactly one vector-width multiple (16elements forFloat32,8forFloat64,32forBFloat16), the last full chunk was skipped by the intrinsic loop and handled by the scalar tail. The new<=condition processes that full chunk while still staying within the exclusive end offset.The stateless and performance tests are now scoped to these const-left exact-chunk cases, including
BFloat16.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Improved performance of the AVX-512 const-left paths for
L2DistanceandcosineDistanceonArray(Float32),Array(Float64), andArray(BFloat16)when the array length is exactly divisible by the vectorized processing width.Documentation entry for user-facing changes
Version info
26.6.1.795