This change prevents convert_layout propagation of slice layouts across broadcast/expand_dims. It is generally a good idea, but it is especially important when running triton-xla-squeeze-dims, which removes expand_dims ops. The expand_dims ops remove the slice layouts, so we need to prevent them from propagating further across broadcast ops which can cause large tensor materialization. See also b/422133176 --- a/lib/Dialect/TritonGPU/Transforms/RemoveLayoutConversions.cpp +++ b/lib/Dialect/TritonGPU/Transforms/RemoveLayoutConversions.cpp @@ -343,6 +343,15 @@ SmallVector LayoutPropagation::propagateToUsers(Value value, if (auto reshapeOp = dyn_cast(user); reshapeOp && reshapeOp.getEfficientLayout()) continue; + // Heuristic: don't propagate slice layouts across broadcasts. + // This can cause massive register pressure. It's better to convert to + // blocked before the broadcast. + if (isa(user) && + llvm::any_of(info.encodings, [](Attribute encoding) { + return llvm::isa_and_nonnull(encoding); + })) { + continue; + } if (user->hasTrait() || user->hasTrait() || isa