From a79abca133f2b6ec2a3659596f96c1430229a77d Mon Sep 17 00:00:00 2001 From: Romil Bhardwaj Date: Wed, 16 Oct 2024 13:58:02 -0700 Subject: [PATCH 1/3] add gvnic support through config.yaml --- sky/clouds/gcp.py | 4 ++++ sky/provision/gcp/config.py | 6 +++++- sky/templates/gcp-ray.yml.j2 | 3 +++ sky/utils/schemas.py | 3 +++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sky/clouds/gcp.py b/sky/clouds/gcp.py index bde6abcb48f..10c310d7cce 100644 --- a/sky/clouds/gcp.py +++ b/sky/clouds/gcp.py @@ -546,6 +546,10 @@ def _failover_disk_tier() -> Optional[resources_utils.DiskTier]: resources_vars[ 'force_enable_external_ips'] = skypilot_config.get_nested( ('gcp', 'force_enable_external_ips'), False) + + # Add gVNIC from config + resources_vars['enable_gvnic'] = skypilot_config.get_nested(('gcp', 'enable_gvnic'), False) + return resources_vars def _get_feasible_launchable_resources( diff --git a/sky/provision/gcp/config.py b/sky/provision/gcp/config.py index 416f0c1a694..a8292669a7c 100644 --- a/sky/provision/gcp/config.py +++ b/sky/provision/gcp/config.py @@ -670,8 +670,12 @@ def _configure_subnet(region: str, cluster_name: str, 'accessConfigs': [{ 'name': 'External NAT', 'type': 'ONE_TO_ONE_NAT', - }], + }] }] + # Add gVNIC if specified in config + enable_gvnic = config.provider_config.get('enable_gvnic', False) + if enable_gvnic: + default_interfaces[0]['nicType'] = 'gVNIC' enable_external_ips = _enable_external_ips(config) if not enable_external_ips: # Removing this key means the VM will not be assigned an external IP. diff --git a/sky/templates/gcp-ray.yml.j2 b/sky/templates/gcp-ray.yml.j2 index 5f06eef05c7..f3e6232d5d8 100644 --- a/sky/templates/gcp-ray.yml.j2 +++ b/sky/templates/gcp-ray.yml.j2 @@ -64,6 +64,9 @@ provider: # leakage. disable_launch_config_check: true use_managed_instance_group: {{ gcp_use_managed_instance_group }} +{%- if enable_gvnic %} + enable_gvnic: {{ enable_gvnic }} +{%- endif %} auth: ssh_user: gcpuser diff --git a/sky/utils/schemas.py b/sky/utils/schemas.py index 6e752f73ebc..94a6ed690e1 100644 --- a/sky/utils/schemas.py +++ b/sky/utils/schemas.py @@ -755,6 +755,9 @@ def get_config_schema(): 'force_enable_external_ips': { 'type': 'boolean' }, + 'enable_gvnic': { + 'type': 'boolean' + }, **_LABELS_SCHEMA, **_NETWORK_CONFIG_SCHEMA, }, From 66856565af403b9a9107f1da0cef7d031600c951 Mon Sep 17 00:00:00 2001 From: Romil Bhardwaj Date: Wed, 16 Oct 2024 14:05:04 -0700 Subject: [PATCH 2/3] lint --- sky/clouds/gcp.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sky/clouds/gcp.py b/sky/clouds/gcp.py index 10c310d7cce..322a6264a9e 100644 --- a/sky/clouds/gcp.py +++ b/sky/clouds/gcp.py @@ -548,7 +548,8 @@ def _failover_disk_tier() -> Optional[resources_utils.DiskTier]: ('gcp', 'force_enable_external_ips'), False) # Add gVNIC from config - resources_vars['enable_gvnic'] = skypilot_config.get_nested(('gcp', 'enable_gvnic'), False) + resources_vars['enable_gvnic'] = skypilot_config.get_nested( + ('gcp', 'enable_gvnic'), False) return resources_vars From c35f02381d0c75bc0ccc4891535a334ac7d98a25 Mon Sep 17 00:00:00 2001 From: Romil Bhardwaj Date: Wed, 16 Oct 2024 14:08:20 -0700 Subject: [PATCH 3/3] docs --- docs/source/reference/config.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/source/reference/config.rst b/docs/source/reference/config.rst index 5c52e7487b9..b8255b46402 100644 --- a/docs/source/reference/config.rst +++ b/docs/source/reference/config.rst @@ -419,6 +419,15 @@ Available fields and semantics: # Default: 'LOCAL_CREDENTIALS'. remote_identity: LOCAL_CREDENTIALS + # Enable gVNIC (optional). + # + # Set to true to use gVNIC on GCP instances. gVNIC offers higher performance + # for multi-node clusters, but costs more. + # Reference: https://cloud.google.com/compute/docs/networking/using-gvnic + # + # Default: false. + enable_gvnic: false + # Advanced Azure configurations (optional). # Apply to all new instances but not existing ones. azure: