From 2ec4c2294fc3d922a558fc1c5c360d7fde7eb0d3 Mon Sep 17 00:00:00 2001 From: Jvst Me Date: Thu, 1 Oct 2026 03:13:23 +0200 Subject: [PATCH] Add OCI `experimental_instance_types` setting Add an OCI backend setting that accepts a list of shape names to allow provisioning in addition to the standard supported instance families. Only works for shapes included in `dstack`'s pricing catalog (`gpuhunt`). This setting can be used to test various shapes that were not yet tested internally at `dstack`. ```yaml experimental_instance_types: [BM.GPU.RTXPRO.8] ``` --- .../_internal/core/backends/oci/compute.py | 16 ++++++++++++---- src/dstack/_internal/core/backends/oci/models.py | 10 ++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/dstack/_internal/core/backends/oci/compute.py b/src/dstack/_internal/core/backends/oci/compute.py index ab9be4908b..b4705bb0a9 100644 --- a/src/dstack/_internal/core/backends/oci/compute.py +++ b/src/dstack/_internal/core/backends/oci/compute.py @@ -1,6 +1,6 @@ -from collections.abc import Iterable +from collections.abc import Container, Iterable from concurrent.futures import ThreadPoolExecutor -from functools import cached_property +from functools import cached_property, partial from typing import List, Optional import oci @@ -64,6 +64,10 @@ def __init__(self, config: OCIConfig): super().__init__() self.config = config self.regions = make_region_clients_map(config.regions or [], config.creds) + self._supported_instances = partial( + _supported_instances, + experimental_instance_types=set(self.config.experimental_instance_types or []), + ) @cached_property def shapes_quota(self) -> resources.ShapesQuota: @@ -75,7 +79,7 @@ def get_all_offers_with_availability( offers = get_catalog_offers( backend=BackendType.OCI, locations=self.config.regions, - extra_filter=_supported_instances, + extra_filter=self._supported_instances, ) with ThreadPoolExecutor(max_workers=8) as executor: @@ -206,7 +210,11 @@ def update_provisioning_data( provisioning_data.internal_ip = vnic.private_ip -def _supported_instances(offer: InstanceOffer) -> bool: +def _supported_instances( + offer: InstanceOffer, experimental_instance_types: Container[str] +) -> bool: + if offer.instance.name in experimental_instance_types: + return True if "Flex" in offer.instance.name: return False return any(map(offer.instance.name.startswith, SUPPORTED_SHAPE_FAMILIES)) diff --git a/src/dstack/_internal/core/backends/oci/models.py b/src/dstack/_internal/core/backends/oci/models.py index 20f22b793d..f7d17c862b 100644 --- a/src/dstack/_internal/core/backends/oci/models.py +++ b/src/dstack/_internal/core/backends/oci/models.py @@ -70,6 +70,16 @@ class OCIBackendConfig(CoreModel): ) ), ] = None + experimental_instance_types: Annotated[ + Optional[List[str]], + Field( + description=( + "The list of shape names to allow provisioning in addition to" + " the standard supported shape families. Only works for shapes" + " included in `dstack`'s pricing catalog (`gpuhunt`)" + ) + ), + ] = None class OCIBackendConfigWithCreds(OCIBackendConfig):