⚡ Thunderbolt: softmax_v6 — 8x unrolled AVX2 Softmax with single-FMA exp256#76
⚡ Thunderbolt: softmax_v6 — 8x unrolled AVX2 Softmax with single-FMA exp256#76bugparty wants to merge 2 commits into
Conversation
…exp256 Co-authored-by: bugparty <1510776+bugparty@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Warning Review limit reached
Next review available in: 53 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?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 reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. 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, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds an AVX2 ChangesSoftmax v6
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related PRs
Sequence Diagram(s)sequenceDiagram
participant Caller
participant softmax_v6
participant exp256_ps_v3
participant Output
Caller->>softmax_v6: provide input and output buffers
softmax_v6->>softmax_v6: reduce maximum and compute sum
softmax_v6->>exp256_ps_v3: evaluate shifted input vectors
exp256_ps_v3-->>softmax_v6: return exponential vectors
softmax_v6->>Output: store normalized probabilities
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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.
🧹 Nitpick comments (1)
ml_kernels/include/ml_kernels/softmax.h (1)
505-505: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueFunction-body opening braces should be on their own line.
The coding guideline requires braces on their own lines for function bodies, but both new definitions place
{on the signature line (exp256_ps_v3at Line 505 andsoftmax_v6at Line 543). Note this matches the surrounding file style, so apply consistently only if the guideline is intended to be enforced here.As per coding guidelines: "Keep braces on their own lines for function bodies".
Also applies to: 543-543
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@ml_kernels/include/ml_kernels/softmax.h` at line 505, Move the opening braces for the function bodies of exp256_ps_v3 and softmax_v6 onto separate lines below their signatures, preserving all existing implementation logic.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@ml_kernels/include/ml_kernels/softmax.h`:
- Line 505: Move the opening braces for the function bodies of exp256_ps_v3 and
softmax_v6 onto separate lines below their signatures, preserving all existing
implementation logic.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8b8974c2-6f9a-415f-b9c5-8b5010fafa5c
📒 Files selected for processing (4)
.jules/thunderbolt.mdml_kernels/include/ml_kernels/softmax.hml_kernels/src/kernel_bench.cppml_kernels/src/test_naive_ops.cpp
Co-authored-by: bugparty <1510776+bugparty@users.noreply.github.com>
💡 What: Added
softmax_v6, an AVX2-optimized softmax kernel that unrolls the main computational loops 8x (handling 64 elements per iteration) and utilizes a fused constant in theexp256approximation via a single_mm256_fnmadd_ps.🎯 Why: The previous
softmax_v5kernel was unrolled 4x and utilized separate multiplication and subtraction instructions for range reduction. Theexp256approximations dominate execution time. By reducing the FMA instruction count and unrolling the loop 8x, the pipeline pressure is lowered, fully saturating the execution ports on AVX2, hiding the latencies of both theexp256calculations and themaxreductions.🏗️ How:
exp256_ps_v3that computesr = x - n*ln2using_mm256_fnmadd_pswith a full precision constant0.6931471805599453f.softmax_v6extending the 3-pass softmax structure, unrolling all loops 8x (64 elements).softmax_v6inml_kernel_bench.test_softmax_v6intest_naive_ops.cppwith a 72-element array to verify both the unrolled loop and the remainder loop.📊 Impact:
Microbenchmarking showed noticeable throughput improvements. End-to-end benchmarks demonstrated increased throughput, reaching up to ~6.29 GFLOP/s on N=16384 (Fixed Memory) compared to
softmax_v5's ~5.66 GFLOP/s.🖥️ Tested on: Ubuntu Linux (Docker container), GNU compiler 13.3.0, x86-64 CPU with AVX2.
🔬 How to reproduce:
PR created automatically by Jules for task 16067841156487821278 started by @bugparty
Summary by CodeRabbit
New Features
Performance
Tests