Skip to content

Commit

Permalink
Catch the minimum_cut NetworkXUnbounded exception and give clear erro…
Browse files Browse the repository at this point in the history
…r message (#1330)
  • Loading branch information
kiya00 authored Oct 18, 2024
1 parent 311ad66 commit 582fb69
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion thunder/core/rematerialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,13 @@ def add_edges(var):
g = nx.DiGraph()
g.add_edges_from(edges)

_, (reachable, non_reachable) = nx.minimum_cut(g, "source", "sink")
try:
_, (reachable, non_reachable) = nx.minimum_cut(g, "source", "sink")
except Exception:
raise RuntimeError(
"Failed to compute the min-cut on the graph due to a path with infinite capacity."
"Please report this error along with your function and relevant details at: https://github.com/Lightning-AI/lightning-thunder/issues/new"
)

cut_edges = set()
for u, nbrs in ((n, g[n]) for n in reachable):
Expand Down

0 comments on commit 582fb69

Please sign in to comment.