Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjusting BFS to seek circular dependencies in the msccl-tools DAG #459

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion python/mscclpp/language/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,9 @@ class _NopConverter(_OpConverter):
def to_json(self, op: Op, tb_channel_dict: dict) -> _JsonInstruction:
return _JsonInstruction(
name=op.inst.value,
deps=list(map(lambda dep: {"tb": dep.tb, "step": dep.step}, op.depends)),
deps=sorted(
list(map(lambda dep: {"tb": dep.tb, "step": dep.step}, op.depends)), key=lambda x: (x["tb"], x["step"])
),
)


Expand Down
5 changes: 4 additions & 1 deletion python/mscclpp/language/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def merge_op(op: Op, other_op: Op):
def circular_dep_after_merge(op: Op, other_op: Op):
root = set([op, other_op])
frontier = set(op.next)
visited = set()
if other_op in frontier:
frontier.remove(other_op)
frontier = list(frontier.union(other_op.next))
Expand All @@ -46,7 +47,9 @@ def circular_dep_after_merge(op: Op, other_op: Op):
# The root node will be visited again if there is a circular dependency
if n in root:
return True
frontier.append(n)
if n not in visited:
frontier.append(n)
visited.add(n)
frontier = frontier[1:]


Expand Down
Loading