Hi all,
Last week I filed nine issues against the shard and MPI dialects (#246375 to #246384) before properly kniwing that a batch like this should start with a thread here. Sorry about that, and thanks to @FedericoBruzzone and @EugeneZelenko for pointing me to the policy. I have about 25 more findings in the same area, so I would like to agree here on which ones are worth filing and how.
What I am testing
- Passes: sharding-propagation, shard-partition, shard-simplify, convert-shard-to-mpi and MPI-to-LLVM, mostly in the order a shard pipeline runs them.
- Inputs: only valid IR. some programs are hand-written and the rest come from a small generator. They use linalg and TOSA ops (elementwise ops, matmuls, reductions and small MLP and attention blocks) with shard annotations on grids of one to four dimensions, with halos, uneven shardings and the collectives.
- How a finding is confirmed: I am working on a research tool that checks the IR after partitioning against the IR before it. When it flags a program, I lower it to LLVM, run it under mpirun with MPICH and Open MPI at -O0 and -O2, and compare the result with the unpartitioned program. A wrong-code finding only counts if that run is wrong. Crashes, assertion failures and verifier errors on valid input count directly.
- llvm-project: using f95203a with assertions. I will re-check each finding on current main before filing it.
AI involvement
I sometimes used an AI coding assistant (Claude Code) to help write the generator and some of the test programs, to reduce the reproducers and to tidy up the reports wording. I ran every reproducer myself and checked the results.
Already filed
- Issues #246375, #246376 and #246378 to #246384.
- PRs #246398 and #246401 fix #246375 and #246384. @fschlimb has reviewed both, and they are waiting for someone to merge them, since I do not have commit access. #246399 and #246400 fix #246376 and #246378 and still need a reviewer, if someone who knows MPIToLLVM has a moment.
The findings
The IDs are only for this thread. Each one has a reduced reproducer, and the wrong-code ones also have the MPI runs.
Wrong results at run time
- W1. shard-partition keeps linalg.index in a split loop, so each device sees its local index instead of the global one.
- W2. shard-partition gives a linalg result its annotated sharding without resharding the computed data.
- W3. shard-partition gives tensor.empty the global size of a dynamic split dimension, so each device returns a tensor of the global shape.
- W4. With sharded_dims_offsets on a dimension split over several grid axes, the shard count is the sum of the axis sizes instead of their product, so the local types are wrong.
- W5. convert-shard-to-mpi lowers shard_shape on a dimension split over several grid axes using only the first axis.
- W6. In the local type of a sharding with halos, a dynamic split dimension shifts the halo pairs of the dimensions after it.
- W7. update_halo is lowered to an exchange with direct neighbours only, so a halo wider than a shard gets uninitialised data.
- W8. shard-simplify folds all_gather(all_slice(x)) to x, although the input of all_slice does not have to be replicated.
- W9. shard-simplify folds minui or maxui of two min or max all_reduces into a single all_reduce.
Crashes and assertion failures
- C1. convert-shard-to-mpi asserts on an all_gather whose input has size 1 along the gather axis.
- C2. shard-partition asserts when a value with halos is resharded to the same split without halos.
- C3. convert-shard-to-mpi reaches llvm_unreachable on an all_reduce with reduction = generic, which shard-partition emits for maxnumf and minnumf.
- C4. shard-partition asserts on a linalg op with two outputs whose reduction dimension is split.
- C5. convert-shard-to-mpi crashes on a sharding with sharded_dims_offsets and an unsplit dimension, which is the example from the shard.sharding docs.
- C6. shard-partition fails without any diagnostic on a non-splat tensor constant, even a replicated one.
- C7. sharding-propagation and shard-partition abort on every split tosa.mul, because the shift operand gets the sharding of the data operands.
- C8. shard-partition asserts on every sharded tosa.matmul, as MatMulOpSharding has no partition method.
- C9. sharding-propagation gives a broadcast (size 1) operand of a TOSA elementwise op the split of the result, and shard-partition then asserts.
- C10. shard-partition on a function with several blocks either aborts (“operation destroyed but still has uses”) or emits a broken CFG.
- C11. sharding-propagation asserts when the users of a value are annotated differently.
- C12. MPIToLLVM asserts “unsupported type” on f16, bf16, i1 and index buffers.
Invalid IR
- V1. convert-shard-to-mpi lowers update_halo on a dynamically shaped tensor by querying dimension kDynamic, and dynamic halo sizes give invalid IR.
- V2. convert-shard-to-mpi emits an invalid mpi.reduce_scatter_block when reduce_scatter changes the element type.
- V3. shard-partition drops the size operand of a tensor.splat with a dynamic size.
- V4. After shard-partition, a call to a partitioned function keeps the callee’s old argument types, so the module fails to verify.
- V5. sharding-propagation prints
split_axes = []for 0-d tensors, which the parser rejects.
Proposed criteria
(a) The pass is part of the usual shard pipeline (propagation, partitioning, simplification, shard to MPI and MPI to LLVM), and the input is valid IR of a kind the dialect’s docs or tests already use. (b) The failure is unambiguous, such as a wrong result under MPI, a crash or IR that fails to verify. (c) The input could come from real use, for example linalg or TOSA from a frontend with sharding annotations, or the output of sharding-propagation itself.
By these, I would file the wrong-code findings first (W1 to W9), then the crashes on common ops (C4, C7, C8 and C9), and keep the rest in a list until someone wants them.
How I would file them
After a sign-off here, 1-2 per day max with fuzzer-found template and a link back to the sign-off post. I am happy to send fixes for the ones I understand well, as with the four PRs above. If a separate repo with the full reports, help, do let me know.
Does this sound reasonable? I would be glad of any thoughts on the criteria or the order, especially from people who work on the shard and MPI dialects.
Thanks!