Skip to content

Check that distributed DAG is deadlock-free - #366

Merged
inducer merged 10 commits into
mainfrom
check-dist-deadlock
Nov 14, 2022
Merged

Check that distributed DAG is deadlock-free#366
inducer merged 10 commits into
mainfrom
check-dist-deadlock

Conversation

@matthiasdiener

@matthiasdiener matthiasdiener commented Oct 18, 2022

Copy link
Copy Markdown
Contributor

@matthiasdiener
matthiasdiener force-pushed the check-dist-deadlock branch 2 times, most recently from 92b53d1 to 0789c7d Compare October 18, 2022 21:02
@matthiasdiener matthiasdiener self-assigned this Oct 18, 2022
@matthiasdiener

Copy link
Copy Markdown
Contributor Author

Is this going in the direction you had in mind @inducer?

@inducer

inducer commented Oct 19, 2022

Copy link
Copy Markdown
Owner

Is this going in the direction you had in mind @inducer?

Yes, but unless I'm mistaken, you're currently still missing the edges relating to inter-rank communication. (And those are the interesting ones.)

@kaushikcfd

Copy link
Copy Markdown
Collaborator

I'm guessing the DAG being constructed here has nodes of the form (part_id, rank_nr) with edges of 3 types:

  1. Inter-rank dependencies from the comm nodes matched by their tags
  2. Intra-rank dependencies of the form P1->P2 iff P2 uses P1's output as an input.

Comment thread pytato/distributed.py Outdated
@matthiasdiener
matthiasdiener force-pushed the check-dist-deadlock branch 4 times, most recently from dd6d79d to 3af81dd Compare October 31, 2022 21:59
Comment thread pytato/distributed.py Outdated
@inducer
inducer force-pushed the check-dist-deadlock branch from 9d47108 to 446daf5 Compare November 1, 2022 00:13
Comment thread pytato/distributed.py Outdated

print(all_summarized_parts)
output_to_defining_pid: Dict[_DistributedName, _DistributedPartId] = {}
for sumpart in all_summarized_parts.values():

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the keys in part.input_name_to_recv_node, there are no corresponding output_names, which is why this fails later on.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch. I believe that that's what we were missing. Do you want to push a fix?

@matthiasdiener matthiasdiener Nov 1, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what the right fix is - should we just ignore those input names in the later loop (around line 1023)?

Edit:
Done in 89dc0ef

@kaushikcfd

kaushikcfd commented Nov 1, 2022

Copy link
Copy Markdown
Collaborator

Is the global parts DAG verifier here noticing cycles in any of the distributed tests? I ask because it seems some of the CI runs are getting timed out by running into a deadlock -- https://github.com/inducer/pytato/actions/runs/3365558563/jobs/5583742094. The CI run is from #374.

@kaushikcfd

kaushikcfd commented Nov 1, 2022

Copy link
Copy Markdown
Collaborator

Looks like the CI in this PR is also experiencing the deadlock? I don't see any other reason why the tests would take this long.

@matthiasdiener

matthiasdiener commented Nov 1, 2022

Copy link
Copy Markdown
Contributor Author

Looks like the CI in this PR is also experiencing the deadlock? I don't see any other reason why the tests would take this long.

The tests (added in 05b4668) run fine on my local machine. My guess is that the MPI runtime inside the CI trips over the fact that one rank exited with an exception and just hangs.

@kaushikcfd

kaushikcfd commented Nov 1, 2022

Copy link
Copy Markdown
Collaborator

The tests run fine on my local machine.

It seems to me moving to Py3.11 is triggering the error.

My guess is that the MPI runtime inside the CI trips over the fact that one rank exited with an exception and just hangs.

Could be the case. I didn't account for that.

@matthiasdiener
matthiasdiener marked this pull request as ready for review November 3, 2022 22:44
@kaushikcfd

kaushikcfd commented Nov 3, 2022

Copy link
Copy Markdown
Collaborator

Thanks! I ran deadlock_checker with this branch and the user experience was almost great. The driver reported the error -- ValueError: duplicate send for comm id: '_CommIdentifier(source_rank=1, dest_rank=0, comm_tag=43)' and deadlocked. The error was very helpful, but there were some non-ideal bits:

  • I don't think there is a duplicate send from rank 1.
  • The deadlocking bit is not great, it should gracefully terminate.

@kaushikcfd

Copy link
Copy Markdown
Collaborator

(I'll remove myself as a reviewer since you guys are more knowledgeable about this than me.)

@kaushikcfd
kaushikcfd removed their request for review November 3, 2022 23:35
@matthiasdiener

matthiasdiener commented Nov 4, 2022

Copy link
Copy Markdown
Contributor Author

Thanks! I ran deadlock_checker

Thanks, this is really helpful! There was a bug in _SummarizedDistributedSend which is hopefully fixed now.

with this branch and the user experience was almost great. The driver reported the error -- ValueError: duplicate send for comm id: '_CommIdentifier(source_rank=1, dest_rank=0, comm_tag=43)' and deadlocked. The error was very helpful, but there were some non-ideal bits:

  • I don't think there is a duplicate send from rank 1.

Right, with the fix there is a duplicate send from rank 0-> 1 now, which seems correct (the visualized DAG shows the same duplicate).

  • The deadlocking bit is not great, it should gracefully terminate.

Not sure what the best way to handle this is. It seems like it's MPI runtime specific.

@inducer
inducer force-pushed the check-dist-deadlock branch 3 times, most recently from 794e1c7 to a8a72dc Compare November 9, 2022 18:36
@inducer

inducer commented Nov 9, 2022

Copy link
Copy Markdown
Owner

I'm working on cleaning this up. In

https://github.com/inducer/pytato/compare/794e1c79d1995cdee842368188cc4afd4143cb25..a8a72dcbfa68be5edf58515945e8ba11cb066703

I've dropped all the unrelated stuff.

@inducer
inducer force-pushed the check-dist-deadlock branch 4 times, most recently from e114fe1 to 222611f Compare November 9, 2022 19:17
Comment thread test/test_distributed.py Outdated
with pytest.raises(ValueError):
verify_distributed_partition(comm, distributed_parts)
else:
verify_distributed_partition(comm, distributed_parts)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests don't cover many of the things the verifier guards against. While I'm tempted to merge this so that we can start using it, I feel like it might be wise to wait for coverage of at least the following scenarios:

  • Duplicate send
  • Duplicate recv
  • Cycle in the graph

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - I added these additional tests in 8d112fe

@inducer
inducer force-pushed the check-dist-deadlock branch from 222611f to 46992cd Compare November 10, 2022 00:28
@inducer
inducer force-pushed the check-dist-deadlock branch from 46992cd to 994d1b2 Compare November 10, 2022 00:32
@inducer

inducer commented Nov 10, 2022

Copy link
Copy Markdown
Owner

Sorry, had a few more force-pushes just now for a few final cleanups. Done now.

@inducer
inducer force-pushed the check-dist-deadlock branch from 4fda54a to 1a7e391 Compare November 14, 2022 02:00
@inducer

inducer commented Nov 14, 2022

Copy link
Copy Markdown
Owner

Thanks!

And thanks for making these extra commits, that made the changes easy to review. I've folded them into the verifier and test commits, fixed some typos, and added a base class and eliminated what I believe was a redundant test. (The two spots that raised DuplicateSend made that easy to spot.)

@inducer
inducer enabled auto-merge (rebase) November 14, 2022 02:01
@inducer
inducer merged commit 946b99e into main Nov 14, 2022
@inducer
inducer deleted the check-dist-deadlock branch November 14, 2022 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants