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

Full EFA attachment for non-public IPs #2271

Merged
merged 3 commits into from
Feb 10, 2025

Conversation

solovyevt
Copy link
Contributor

Closes #2270

Comment on lines 208 to 239
if instance_type == "p5.48xlarge":
# EFA configuration for P5 instances: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/efa-acc-inst-types.html#efa-for-p5
p5d_interfaces = [
{
"NetworkCardIndex": i,
"DeviceIndex": 1,
"InterfaceType": "efa" if i % 4 == 0 else "efa-only",
}
for i in range(1, 32)
]
for interface in p5d_interfaces:
struct["NetworkInterfaces"].append(
{
"AssociatePublicIpAddress": allocate_public_ip,
"NetworkCardIndex": interface["NetworkCardIndex"],
"DeviceIndex": interface["DeviceIndex"],
"SubnetId": subnet_id,
"Groups": [security_group_id],
"InterfaceType": interface["InterfaceType"],
}
)
else:
for i in range(1, max_efa_interfaces):
struct["NetworkInterfaces"].append(
{
"AssociatePublicIpAddress": allocate_public_ip,
"NetworkCardIndex": i,
"DeviceIndex": 1,
"SubnetId": subnet_id,
"Groups": [security_group_id],
"InterfaceType": "efa-only", # Set specifically to efa-only to keep the interfaces exclusively for GPU-to-GPU communications and not mix with IP traffic
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems "InterfaceType" is the only difference between "p5.48xlarge" and other instance types? Then the code can be simplified significantly:

            for i in range(1, max_efa_interfaces):
                # Set efa-only to keep the interfaces exclusively for GPU-to-GPU communications and not mix with IP traffic
                interface_type = "efa-only"
                if instance_type == "p5.48xlarge":
                    # EFA configuration for P5 instances:
                    # https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/efa-acc-inst-types.html#efa-for-p5
                    interface_type = "efa" if i % 4 == 0 else "efa-only"
                struct["NetworkInterfaces"].append(
                    {
                        "AssociatePublicIpAddress": allocate_public_ip,
                        "NetworkCardIndex": i,
                        "DeviceIndex": 1,
                        "SubnetId": subnet_id,
                        "Groups": [security_group_id],
                        "InterfaceType": interface_type,
                    }
                )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, pushed the choppy version without refactoring. Fixed.

@r4victor
Copy link
Collaborator

@solovyevt, thanks for the PR, looks good. I'm merging it.

I also pushed a commit to update the docs.

@r4victor r4victor merged commit 58df5fc into dstackai:master Feb 10, 2025
24 checks passed
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.

[Feature]: AWS: Full EFA support for non-public IPs
3 participants