[RFC] Sharding Framework Design for Device Mesh

I got the time to read your proposal and the DISTAL paper. During the reading, I kept asking my self two questions:

  1. Is the sharding representing space of your proposal the same as the SPMD format?
  2. If the sharding / ccl optimization is implemented on the sharding representation of your proposal, will it be better or easier to be implemented on SPMD format?

For the first question, I’m afraid the answer is no. Using your example of sharding along tensor axis 0 with halo/border of size b. In the case of indivisibility, we could have the option to put the excess part in the first or last device of a mesh dimension. This is what your proposal cannot represent. While in the SPMD format with extract_slice op, arbitrary sharding / slice logic could be represented.

For the 2nd question, my answer is maybe. But considering 1) the representing space in SPMD format is larger and 2) existing passes like optimizing the extract_slice operations could be reused in the SPMD format. Therefore the total workload would still be less if we implement the sharding / ccl optimization in SPMD format.

Finally, I still suggest we align the design closely to XLA GSPMD, adapting it as necessary to cater to MLIR’s requirements. Given the proven functionality of GSPMD, utilizing it as a foundational reference could provide a reliable pathway for implementing this framework within MLIR.

@sogartar if you agree with me, we can proceed the SPMD partitioner part of the the sharding framework.