Skip to content

feat(s2): elementwise bitwise kernels (and/or/xor/not) on gfx1151 + AVX-512 - #140

Merged
gstoner merged 1 commit into
mainfrom
s2/elementwise-bitwise
Jun 26, 2026
Merged

gstoner merged 1 commit into
mainfrom
s2/elementwise-bitwise

Conversation

@gstoner

@gstoner gstoner commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Adds the S2 bitwise family over i32 integers — the integer sibling of the logical lane (#139) — on both devices (gfx1151 + AVX-512). and/or/xor (binary) + not (unary), acting on the full bit pattern (no normalization, unlike logical). Together with #139 this closes the registry's entire logical category (logical_* + bitwise_*).

ROCm (gfx1151)

  • tessera_rocm.bitwise ODS op + generate-rocm-bitwise-kernel pass: arith.{andi,ori,xori} on i32; not = a ^ -1. Binary kinds emit a 4-arg signature; not emits a 3-arg (unary) signature.
  • Runtime rocm_bitwise_compiled lane (arity-aware, i32 in/out) + executor table + execution-matrix catalog/row + _ROCM_COMPILED / _NUMERICAL_FIXTURES.
  • test_rocm_bitwise_compiled.py: 19 tests pass on gfx1151 vs numpy across kind × shape incl. rank-3 + signed inputs, plus a GPU-free codegen gate (4 kinds → ROCDL, 3-arg/4-arg + memref<?xi32> asserted, bad kind rejected).

x86 (AVX-512)

  • avx512_bitwise_i32.cpp: _mm512_{and,or,xor}_si512 (16 i32/vector); not = xor all-ones.
  • test_bitwise.cpp: validated standalone on the AVX-512 host — ALL PASSED.

Honesty / scope

Test plan

  • 4 kinds codegen + lower to ROCDL; not=3-arg, rest=4-arg, i32 memrefs
  • test_rocm_bitwise_compiled.py — 19 passed on gfx1151
  • x86 test_bitwise.cpp — ALL PASSED on AVX-512 host
  • drift gate + perf-doc + mypy + ruff clean

🤖 Generated with Claude Code

…VX-512

Adds the S2 bitwise family over i32 integers — the integer sibling of the logical
lane (#139) — on both devices. and/or/xor (binary) + not (unary), acting on the
full bit pattern (no normalization, unlike logical).

ROCm (gfx1151):
- `tessera_rocm.bitwise` ODS op + `generate-rocm-bitwise-kernel` pass:
  arith.{andi,ori,xori} on i32; not = a ^ -1. Binary kinds emit a 4-arg
  signature; not emits a 3-arg (unary) signature.
- runtime `rocm_bitwise_compiled` lane (arity-aware, i32 in/out) + executor table
  + execution_matrix catalog/row; `_ROCM_COMPILED` + `_NUMERICAL_FIXTURES`.
- test_rocm_bitwise_compiled.py: validated on gfx1151 vs numpy across kind ×
  shape incl. rank-3 + signed inputs, + a GPU-free codegen gate.

x86 (AVX-512):
- avx512_bitwise_i32.cpp: `_mm512_{and,or,xor}_si512` (16 i32/vector); not = xor
  all-ones. Validated standalone (test_bitwise.cpp, ALL PASSED).

No x86:fused slot claimed (Decision #25). Completes the S2 logical-family registry
gaps (logical_* in #139 + bitwise_* here). Regenerated drift dashboards +
ROCM_AUDIT.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 61f709c941

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread python/tessera/runtime.py
ctypes.c_int64(0), ctypes.c_int64(size), ctypes.c_int64(1)]

for arr_in in inputs:
host = np.ascontiguousarray(arr_in, dtype=np.int32).reshape(-1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject non-int32 bitwise inputs before launch

When a rocm_bitwise_compiled artifact is launched with non-int32 arrays, this copy silently casts each operand to int32 before feeding the memref<?xi32> kernel. That truncates or reinterprets unsupported inputs such as int64/uint64/float values and returns wrapped 32-bit bitwise results instead of failing, while the manifest and execution row advertise only i32 support and neighboring ROCm lanes reject unsupported dtypes. Please validate all operands are np.int32 before copying them to the device (or return a clear error).

Useful? React with 👍 / 👎.

@gstoner
gstoner merged commit fc3d123 into main Jun 26, 2026
14 checks passed
@gstoner
gstoner deleted the s2/elementwise-bitwise branch June 26, 2026 19:19
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