-
Notifications
You must be signed in to change notification settings - Fork 3.4k
[BugFix] port finding and avoid hardcoded ipv4 host #10693
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2788,9 +2788,14 @@ def init_new(server_args, dp_rank: Optional[int] = None) -> "PortArgs": | |
| if nccl_port < 60000: | ||
| nccl_port += 42 | ||
| else: | ||
| nccl_port -= 43 | ||
| nccl_port = server_args.port + random.randint(100, 1000) | ||
|
Comment on lines
2788
to
+2791
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic for finding an available port when one is not provided is a bit complex. Using nccl_port += 1 |
||
| else: | ||
| nccl_port = server_args.nccl_port | ||
| # Check if the port is available | ||
| while True: | ||
| if is_port_available(nccl_port): | ||
| break | ||
| nccl_port += 1 | ||
|
|
||
| if not server_args.enable_dp_attention: | ||
| # Normal case, use IPC within a single node | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change correctly replaces the hardcoded
127.0.0.1withself.server_args.host. However, ifself.server_args.hostis an IPv6 address, it needs to be enclosed in square brackets (e.g.,[::1]) to form a valid TCP URL fortorch.distributed. Without the brackets, initialization will fail for IPv6 hosts. It's recommended to handle this case.