feat: update comm ops ods and add testcases#648
feat: update comm ops ods and add testcases#648FangRui0 wants to merge 1 commit intohw-native-sys:mainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the PTO communication dialect by renaming collective operations, implementing a more readable custom assembly format, and updating the EmitC lowering to utilize a new ParallelGroup abstraction. Feedback on the changes suggests improving the robustness of the MLIR Python bindings in the new test samples by explicitly handling optional operands with None and using keyword arguments for operation attributes to prevent potential positional argument mismatches.
| is_root = arith.CmpIOp(arith.CmpIPredicate.eq, my_rank, c1_i32).result | ||
| root_if = scf.IfOp(is_root, [], hasElse=False) | ||
| with InsertionPoint(root_if.then_block): | ||
| pto.TBroadcastOp(src, ping, group, 1) |
There was a problem hiding this comment.
In MLIR Python bindings, operations with AttrSizedOperandSegments and Optional operands typically require all positional arguments to be provided in order. Since TBroadcastOp has an optional pong operand before the variadic group, passing group as the third positional argument might lead to a type mismatch or incorrect IR generation. It is safer to pass None for the optional pong and use keyword arguments for attributes like root.
| pto.TBroadcastOp(src, ping, group, 1) | |
| pto.TBroadcastOp(src, ping, None, group, root=1) |
| is_root = arith.CmpIOp(arith.CmpIPredicate.eq, my_rank, c1_i32).result | ||
| root_if = scf.IfOp(is_root, [], hasElse=False) | ||
| with InsertionPoint(root_if.then_block): | ||
| pto.CommTGatherOp(dst, ping, group, 1) |
There was a problem hiding this comment.
Similar to the broadcast operation, CommTGatherOp has an optional pong operand. The current positional call skips it, which may cause issues with standard MLIR Python bindings. Using explicit None for optional operands and keyword arguments for attributes is recommended.
| pto.CommTGatherOp(dst, ping, group, 1) | |
| pto.CommTGatherOp(dst, ping, None, group, root=1) |
| is_root = arith.CmpIOp(arith.CmpIPredicate.eq, my_rank, c1_i32).result | ||
| root_if = scf.IfOp(is_root, [], hasElse=False) | ||
| with InsertionPoint(root_if.then_block): | ||
| pto.CommTScatterOp(src, ping, group, 1) |
There was a problem hiding this comment.
The positional arguments here skip the optional pong operand. To ensure robustness across different MLIR binding versions, please provide None for the optional operand and use a keyword argument for the root attribute.
| pto.CommTScatterOp(src, ping, group, 1) | |
| pto.CommTScatterOp(src, ping, None, group, root=1) |
| pto.TReduceOp( | ||
| dst, | ||
| acc, | ||
| recv, | ||
| group, | ||
| pto.ReduceOpAttr.get(pto.ReduceOp.Sum, ctx), | ||
| 1, | ||
| ) |
There was a problem hiding this comment.
The TReduceOp has an optional recvPong operand. The current call passes group in its place positionally. Additionally, attributes like reduceOp and root should ideally be passed as keyword arguments to avoid ambiguity and potential binding errors.
| pto.TReduceOp( | |
| dst, | |
| acc, | |
| recv, | |
| group, | |
| pto.ReduceOpAttr.get(pto.ReduceOp.Sum, ctx), | |
| 1, | |
| ) | |
| pto.TReduceOp( | |
| dst, | |
| acc, | |
| recv, | |
| None, | |
| group, | |
| reduceOp=pto.ReduceOpAttr.get(pto.ReduceOp.Sum, ctx), | |
| root=1, | |
| ) |
Codex Review该评论由 review 机器人自动更新。
SummaryPR #648 introduces backward-incompatible communication-op IR changes: it renames collective mnemonics and removes parsing support for the previously accepted p2p/signal syntax. Findings
This changes the public op names from
The assembly form for |
Signed-off-by: FangRui <fangrui_95@163.com>
No description provided.