Skip to content

fix(vllm): support IPv6 communicator hosts - #6907

Open
yikun-c wants to merge 7 commits into
huggingface:mainfrom
yikun-c:fix/vllm-client-ipv6-communicator-host
Open

fix(vllm): support IPv6 communicator hosts#6907
yikun-c wants to merge 7 commits into
huggingface:mainfrom
yikun-c:fix/vllm-client-ipv6-communicator-host

Conversation

@yikun-c

@yikun-c yikun-c commented Aug 25, 2026

Copy link
Copy Markdown

What does this PR do?

Fixes #3164.

This fixes IPv6 weight-sync initialization in VLLMClient:

  • HTTP URLs keep their required bracketed form, e.g. http://[2001:db8::1]:8000.
  • The NCCL/TCPStore communicator receives the corresponding bare IPv6 literal, 2001:db8::1.
  • IPv4 and hostname behavior is unchanged.

The previous socket.gethostbyname() conversion is IPv4-only and cannot represent an IPv6 literal. The change keeps the HTTP and communicator address contracts separate and normalizes forwarded host headers as well.

Before submitting

  • This PR fixes a typo or improves the docs.
  • I read the contributor guideline, Pull Request section.
  • This was discussed via grpo init_communicator ipv6 can not reach #3164; a maintainer explicitly suggested bracket stripping at the communicator boundary.
  • Documentation changes are needed.
  • I added regression tests for bracketed/bare IPv6, IPv4, and hostnames.

AI writing disclosure

  • No AI usage.
  • AI-assisted.
  • AI-generated: an AI coding agent generated the draft. The contributor reviewed the scope and approved this ready-for-review submission.

Validation

  • Extracted and executed the submitted address helpers from the branch source.
  • Verified bracketed/bare IPv6 normalization plus IPv4 and hostname preservation.

Who can review?

@qgallouedec, since you requested this focused communicator-boundary fix in #3164.


Note

Medium Risk
Touches distributed weight-sync addressing (TCPStore/NCCL); behavior change is scoped but failures would break training sync on IPv6 or proxied setups.

Overview
Fixes IPv6 weight-sync setup in VLLMClient by separating how hosts are formatted for HTTP vs for NCCL/TCPStore.

VLLMClient no longer always runs the server host through socket.gethostbyname() (IPv4-only). New helpers normalize addresses: _resolve_communicator_host keeps bare IPv6 literals (and bracket-stripped forms) for the communicator, still resolving hostnames via gethostbyname; _format_http_host adds brackets when building http://… URLs. The same resolution applies when X-Forwarded-For updates self.host.

Regression tests in TestVLLMClientAddressing cover bracketed/bare IPv6, IPv4, and hostname resolution.

Reviewed by Cursor Bugbot for commit ca910ca. Bugbot is set up for automated code reviews on this repo. Configure here.

@yikun-c
yikun-c marked this pull request as ready for review August 25, 2026 08:40
@yikun-c

yikun-c commented Aug 25, 2026

Copy link
Copy Markdown
Author

Ready for review after contributor approval. The PR follows the focused communicator-boundary scope discussed in #3164; template and AI disclosure are complete. Thank you for taking a look.

Comment thread trl/generation/vllm_client.py Outdated
@yikun-c

yikun-c commented Aug 25, 2026

Copy link
Copy Markdown
Author

Addressed the Bugbot finding in the latest commit: communicator hosts now strip URL-only IPv6 brackets, preserve IP literals, and retain the previous socket.gethostbyname behavior for hostnames such as localhost. Added a mocked hostname-resolution regression alongside the IPv6 cases. Local branch-source helper validation passes for IPv4, hostname, and bracketed/bare IPv6.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ca910ca. Configure here.

self.base_url = f"{scheme}://{parsed_url.netloc}{parsed_url.path}"
else:
self.host = host
self.host = _resolve_communicator_host(host)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Host path rewrites HTTP to IPv4

Medium Severity

_resolve_communicator_host now runs socket.gethostbyname on the host argument, then _format_http_host builds base_url from that already-resolved value. A hostname such as localhost becomes an IPv4 HTTP URL and communicator address, so IPv6-only or IPv6-preferred hosts fail even though the base_url path still keeps the original URL separate from the communicator host.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ca910ca. Configure here.

if response.status_code == 200:
if "X-Forwarded-For" in response.headers:
self.host = response.headers["X-Forwarded-For"]
self.host = _resolve_communicator_host(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Forwarded host resolution can crash

Medium Severity

A successful health check now passes X-Forwarded-For through _resolve_communicator_host. Multi-hop or non-literal values are not valid IPs, so socket.gethostbyname raises socket.gaierror. That exception is outside the RequestException handler, so a 200 health response can crash client setup.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ca910ca. Configure here.

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.

grpo init_communicator ipv6 can not reach

1 participant