Skip to content

perf: accelerate approximate cuts and selective wide prediction staging - #179

Merged
brndnmtthws merged 1 commit into
mainfrom
perf/cpu-round3-source
Oct 23, 2026
Merged

brndnmtthws merged 1 commit into
mainfrom
perf/cpu-round3-source

Conversation

@brndnmtthws

@brndnmtthws brndnmtthws commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Changes

  • Selectively stage only feature/sign slots read by eligible wide dense forests. Cache a sorted unique slot plan lazily, with bounded bitmap discovery to avoid sorting every node on first prediction. Keep existing narrow, single-row and CSR paths. The full-width lane allocation remains.
  • Adaptively choose stable radix sorting for approximate weighted quantile cuts. Keep comparison sorting for small inputs, sampled duplicates and mostly ordered values. Both paths preserve exact float total order and equal-key weight order.

No public API, serialization, tree-walking or accumulation-order changes. Baseline is 5d4bd3758db72220e61c4d1a4b0f8cb09b20dd74, including #178.

Before / after

One Rayon thread on a shared, virtualized x86-64 host. Rust 1.99.1 / LLVM 23.1.1, default CPU features, release opt-level 3, thin LTO, one codegen unit, no target-cpu override or CPU pinning. Do not compare absolute timings with earlier rounds on different hardware.

Five independently interleaved ABBA cycles, three measured samples per process: 30 samples from ten processes per binary per workload. No samples removed. Values are milliseconds; changes are latency changes, not universal throughput claims. P10–P90 is an interpolated sample range, not a confidence interval.

Workload Baseline ms, median [P10–P90] Candidate ms, median [P10–P90] Median change
Approx logistic, dense weighted, 30k × 30 / 10 rounds 431.5 [416.01–610.97] 330.6 [326.39–363.59] -23.4%
Approx logistic, dense unit weights, 30k × 30 / 10 rounds 429.48 [412.82–465.13] 333.82 [322.51–369.22] -22.3%
Approx logistic, NaN-missing dense, 30k × 30 / 10 rounds 237.57 [231.16–242.55] 203.72 [198.6–210.6] -14.3%
Histogram logistic control (unchanged path) 92.263 [89.976–104.47] 92.519 [89.276–99.851] +0.3%
Predict: 256 columns, ~8% used, depth 4, 10 trees, 16 rows 0.0044643 [0.004428–0.0069651] 0.0013513 [0.0013315–0.0025477] -69.7%
Predict: 1024 columns, ~8% used, depth 8, 100 trees, 10k rows 19.887 [18.814–22.838] 9.5547 [9.3275–10.293] -52.0%
Predict: 1024 columns, ~1% used, depth 4, 10 trees, 256 rows 0.35986 [0.34184–0.3875] 0.070618 [0.065872–0.095756] -80.4%

Prediction uses prepared DMatrix input and warm layout, including validation/output allocation. Training includes fresh matrix construction, metadata and training, without reusing matrix/bin caches; output checking is outside timing. Cold-layout runs include first-prediction layout construction, but not model decoding.

Dense weighted training improved in every confirmation block, by 17.8–46.4%. The 46.4% block had an unusually slow baseline and is retained rather than treated as an extra win; the other four blocks improved 17.8–23.2%. The matching identical-binary training control moved −1.45% pooled; unchanged histogram training moved +0.28%. The earlier full grid measured dense weighted training −18.3% and the two ~8%-used inference cases −69.2%/−51.0%.

Coverage and limits

  • Full grid: 23 inference cases across matrix/borrowed-row APIs, warm/cold layout and 1/4 threads; 29 cut/training cases at 1/4 threads. Includes repository fixtures, widths 30/256/1024, feature-use densities ~1/8/32/100%, depths 4/8, 10/100 trees, batches 1/15/16/256/10000, missing/categorical values, row views, finite sentinels and CSR.
  • Four-thread results are not headline evidence: identical binaries differed 25% in one warm control and 41% in a cold control. An isolated one-thread cut control also differed 29%. This prompted the additional interleaved end-to-end confirmation. All unfavorable samples and follow-ups are retained.
  • Cardinality-1024 training initially moved +5.7%, then −3.8% on follow-up, versus +3.1% for identical binaries. Full-use cold prediction moved +6.4%, then −2.1%, versus −4.1% for identical binaries. Neither is claimed as a win or established regression. Narrow/full-use/CSR paths are controls, not claimed improvements.
  • No representative production workload was supplied. Wide low-feature-use inference is a deliberate synthetic target, not evidence that typical models improve 52–80%. No dedicated-hardware, ARM or GPU performance claim. No memory improvement claimed: prediction retains full-width buffers and radix uses O(N) scratch.

Reproduction and rejected experiments

This PR commits source code only: four implementation files and four reproducible benchmark harness sources. No benchmark datasets, raw records, reports, binary archives or host metadata are added to git. Results are summarized here; complete evidence remains local.

Both binaries use identical harnesses. Checks require exact prediction/cut/model identities across binaries and thread counts; inference also uses an independent scalar tree-walk oracle.

Build baseline and candidate with Rust 1.99.1 and the same resolved dependencies,
default CPU features and release profile (opt-level 3, thin LTO, one codegen unit,
panic=abort, no target-cpu override). Copy the candidate's two benchmark examples
to baseline first. Use separate target directories and copy the ignored root
Cargo.lock between builds; do not commit it. Build serially, stop other local
builds/tests, then run the scripts serially. Example relative worktree layout:

BASE=baseline
CAND=candidate
(cd "$CAND" && cargo build --release --example bench_cpu_round3 --example bench_quantile_round3)
cp "$CAND/Cargo.lock" "$BASE/Cargo.lock"
cp "$CAND/examples/bench_cpu_round3.rs" "$BASE/examples/"
cp "$CAND/examples/bench_quantile_round3.rs" "$BASE/examples/"
(cd "$BASE" && cargo build --release --example bench_cpu_round3 --example bench_quantile_round3)
python "$CAND/scripts/bench_cpu_round3.py" --baseline "$BASE/target/release/examples/bench_cpu_round3" --candidate "$CAND/target/release/examples/bench_cpu_round3" --output runs/warm --threads 1 4 --repeats 15
python "$CAND/scripts/bench_cpu_round3.py" --baseline "$BASE/target/release/examples/bench_cpu_round3" --candidate "$CAND/target/release/examples/bench_cpu_round3" --output runs/cold --threads 1 4 --repeats 15 --cold-layout
python "$CAND/scripts/bench_quantile_round3.py" --baseline "$BASE/target/release/examples/bench_quantile_round3" --candidate "$CAND/target/release/examples/bench_quantile_round3" --output runs/training --threads 1 4 --repeats 15

For each of five confirmation cycles, run quantile cases approx_dense,
approx_unit, approx_missing, hist_control with one thread and three repeats;
then inference cases w256_p8_d4_t10_b16_missing,
w1024_p8_d8_t100_b10000_missing, w1024_p1_d4_t10_b256 with the same settings;
then approx_dense with the identical baseline executable for both labels.
Use a fresh output directory each time. The runners write local metadata alongside the measurements; inspect and
minimize those outputs before sharing. Generated outputs are not committed.

Rejected/constrained experiments: uncleared quantile-summary scratch had no reliable end-to-end gain; unconditional radix regressed duplicate-heavy training about 46% and ordered cuts 2–3×; collect-and-sort slot discovery regressed a cold deep-model case 18–25% before bounded bitmap discovery. No scheduling change is included. Rejected experiments are summarized only. Every final-code timing sample and same-binary control is retained locally, not committed.

Validation

  • All-feature tests: 973 passed, zero failed, six ignored, including 45 doctests.
  • All-target/all-feature Clippy and rustdoc with warnings denied; root/fuzz/CUDA Rust formatting; Python Ruff checks.
  • Independent source and benchmark-evidence review passed. All 427 summary rows reconcile with raw data; all 52 workload identities match.
  • Full generated parity, MSRV, Python wheel and platform coverage run in PR CI; local tests are not presented as those jobs.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-23T00:55:39.001904Z 6ec2259 PR opened
🔒 Security Review ✅ Completed 2026-10-23T00:57:53.590955Z 6ec2259 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.

@brndnmtthws
brndnmtthws merged commit 12fa2e4 into main Oct 23, 2026
25 checks passed
@brndnmtthws
brndnmtthws deleted the perf/cpu-round3-source branch October 23, 2026 02:04
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