Skip to content

D-PM-STATS: probe what P×M makes cheaper (statistics, comparison, products) - #439

Merged
AdaWorldAPI merged 2 commits into
masterfrom
ccr-85acaff0-oszq40-pm-stats
Nov 25, 2026
Merged

AdaWorldAPI merged 2 commits into
masterfrom
ccr-85acaff0-oszq40-pm-stats

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Summary

This is a research probe. It adds no kernel, API or layout: everything is composed from existing ndarray::simd words and abakus::pm. It asks which operations get cheaper when polarity and magnitude can be accessed independently. Findings are in .claude/knowledge/pm-stats-probe.md.

The idea the results rest on: an untouched lane has M = 0, so it adds nothing to Σx, Σ|x|, Σx² or Σxy. Only the count N needs touched. None of these folds needs a validity prefilter, and x² and |x| don't need polarity at all.

  • Probe 1, sufficient statistics. N, S, Q and A come from one demand-driven fold. Variance is returned as the exact rational (N·Q − S², N²). Two ways of computing S are compared: summing positive and negative magnitudes separately, and ΣM − 2ΣM⁻.
  • Probe 2, comparison and selection. lt, le and eq are three-valued: each returns the lanes where it holds and a separate mask of undecidable lanes. lt_const handles a comparison against a constant, and min and max are built on lt.
  • Probe 3, products. Σxy is computed partitioned by product polarity, in two forms.

Tests

tests/pm_stats.rs has 11 tests, green on AVX-512 and on the v3 (AVX2) tier. NEON and wasm were not run.

The oracles:

  • comparison, selection and products are checked on every 512 × 512 codeword pair;
  • lt_const is checked for every constant from −255 to 255;
  • the statistics are checked against an exact scalar fold, with boundary populations: all untouched, only +0, full cancellation, and a nearly constant population with variance 63/4096.

Each disable run turns the suite red:

Disabled Failing
lt ignores polarity 2
lt without the known mask 1
N from P alone 3
S ignores polarity 1
prod_sum drops its high byte 5
dot product ignores polarity 1
x < 0 without the touched check 1

Measured

Times are ns per 64 lanes, best of 7, from two runs on a shared host. Some cells move 2–3× between runs, so the table gives ranges.

AVX-512 AVX2
S, 64K lanes 2.9–3.9, flat over density and polarity mix; masked_sum_i32 1.7 at ≤1%, 12 at ≥50% 8.4–14; masked_sum_i32 1.7–4 sparse, 9–20 dense
ΣM − 2ΣM⁻ vs split slower (4.0 vs 2.9) faster (8.4 vs 9.8+)
N, S, Q, A, 50% selected 12–18 at 64, 64K and 16M lanes; scalar i16 loop 41–51 44–47 vs 40–48: no win
a < b 3.5–4.5 vs I16x32 3.1–4.2 4.95 vs 3.08: slower
x < 0 1.7–1.9 1.8
dot, 64K / 16M lanes 16–17 vs 11–15 / 20–25 vs 26–32 59–61 vs 11–30: large loss

What this shows:

  • The statistical fold is the strong result on AVX-512.
  • Signed comparison and the dot product are not cheaper in ALU work. Their wins come from bytes read: 72 per 64 lanes against 128–256.
  • x < 0 is genuinely cheaper.
  • The dot product loses badly on AVX2.

Not captured: the instruction sequences (the arms inlined, so there was no symbol to disassemble), latency as opposed to throughput, other ISA tiers, wider widths, and folding across DR tiles.


Generated by Claude Code

…itioned products

Research probe, composed from existing ndarray::simd words: no new kernel,
API or layout. Oracles: every 512x512 codeword pair for comparison,
selection and products; random and boundary blocks for N, S, Q, A.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAqKMNZqKXSaeb9g2ypywF
The fold reads the register shape a source lends (u8 magnitude slab plus
u64 polarity plane) and shares its block function with the tested path.
The bench compares against masked_sum_i32, an I16x32 compare and i16
loops, on AVX-512 and AVX2. Findings are in
.claude/knowledge/pm-stats-probe.md: the statistical fold is the strong
result on AVX-512; signed compare and dot product are not cheaper in ALU
work, and the dot product loses badly on AVX2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAqKMNZqKXSaeb9g2ypywF
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab.

Next included review available in 35 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 88 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 32ac0da2-aae0-42c0-b50e-f25419cfce6f
Commits

Reviewing files that changed from the base of the PR and between a6b6c05 and 0c223bf.

Files selected for processing: 5

  • .claude/knowledge/pm-stats-probe.md
  • Cargo.toml
  • examples/pm_stats/main.rs
  • examples/pm_stats/stats.rs
  • tests/pm_stats.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review November 25, 2026 00:55
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-25T00:55:05.698748Z
We couldn’t complete this review. Comment @codex review to try again.
0c223bf Draft marked ready
ℹ️ 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@AdaWorldAPI
AdaWorldAPI merged commit 82d1294 into master Nov 25, 2026
30 checks passed
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.

2 participants