Skip to content

Add FloatWidenScheme to BtrBlocks for lossless float narrowing - #11902

Merged
lwwmanning merged 7 commits into
wm/float-widen-arrayfrom
wm/float-widen-scheme
Nov 25, 2026
Merged

lwwmanning merged 7 commits into
wm/float-widen-arrayfrom
wm/float-widen-scheme

Conversation

@lwwmanning

@lwwmanning lwwmanning commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

This adds FloatWidenScheme to vortex-btrblocks. The scheme narrows float arrays losslessly with Widen (f64 to f32 or f16, and f32 to f16) before the child float encodings compress them. CUDA presets do not use it.

The scheme reuses narrowest_float_ptype and narrow_float_values from vortex-array, and estimates its gain on the usual BtrBlocks sample (DeferredEstimate::Sample). When an f64 column fits both f16 and f32, it compresses both children and keeps the smaller one. Dict and RLE stay at the root. The scheme writes vortex.widen.v2, so it applies only when the UNSTABLE edition is allowed.

Stacked on #11901

Authored with AI assistance.


Devin Review

@lwwmanning lwwmanning added the changelog/feature A new feature label Nov 24, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T00:38:18.560622Z 53babe9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@lwwmanning

Copy link
Copy Markdown
Contributor Author

37-Column Local Float Ablation (Default vs Default + FloatWidenScheme with UNSTABLE)

All 37 columns across PBI, Taxi, GloveSmall100k, and OpenaiSmall50k passed 100% bit-exact round-trip verification (all chunks) plus vortex.widen.v2 wire serialize/deserialize and filter / take / compare < verification.

Column PType Rows Raw (MB) Default (MB) +FloatWiden (MB) Delta Widen Chunks Base Enc +FloatWiden Enc Enc Base (ms) Enc Widen (ms)
Arade.F4 f64 9888775 79.11 31.82 31.82 +0.00% 0/76 vortex.alp(76) vortex.alp(76) 225.6 226.5
Arade.F5 f64 9888775 79.11 31.08 31.08 +0.00% 0/76 vortex.alp(76) vortex.alp(76) 230.0 232.4
Arade.F8 f64 9888775 79.11 31.45 31.45 +0.00% 0/76 vortex.alp(76) vortex.alp(76) 233.1 234.9
Arade.F9 f64 9888775 79.11 31.45 31.45 +0.00% 0/76 vortex.alp(76) vortex.alp(76) 236.1 233.7
Bimbo.Dev_proxima f64 74180464 593.44 12.32 12.32 +0.00% 0/566 vortex.dict(517)+vortex.alp(49) vortex.dict(517)+vortex.alp(49) 458.4 454.1
Bimbo.Venta_hoy f64 74180464 593.44 121.50 121.50 +0.00% 0/566 vortex.alp(566) vortex.alp(566) 732.4 724.8
CMSprovider.AVERAGE_MEDICARE_ALLOWED_AMT f64 9287877 75.46 40.13 40.13 +0.00% 0/71 vortex.dict(53)+vortex.alp(17) vortex.dict(53)+vortex.alp(17) 178.3 180.8
CMSprovider.AVERAGE_MEDICARE_PAYMENT_AMT f64 9287877 75.46 52.36 52.36 +0.00% 0/71 vortex.alp(71) vortex.alp(71) 219.2 215.6
CMSprovider.AVERAGE_SUBMITTED_CHRG_AMT f64 9287877 75.46 41.69 41.69 +0.00% 0/71 vortex.alp(41)+vortex.dict(30) vortex.alp(41)+vortex.dict(30) 203.7 205.3
CMSprovider.LINE_SRVC_CNT f64 9287877 75.46 13.61 13.59 -0.13% 3/71 vortex.alp(71) vortex.alp(68)+widen(f32->vortex.alp)(3) 60.7 65.8
CMSprovider.STDEV_MEDICARE_ALLOWED_AMT f64 9287877 75.46 37.00 37.00 +0.00% 0/71 vortex.alp(61)+vortex.dict(10) vortex.alp(61)+vortex.dict(10) 93.2 91.8
CMSprovider.STDEV_MEDICARE_PAYMENT_AMT f64 9287877 75.46 48.04 48.04 +0.00% 0/71 vortex.alp(71) vortex.alp(71) 207.1 206.4
CMSprovider.STDEV_SUBMITTED_CHRG_AMT f64 9287877 75.46 38.12 38.12 +0.00% 0/71 vortex.alp(52)+vortex.dict(19) vortex.alp(52)+vortex.dict(19) 122.1 120.9
Euro2016.polarity_confidence f64 2052497 16.68 13.86 13.86 +0.00% 0/16 vortex.alprd(16) vortex.alprd(16) 18.0 19.6
Euro2016.subjectivity_confidence f64 2052497 16.68 14.56 14.56 +0.00% 0/16 vortex.alp(15)+vortex.dict(1) vortex.alp(15)+vortex.dict(1) 30.1 29.5
Food.volume_total_bytes f64 5216593 41.73 19.60 19.60 +0.00% 0/40 vortex.alp(40) vortex.alp(40) 101.9 100.7
HashTags.interaction#author#id f64 511511 4.16 2.07 2.07 +0.00% 0/4 vortex.alp(4) vortex.alp(4) 8.3 8.7
HashTags.interaction#geo#latitude f64 511511 4.16 0.29 0.29 +0.00% 0/4 vortex.sparse(4) vortex.sparse(4) 1.2 1.0
HashTags.interaction#geo#longitude f64 511511 4.16 0.29 0.29 +0.00% 0/4 vortex.sparse(4) vortex.sparse(4) 1.0 0.9
HashTags.interaction#received_at f64 511511 4.16 3.35 3.35 +0.00% 0/4 vortex.alp(2)+vortex.alprd(2) vortex.alp(2)+vortex.alprd(2) 5.5 6.1
HashTags.twitter#geo#latitude f64 511511 4.16 0.29 0.29 +0.00% 0/4 vortex.sparse(4) vortex.sparse(4) 1.1 1.0
HashTags.twitter#geo#longitude f64 511511 4.16 0.29 0.29 +0.00% 0/4 vortex.sparse(4) vortex.sparse(4) 1.0 0.9
HashTags.twitter#id f64 511511 4.09 3.14 3.14 +0.00% 0/4 vortex.alprd(4) vortex.alprd(4) 5.7 5.5
HashTags.twitter#in_reply_to_status_id f64 511511 4.16 0.36 0.36 +0.00% 0/4 vortex.sparse(4) vortex.sparse(4) 1.6 1.6
HashTags.twitter#user#id f64 511511 4.16 2.07 2.07 +0.00% 0/4 vortex.alp(4) vortex.alp(4) 8.3 8.1
HashTags.twitter#user#id_str f64 511511 4.16 2.05 2.05 +0.00% 0/4 vortex.alp(4) vortex.alp(4) 7.7 7.5
Taxi.trip_miles f64 19144903 153.16 37.64 37.64 +0.00% 0/147 vortex.alp(147) vortex.alp(147) 191.3 197.1
Taxi.base_passenger_fare f64 19144903 153.16 36.33 36.33 +0.00% 0/147 vortex.alp(147) vortex.alp(147) 180.5 183.3
Taxi.tolls f64 19144903 153.16 16.44 16.44 +0.00% 0/147 vortex.dict(129)+vortex.alp(18) vortex.dict(129)+vortex.alp(18) 173.0 175.4
Taxi.bcf f64 19144903 153.16 22.06 22.06 +0.00% 0/147 vortex.alp(147) vortex.alp(147) 100.9 103.0
Taxi.sales_tax f64 19144903 153.16 24.91 24.91 +0.00% 0/147 vortex.alp(147) vortex.alp(147) 119.7 112.1
Taxi.congestion_surcharge f64 19144903 153.16 4.79 4.79 -0.06% 0/147 vortex.dict(144)+vortex.alp(3) vortex.dict(147) 115.6 148.7
Taxi.airport_fee f64 19144903 153.16 4.54 4.07 -10.45% 30/147 vortex.dict(98)+vortex.alp(49) vortex.dict(113)+widen(f32->vortex.alp)(30) 128.9 161.3
Taxi.tips f64 19144903 153.16 25.97 25.97 +0.00% 0/147 vortex.dict(81)+vortex.alp(66) vortex.dict(81)+vortex.alp(66) 168.9 168.6
Taxi.driver_pay f64 19144903 153.16 34.51 34.51 +0.00% 0/147 vortex.alp(147) vortex.alp(147) 163.6 159.7
GloveSmall100k.emb[flat] f32 20000000 80.00 64.40 64.40 +0.00% 0/77 vortex.alp(73)+vortex.alprd(3) vortex.alp(73)+vortex.alprd(3) 314.1 308.7
OpenaiSmall50k.emb[flat] f64 76800000 614.40 548.57 270.17 -50.75% 586/586 vortex.alprd(586) widen(f32->vortex.alprd)(586) 1158.3 1323.3
TOTAL (37 cols) 4220.99 1412.93 1134.03 -19.74% 6206.0 6425.7

Operation Latencies (Median of 3 Runs, Release)

Column / Arm Size (MB) Decode (ms) scalar_at (ns) Filter 1% (ms) Filter 10% (ms) Filter 50% (ms) Take 1% (ms) Take 10% (ms) Take 50% (ms) Compare < (ms)
CMSprovider.LINE_SRVC_CNT (Default) 13.61 3.4 484.6 1.3 3.4 5.0 1.3 7.9 11.2 2.3
CMSprovider.LINE_SRVC_CNT (+FloatWiden) 13.59 2.9 514.1 1.1 3.4 5.5 1.4 7.4 11.7 2.0
Taxi.airport_fee (Default) 4.54 7.3 704.9 2.1 4.1 10.1 2.9 15.6 47.0 1.5
Taxi.airport_fee (+FloatWiden) 4.07 10.6 712.9 2.2 4.7 11.7 3.1 15.6 50.1 1.4
OpenaiSmall50k.emb[flat] (Default) 548.57 35.9 617.9 22.8 50.0 64.1 23.9 89.8 298.3 49.5
OpenaiSmall50k.emb[flat] (+FloatWiden) 270.17 39.7 680.9 22.2 44.4 51.6 22.1 80.7 291.7 28.5

@codspeed

codspeed Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 22.73%

Warning

vortex-data has exceeded the Hobby plan limit of 5 active contributors. Upgrade your plan or apply to the open source program by December 8, 2026 to keep using CodSpeed.

2 warnings

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚠️ 1 benchmark is dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

❌ 8 regressed benchmarks
✅ 2048 untouched benchmarks
⏩ 215 skipped benchmarks1
🗄️ 2 archived benchmarks run2

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ CPU Simulation canonicalize_dict_sparse_codes_utf8[100] 265 µs 477.3 µs -44.49%
❌ CPU Simulation canonicalize_dict_sparse_codes_utf8[10] 338.5 µs 502.6 µs -32.66%
❌ CPU Simulation canonicalize_dict_sparse_codes_primitive[100] 198 µs 273.2 µs -27.53%
❌ CPU Simulation canonicalize_dict_sparse_codes_primitive[10] 233.6 µs 286.4 µs -18.46%
❌ CPU Simulation bench_compare_varbin[(50000, 2)] 135.6 µs 162.6 µs -16.62%
❌ CPU Simulation bench_compare_sliced_dict_varbinview[(9999, 10000)] 201.1 µs 228.4 µs -11.94%
❌ CPU Simulation bench_compare_sliced_dict_varbinview[(10000, 10000)] 201 µs 228 µs -11.85%
❌ CPU Simulation bench_compare_sliced_dict_varbinview[(1000, 10000)] 86.9 µs 97.8 µs -11.14%

Tip

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


Comparing wm/float-widen-scheme (58ff915) with wm/float-widen-array (5c47e97)

Open in CodSpeed

Footnotes

  1. 215 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. ↩

  2. 2 benchmarks were run, but are now archived. If they were deleted in another branch, consider rebasing to remove them from the report. Instead if they were added back, click here to restore them. ↩

@lwwmanning lwwmanning left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posted by Claude Opus 5.5 on Will's behalf.

I found no path that gives a lossy result. The sampled probe can only skip the scheme, a full bit-exact check gates every verdict, and the CUDA preset excludes the scheme as claimed.

Most of the 663 lines are a custom deferred estimate that builds its own sample and repeats the target selection from #11901. Reusing the compressor's shared sample and one selection function from vortex-array would make this much smaller, and would let #11901 keep its helpers private. Details inline. This also needs the CUDA fix on #11901 before files written with it can be read on the GPU.


/// Builds a deterministic ~1% sample executed to a contiguous [`PrimitiveArray`], returning
/// `(sample, is_subsampled)`.
fn build_sample_primitive(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build_sample_primitive reimplements the compressor's sample_rows with different spacing, and a fixed 1024 rows for arrays of about 100k to 800k rows, where the competing schemes see about 1 percent through the shared compression_sample. It also skips amortize_fixed_nbytes. So the Widen ratio is compared against ratios from a different sample, and that sample is executed a second time. Running the full fit check in pass 1 and returning DeferredEstimate::Sample would reuse the shared sample and remove most of estimate_narrowed_ratio.

/// Verifies full-array bit-exact fit and returns all valid narrower targets ordered narrowest
/// first (`[F16, F32]` when an `f64` array fits both, because `ALP`/`ALPRD` skip `f16` so `f32`
/// can still beat `f16` after child compression).
fn candidate_targets_full(array: &PrimitiveArray, mask: &Mask) -> VortexResult<Vec<PType>> {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

candidate_targets_full and narrowest_fit_ptype repeat the f32-then-f16 selection in WidenArray::encode_float from #11901, through lower-level helpers that #11901 had to make public. One selection function exposed from vortex-array would serve both.

let fits_f16 = probe_valid_slice(array.as_slice::<f64>(), mask, f64_slice_fits_in_f16)
&& float_array_fits_in_ptype(array, PType::F16, mask)?;
if fits_f16 {
Ok(vec![PType::F16, PType::F32])

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No test covers an f64 column that fits both f16 and f32, so nothing checks the claim here that f32 can beat f16 after ALP or ALPRD, or that the chosen target round-trips. One case with f16-exact f64 values would cover it.


/// Minimum compression-ratio improvement over the best un-narrowed float scheme required to wrap
/// the array in a [`WidenArray`] (`>= 2%` smaller).
const MIN_IMPROVEMENT_FACTOR: f64 = 1.02;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other schemes compete on raw ratio. What is the 2 percent threshold based on? Either give the measurement behind it or drop it.

PType::F32
);
assert!(
with_widen.nbytes() * 100 < without_widen.nbytes() * 60,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The over-40-percent assertion compares against whatever ALPRD produces today on pseudorandom data, so an unrelated ALPRD improvement could fail it. The Widen-at-root and bit-exact assertions are the ones that matter.

@devin-ai-integration
devin-ai-integration Bot force-pushed the wm/float-widen-array branch 2 times, most recently from b692593 to 83b1715 Compare November 24, 2026 11:35
devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration
devin-ai-integration Bot force-pushed the wm/float-widen-scheme branch 2 times, most recently from 098ee79 to be73159 Compare November 24, 2026 12:09
@vortex-roborev-bot

vortex-roborev-bot Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

roborev: Combined Review (58ff915)

Verdict: No issues found.


Reviewers: claude-code | Synthesis: claude-code, 0s | Total: 43s, cost partial ~$0.39

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Addressed the roborev finding in a2478a382: FloatWidenScheme::expected_compression_ratio now uses DeferredEstimate::Callback with sample_aligned_chunks and passes the full-array narrowest target into the shared compress_with_target helper, preventing a sample from estimating with f16 when the full array only fits f32. Added f32_outlier_outside_sample_uses_f32_target as a regression test.

devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Addressed the updated roborev finding in 575fe063a: reduced the aligned sample to 2 chunks (2,048 rows) and cached the full-array compressed output in ArrayAndStats (CachedFullWiden) when sample_aligned_chunks returns None, so FloatWidenScheme::compress reuses it directly without compressing the full array twice.

devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration

devin-ai-integration Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Note on the CodSpeed report: the earlier 22% regression on encode_primitives[u8, (2000, 2)] (an unrelated u8 dict benchmark in vortex-array compared against a stale base during rebase) disappeared on 68f3190 vs 9be8071. The single remaining flagged item (encodings/fastlanes/benches/bitpacking_filter.rs::avx2::filter_avx2[80], 1.5 µs -> 1.7 µs Walltime) is likewise in vortex-fastlanes and unrelated to FloatWidenScheme (this PR touches no files in vortex-array or encodings/fastlanes).

Add FloatWidenScheme to vortex-btrblocks, gated behind vortex.widen.v2 (UNSTABLE) and excluded from the CUDA preset. Uses a zero-allocation stratified Pass-1 probe for instant rejection on general float columns, full-array bit-exact verification inside a DeferredEstimate::Callback after sampled schemes run, descendant exclusions keeping Dict/RLE at the root, and a >= 2% savings threshold before wrapping narrowed child compression in WidenArray.

Signed-off-by: Will Manning <will@willmanning.io>
Signed-off-by: Will Manning <will@spiraldb.com>
… size

Signed-off-by: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>
Signed-off-by: Will Manning <will@spiraldb.com>
…imation

Signed-off-by: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>
Signed-off-by: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>
Signed-off-by: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>
Signed-off-by: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>
devin-ai-integration[bot]

This comment was marked as resolved.

…n tests

Signed-off-by: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Devin Review

@lwwmanning
lwwmanning merged commit c97549b into wm/float-widen-array Nov 25, 2026
101 of 103 checks passed
@lwwmanning
lwwmanning deleted the wm/float-widen-scheme branch November 25, 2026 02:26
devin-ai-integration Bot pushed a commit that referenced this pull request Nov 25, 2026
Signed-off-by: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>
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.

1 participant