Fix chunking non outermost dims and insert new generic for cross-chunk accumulation to avoid fp numerical mismatch - #149
Open
acgatea1 wants to merge 6 commits into
Conversation
… reduction dim) Signed-off-by: Alex Gatea <alexgatea@ibm.com>
…o add the accumulator with the partial FIFO value Signed-off-by: Alex Gatea <alexgatea@ibm.com>
…-partial scf.if Signed-off-by: Alex Gatea <alexgatea@ibm.com>
acgatea1
requested review from
Prasanth-Chatarasi,
bmahjour,
lupalby,
viji560 and
vswagath1989
as code owners
September 10, 2026 17:29
Signed-off-by: Alex Gatea <alexgatea@ibm.com>
msdataei
reviewed
Sep 10, 2026
…icit --num-chunks allows multi-dim Signed-off-by: Alex Gatea <alexgatea@ibm.com>
acgatea1
force-pushed
the
fix_chunking_non_outermost_dims_and_fp_numerical_mismatch
branch
from
September 10, 2026 19:51
9de0e3d to
46c1609
Compare
msdataei
approved these changes
Sep 10, 2026
| // CHECK: scf.if %[[IS_FIRST:.*]] { | ||
| // CHECK-NEXT: } else { | ||
| // CHECK-NEXT: %[[RD1:.*]] = ktdf.read_from_fifo %[[PRIV1]]#1 : <"L1LU" -> "SFU", 64xf16> -> memref<1x64xf16> | ||
| // CHECK-NEXT: linalg.generic {indexing_maps = [#[[$MAP2]], #[[$MAP2]]], iterator_types = ["parallel", "parallel"]} ins(%[[RD1]] : memref<1x64xf16>) outs(%[[ALLOC]] : memref<1x64xf16, "SFU_REG">) |
Contributor
There was a problem hiding this comment.
It is good that we are using the same allocation as above linalg.generic.
Contributor
Signed-off-by: Alex Gatea <alexgatea@ibm.com>
bmahjour
requested changes
Sep 10, 2026
Comment on lines
+1012
to
+1014
| sum_val = arith::AddFOp::create(b, b_loc, in_val, out_val); | ||
| } else { | ||
| sum_val = arith::AddIOp::create(b, b_loc, in_val, out_val); |
Collaborator
There was a problem hiding this comment.
We should derive the reduction op from the input to this pass (not assume sum).
Collaborator
There was a problem hiding this comment.
please also add a test with a non-sum reduction (eg. max)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[ReductionDimChunking] — Restrict chunking to the outermost reduction dim, skipping the inner reduction dim, to avoid incorrectly chunking dims that are handled separately by SplitReductionInnerOuterDim.
[ReductionLoopExposure] — When cross-chunk accumulation is needed (partial FIFO path), move seed initialization from a conditional scf.if before the loop to an unconditional tensor.empty. After the loop, emit a combine scf.if that on the first chunk passes the loop result through, and on subsequent chunks reads the previous partial from the FIFO and adds it via a parallel linalg.generic. The write_to_fifo guard (scf.if all-ivs-last) inside the loop is preserved unchanged.
[MapReductionPartials] — Handle the new combine scf.if pattern that appears as G2's input after ReductionLoopExposure. Lower it to a result-less scf.if (then-branch empty, else-branch memref read_from_fifo + buffer linalg.generic add into the G1 alloc), then wire the alloc directly as G2's ins. Add LIT test outer_inner_dim_with_partial.mlir covering the full outer+inner absmax-with-partial flow.
Passes internal tests