feat(simd): add ndarray::simd::bf16_tile_gemm_16x16 polyfill primitive#222
Conversation
A 16x16 BF16 tile GEMM (`C[16,16] += A[16,K]·B[K,16]`, K multiple of 32) built purely from the SIMD polyfill: BF16->f32 decode + `F32x16::mul_add`. The `F32x16` wrapper owns the per-arch dispatch (AVX-512 VFMADD231PS where available -> AVX2 pair -> NEON -> scalar), so the kernel rides AMX/AVX-512 hosts automatically. No `hpc` reference, no AMX intrinsic, no external BLAS. Lives in src/simd_ops.rs, re-exported via `ndarray::simd`. Parity test vs an f32-accumulated scalar reference + a `+=` accumulation test + doctest all pass on AVX-512; clippy -D warnings + fmt clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GJ4NVBSjq1w5h7RmTbVafb
|
Warning Review limit reached
More reviews will be available in 59 minutes and 22 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: afb53c28c8
ℹ️ 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".
| let mut col = vec![0.0f32; k]; | ||
| for (kk, slot) in col.iter_mut().enumerate() { | ||
| *slot = b_f32[kk * 16 + j]; | ||
| } |
There was a problem hiding this comment.
Reuse B column buffers outside the row loop
For each output element (i, j), this allocates and fills a k-element Vec, so one 16×16 tile does 256 heap allocations and repeats the same B-column gather once for every row. In hot tiled GEMM use, especially for small or moderate k, that allocator and memory traffic can dominate the SIMD FMA work; pretranspose/gather the 16 B columns once per call or at least once per j and reuse them across all 16 rows.
Useful? React with 👍 / 👎.
PR #222 added ndarray::simd::bf16_tile_gemm_16x16 by copying the F32x16 kernel out of hpc::bf16_tile_gemm::fallback_path, leaving the same kernel in two places. Collapse it: the polyfill fn is the single source of truth; the hpc AMX wrapper's fallback now calls crate::simd::bf16_tile_gemm_16x16, with the AMX TDPBF16PS tile path still layered on top. Drops the now-unused F32x16 / bf16_to_f32_batch import. Both suites pass (hpc fallback + simd_ops parity); clippy -D warnings + fmt clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GJ4NVBSjq1w5h7RmTbVafb
refactor(hpc): bf16_tile_gemm fallback delegates to the polyfill (dedup of #222)
A 16x16 BF16 tile GEMM (
C[16,16] += A[16,K]·B[K,16], K multiple of 32)built purely from the SIMD polyfill: BF16->f32 decode +
F32x16::mul_add.The
F32x16wrapper owns the per-arch dispatch (AVX-512 VFMADD231PS whereavailable -> AVX2 pair -> NEON -> scalar), so the kernel rides AMX/AVX-512
hosts automatically. No
hpcreference, no AMX intrinsic, no external BLAS.Lives in src/simd_ops.rs, re-exported via
ndarray::simd. Parity test vs anf32-accumulated scalar reference + a
+=accumulation test + doctest allpass on AVX-512; clippy -D warnings + fmt clean.
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01GJ4NVBSjq1w5h7RmTbVafb