add batched_syrk triton kernel - #276
Conversation
Signed-off-by: Rudin6 <41809200+Rudin6@users.noreply.github.com>
Signed-off-by: Rudin6 <41809200+Rudin6@users.noreply.github.com>
Refactor SYRK handling for tensor dimensions and device compatibility. Introduce batched_newton_schulz_step_tsyrk function for batched input processing. Signed-off-by: Rudin6 <41809200+Rudin6@users.noreply.github.com>
This benchmark script compares the performance and accuracy of the batched_tsyrk_ex function against PyTorch's baddbmm and bmm functions. It includes functions for reference computation, error measurement, and timing benchmarks. Signed-off-by: Rudin6 <41809200+Rudin6@users.noreply.github.com>
Signed-off-by: Rudin6 <41809200+Rudin6@users.noreply.github.com>
Updated test to allow use_syrk on batched CPU input, which now falls back to GEMM path instead of raising an error. Signed-off-by: Rudin6 <41809200+Rudin6@users.noreply.github.com>
Rudin6 patch 1
Greptile SummaryThe PR adds a batched Triton SYRK kernel and integrates it into batched Newton–Schulz iterations for CUDA tensors.
Confidence Score: 4/5The PR should not merge until the outstanding CUDA device-to-host synchronizations in the benchmark are addressed in accordance with the repository rule. The benchmark still converts CUDA reduction results to Python via Files Needing Attention: benchmarks/bench_batched_syrk.py Important Files Changed
Sequence DiagramsequenceDiagram
participant NS as newton_schulz
participant Step as batched_newton_schulz_step_tsyrk
participant SYRK as batched_tsyrk_ex
participant Kernel as Triton batched_syrk kernel
NS->>Step: Batched BF16 CUDA tensor
Step->>SYRK: "X @ X.mT"
SYRK->>Kernel: Launch lower-triangular tile grid
Kernel-->>SYRK: Symmetric Gram matrices
SYRK-->>Step: A
Step->>SYRK: "c*A@A + b*A (quintic path)"
Step-->>NS: Updated batch via baddbmm
Reviews (2): Last reviewed commit: "Merge branch 'main' into main" | Re-trigger Greptile |
| out = alpha * (a.float() @ a.mT.float()) | ||
| if beta != 0.0: | ||
| out += beta * c.float() | ||
| return out |
There was a problem hiding this comment.
CUDA reductions force host synchronization
When the benchmark reports correctness on CUDA, these .item() calls synchronously transfer reduction results to Python, stalling queued GPU work and perturbing benchmark execution; the same pattern occurs in the symmetry checks on lines 68 and 136.
Rule Used: Always flag device-to-host synchronizations (e.g.,... (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Should be fine in benchmark if not in the timed region.
There was a problem hiding this comment.
Fair point — correctness checks that run outside the timed region don't skew the benchmark measurements. I'll stand down on this one.
Shall I remember this as a rule: "Do not flag .item() calls or other device-to-host synchronizations in benchmark files when they are used for correctness/validation checks outside the timed region"?
|
@gdengk could you help review the triton code? I can review the rest. |
No description provided.