Skip to content

hpc::abakus::pm: add_pm / neg_pm / sub_pm as an experimental library module - #433

Merged
AdaWorldAPI merged 1 commit into
masterfrom
ccr-85acaff0-oszq40-sub-pm
Nov 15, 2026
Merged

AdaWorldAPI merged 1 commit into
masterfrom
ccr-85acaff0-oszq40-sub-pm

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

This moves the Codec9 P × M arithmetic out of the add_pm example into a library module, so there is one copy of the code. It was approved after P2 (#432).

Layout

  • ndarray::hpc::codec9 (unchanged): the representation, meaning encode/decode, scale, rounding and the never-touched sentinel.
  • New ndarray::hpc::abakus::pm: the operations on values in that form, and their carry contract. It contains Pm, touched, add_pm, neg_pm and sub_pm. The module is documented as experimental, with no stability guarantee.

How carry lanes are exposed

All 512 codewords are valid values, so a carry lane can't be marked invalid inside the byte itself. Instead, add_pm and sub_pm return a #[must_use] PmSum:

method returns
lane(i) NeverTouched, Exact(i16), or Escaped for a carry lane
exact() Some(Pm) only when no lane carried
carry() the carry mask
into_saturated_parts() the raw bytes plus the carry mask; the name says that carry lanes hold saturated bytes, not results

There is no other way to get the lanes out as a plain Pm.

The example, tests and CI

  • examples/add_pm/pm.rs now keeps only the scalar oracle and timing code. Thin wrappers call the library and return into_saturated_parts().
  • So tests/add_pm.rs (11 tests, unchanged) now tests the library code. The same holds for the backend rows from add_pm probe: sub_pm as addition of the polarity-negated operand (P2) #432 that run it: avx2, avx, v2 and neon.
  • Two new library unit tests cover PmSum::lane / exact / into_saturated_parts.

Verification

  • Tests: tests/add_pm.rs passes 11/11 on AVX-512, and on avx2 / avx-qemu / v2-qemu / neon-qemu through scripts/add-pm-backends.sh. The library unit tests pass 2/2.
  • Disable run: I committed first, then broke the library's neg_pm (polarity flipped on zero magnitudes). 4 tests failed, which shows the suite exercises the library code.
  • Checks: cargo clippy --features std --lib --test add_pm --example add_pm -D warnings is clean. cargo doc shows no warnings from the new module; the crate's existing unresolved-link errors are unrelated. The facet-stride guard passes on the diff.

Next

After this merges, the lab copy of the arithmetic in lance-graph's xlog-relcomp-probe (PmLedger) gets replaced with a dependency on this module. That PR keeps its i64 oracle and end-to-end tests, and also records #2086's merge without a final-head review as a governance exception.


Generated by Claude Code

…module

The P x M arithmetic moves out of the add_pm example into
ndarray::hpc::abakus::pm, the one source of truth; Codec9 keeps the
representation. add_pm and sub_pm return a #[must_use] PmSum: lane() reports a
carry lane as Escaped, exact() is Some only when nothing carried, and the
saturated bytes come only from into_saturated_parts(). The example keeps the
scalar oracle and timing and calls the library, so tests/add_pm.rs (and the
backend rows that run it) now test the library code.

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

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

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: Advanced
  • Run ID: aaac2652-74b2-4799-ad1f-11764232687a
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review November 15, 2026 12:58
@AdaWorldAPI
AdaWorldAPI merged commit 65a16d6 into master Nov 15, 2026
21 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 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-15T13:00:10.675371Z 0f61670 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.

AdaWorldAPI pushed a commit that referenced this pull request Nov 15, 2026
Pm derived PartialEq, which needs U8x64: PartialEq; the nightly-simd
realization's U8x64 does not implement it, so master's nightly row has
been red since #433. Pm now compares pos and mag.to_array().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XAqKMNZqKXSaeb9g2ypywF
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