Skip to content

Conversation

@timsolovev
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
pranitnaik43 pushed a commit to bahaal-tech/dstack that referenced this pull request Mar 4, 2025
* feature(aws): Extend EFA attachment

* refactor(aws): Simplify NetworkInterfaces logic

* Update docs on EFA

---------

Co-authored-by: Solovev, Timur <tsolovev@ea.com>
Co-authored-by: Victor Skvortsov <vds003@gmail.com>
pranitnaik43 pushed a commit to bahaal-tech/dstack that referenced this pull request Mar 5, 2025
* feature(aws): Extend EFA attachment

* refactor(aws): Simplify NetworkInterfaces logic

* Update docs on EFA

---------

Co-authored-by: Solovev, Timur <tsolovev@ea.com>
Co-authored-by: Victor Skvortsov <vds003@gmail.com>
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