-
Notifications
You must be signed in to change notification settings - Fork 165
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
Conversation
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 | ||
} |
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.
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,
}
)
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.
Sorry, pushed the choppy version without refactoring. Fixed.
@solovyevt, thanks for the PR, looks good. I'm merging it. I also pushed a commit to update the docs. |
Closes #2270