---
title: "Compute config SDK reference"
description: "Customer-hosted cloud features"
---

# Compute config SDK reference

#### Customer-hosted cloud features

:::note
Some features are only available on customer-hosted clouds. Reach out to [support@anyscale.com](mailto:support@anyscale.com) for info.
:::

## Compute config SDK

### `anyscale.compute_config.create`

Create a new version of a compute config.

Returns the full name of the registered compute config, including the version.

**Arguments**

-   **`config` ([ComputeConfig](#computeconfig) | [MultiResourceComputeConfig](#multiresourcecomputeconfig))**: The config options defining the compute config.
-   **`name` (str | None)**: The name of the compute config. This should _not_ include a version tag. If a name is not provided, one will be automatically generated.

**Returns**: str

#### Examples

::::tabs

:::tab[Python]
```python
import anyscale
from anyscale.compute_config.models import ComputeConfig, HeadNodeConfig, MarketType, WorkerNodeGroupConfig

single_deployment_compute_config = ComputeConfig(
    head_node=HeadNodeConfig(
        instance_type="m5.8xlarge",
    ),
    worker_nodes=[
        WorkerNodeGroupConfig(
            instance_type="m5.8xlarge",
            min_nodes=5,
            max_nodes=5,
        ),
        WorkerNodeGroupConfig(
            instance_type="m5.4xlarge",
            min_nodes=1,
            max_nodes=10,
            market_type=MarketType.SPOT,
        ),
    ],
)
full_name: str = anyscale.compute_config.create(single_deployment_compute_config, name="my-single-deployment-compute-config")

multi_deployment_compute_config = MultiResourceComputeConfig(
    configs=[
        ComputeConfig(
            cloud_resource="vm-aws-us-west-1",
            head_node=HeadNodeConfig(
                instance_type="m5.2xlarge",
            ),
            worker_nodes=[
                WorkerNodeGroupConfig(
                    instance_type="m5.4xlarge",
                    min_nodes=1,
                    max_nodes=10,
                ),
            ],
        ),
        ComputeConfig(
            cloud_resource="vm-aws-us-west-2",
            head_node=HeadNodeConfig(
                instance_type="m5.2xlarge",
            ),
            worker_nodes=[
                WorkerNodeGroupConfig(
                    instance_type="m5.4xlarge",
                    min_nodes=1,
                    max_nodes=10,
                ),
            ],
        )
    ]
)
full_name: str = anyscale.compute_config.create(multi_deployment_compute_config, name="my-multi-deployment-compute-config")
```
:::

::::

### `anyscale.compute_config.get`

Get the compute config with the specified name.

The name can contain an optional version tag, i.e., 'name:version'. If no version is provided, the latest one will be returned.

Args: name: Name of the compute config (can include version tag) include\_archived: Whether to include archived configs cloud: Cloud name to filter by when resolving config name \_id: Internal parameter for fetching by ID \_private\_sdk: Internal SDK instance

**Arguments**

-   **`name` (str | None)**: The name of the compute config. This can include an optional version tag, i.e., 'name:version'. If no version tag is provided, the latest version will be returned.
-   **`include_archived` (bool) = False**: Whether to consider archived compute configs (defaults to False).
-   **`cloud` (str | None) = None**: Cloud name to filter by when resolving the compute config by name. Useful when multiple compute configs with the same name exist across different clouds.

**Returns**: [ComputeConfigVersion](#computeconfigversion)

#### Examples

::::tabs

:::tab[Python]
```python
import anyscale
from anyscale.compute_config.models import ComputeConfigVersion

compute_config: ComputeConfigVersion = anyscale.compute_config.get("my-compute-config")
```
:::

::::

### `anyscale.compute_config.get_default`

Get the default compute config for the specified cloud.

Returns the default compute configuration that will be used when no compute config is explicitly specified for a workload.

Args: cloud: Name of the cloud. If not provided, uses the organization's default cloud. cloud\_resource: Name of the cloud resource. If not provided, uses the default cloud resource for the cloud. \_private\_sdk: Internal SDK instance.

Returns: ComputeConfigVersion containing the default compute config.

**Arguments**

-   **`cloud` (str | None) = None**: Name of the cloud. If not provided, uses the organization's default cloud.
-   **`cloud_resource` (str | None) = None**: Name of the cloud resource. If not provided, uses the default cloud resource for the cloud.

**Returns**: [ComputeConfigVersion](#computeconfigversion)

#### Examples

::::tabs

:::tab[Python]
```python
import anyscale
from anyscale.compute_config.models import ComputeConfigVersion

# Get the default compute config for the default cloud
default_config: ComputeConfigVersion = anyscale.compute_config.get_default()

# Get the default compute config for a specific cloud
default_config: ComputeConfigVersion = anyscale.compute_config.get_default(cloud="my-cloud")

# Get the default compute config for a specific cloud resource
default_config: ComputeConfigVersion = anyscale.compute_config.get_default(
    cloud="my-cloud",
    cloud_resource="my-cloud-resource"
)
```
:::

::::

### `anyscale.compute_config.archive`

Archive a compute config and all of its versions.

The name can contain an optional version, e.g., 'name:version'. If no version is provided, the latest one will be archived.

Once a compute config is archived, its name will no longer be usable in the organization.

**Arguments**

-   **`name` (str | None)**: Name of the compute config.

#### Examples

::::tabs

:::tab[Python]
```python
import anyscale

anyscale.compute_config.archive(name="my-compute-config")
```
:::

::::

### `anyscale.compute_config.list`

List compute configurations with filtering, sorting, and pagination.

Returns a ComputeConfigListResult object containing:

-   results: List of compute config objects
-   next\_token: Token for fetching the next page (None if no more results)
-   count: Number of results in this page

Args: name: Filter by compute config name cloud\_id: Filter by cloud ID cloud\_name: Filter by cloud name sort\_by: Field to sort by ('name', 'created\_at', 'last\_modified\_at') sort\_order: Sort order ('asc' or 'desc') max\_items: Maximum number of items to return per page next\_token: Pagination token for next page include\_shared: Include configs shared with the user \_id: Internal parameter for fetching by ID \_private\_sdk: Internal SDK instance

Returns: ComputeConfigListResult with 'results' (list), 'next\_token' (str|None), and 'count' (int)

Raises: ValueError: If both cloud\_id and cloud\_name are provided

**Arguments**

-   **`name` (str | None) = None**: Filter by compute config name.
-   **`cloud_id` (str | None) = None**: Filter by cloud ID.
-   **`cloud_name` (str | None) = None**: Filter by cloud name.
-   **`sort_by` (str) = last\_modified\_at**: Field to sort by. Options: 'name', 'created\_at', 'last\_modified\_at'. Default: 'last\_modified\_at'
-   **`sort_order` (str) = asc**: Sort order. Options: 'asc' (ascending) or 'desc' (descending). Default: 'asc'
-   **`max_items` (int) = 20**: Maximum number of items to return per page. Default: 20
-   **`next_token` (str | None) = None**: Pagination token for fetching the next page of results.
-   **`include_shared` (bool) = False**: Include compute configs shared with the user (not just those created by the user). Default: False

**Returns**: [ComputeConfigListResult](#computeconfiglistresult)

#### Examples

::::tabs

:::tab[Python]
```python
import anyscale

# List all compute configs created by the current user
configs = anyscale.compute_config.list()

# List with filtering and sorting
configs = anyscale.compute_config.list(
    cloud_name="aws-prod",
    sort_by="created_at",
    sort_order="desc",
    max_items=10
)

# Access results and pagination token
for config in configs.results:
    print(f"{config.name} (version {config.version})")

# Fetch next page if available
if configs.next_token:
    next_page = anyscale.compute_config.list(
        cloud_name="aws-prod",
        sort_by="created_at",
        sort_order="desc",
        max_items=10,
        next_token=configs.next_token
    )
```
:::

::::

## Compute config models

### `ComputeConfig`

Compute configuration for instance types and cloud resources for a cluster with a single cloud resource.

#### Fields

-   **`cloud` (str | None)**: The Anyscale Cloud to run this workload on. If not provided, the organization default will be used (or, if running in a workspace, the cloud of the workspace).
-   **`cloud_resource` (str | None)**: The cloud resource to use for this workload. Defaults to the primary cloud resource of the Cloud.
    -   Only available on [customer-hosted clouds](#customer-hosted-only).
-   **`head_node` ([HeadNodeConfig](#headnodeconfig) | Dict | None)**: Configuration options for the head node of the cluster. Defaults to the cloud's default head node configuration.
-   **`worker_nodes` (List\[[WorkerNodeGroupConfig](#workernodegroupconfig) | Dict\] | None)**: Configuration options for the worker nodes of the cluster. If not provided, worker nodes will be automatically selected based on logical resource requests. To use a head-node only cluster, pass `[]` here.
-   **`min_resources` (Dict\[str, float\] | None)**: Total minimum logical resources across all nodes in the cluster. Resources omitted from this field have no minimum.
-   **`max_resources` (Dict\[str, float\] | None)**: Total maximum logical resources across all nodes in the cluster. Resources omitted from this field have no maximum.
-   **`zones` (List\[str\] | None)**: Availability zones to consider for this cluster. Defaults to all zones in the cloud's region. By default all instances with user workloads scheduled on them will run in the same zone to save cost, unless `enable_cross_zone_scaling` is set.
    -   Only available on [customer-hosted clouds](#customer-hosted-only).
-   **`enable_cross_zone_scaling` (bool)**: Allow instances in the cluster to be run across multiple zones. This is recommended when running production services (for fault-tolerance in a zone failure scenario). It is not recommended for workloads that have a large amount of inter-zone communication due to the possibility of higher costs and degraded performance. When false, all instances with user workloads scheduled on them (e.g. all worker nodes in multi-node clusters) will run in the same zone to save cost.
    -   Only available on [customer-hosted clouds](#customer-hosted-only).
-   **`advanced_instance_config` (Dict\[str, Any\] | None)**: Advanced instance configurations that will be passed through to the cloud provider.
    -   Only available on [customer-hosted clouds](#customer-hosted-only).
-   **`flags` (Dict\[str, Any\] | None)**: Cluster-level flags specifying advanced or experimental options.
-   **`auto_select_worker_config` (bool)**: Allow worker groups to be automatically configured based on the workload's logical resource requests. When false, worker groups must be explicitly configured.

#### Python Methods

```python
def __init__(self, **fields) -> ComputeConfig
    """Construct a model with the provided field values set."""

def options(self, **fields) -> ComputeConfig
    """Return a copy of the model with the provided field values overwritten."""

def to_dict(self) -> Dict[str, Any]
    """Return a dictionary representation of the model."""
```

#### Examples

::::tabs

:::tab[YAML]
```yaml
cloud: my-cloud
zones: # (Optional) Defaults to to all zones in a region.
  - us-west-2a
  - us-west-2b
head_node:
  instance_type: m5.8xlarge
worker_nodes:
- instance_type: m5.8xlarge
  min_nodes: 5
  max_nodes: 5
  market_type: PREFER_SPOT # (Optional) Defaults to ON_DEMAND
- instance_type: g5.4xlarge
  min_nodes: 1
  max_nodes: 10
  market_type: SPOT # (Optional) Defaults to ON_DEMAND
min_resources: # (Optional) Defaults to no minimum.
  CPU: 1
  GPU: 1
  CUSTOM_RESOURCE: 0
max_resources: # (Optional) Defaults to no maximum.
  CPU: 6
  GPU: 10
  CUSTOM_RESOURCE: 10
enable_cross_zone_scaling: true # (Optional) Defaults to false.
advanced_instance_config: # (Optional) Defaults to no advanced configurations.
  # AWS specific configuration example
  BlockDeviceMappings:
    - DeviceName: DEVICE_NAME
      Ebs:
        VolumeSize: VOLUME_SIZE
        DeleteOnTermination: DELETE_ON_TERMINATION
  IamInstanceProfile:
    Arn: IAM_INSTANCE_PROFILE_ARN
  NetworkInterfaces:
    - SubnetId: SUBNET_ID
      Groups:
        - SECURITY_GROUP_ID
      AssociatePublicIpAddress: ASSOCIATE_PUBLIC_IP
  TagSpecifications:
    - ResourceType: RESOURCE_TYPE
      Tags:
        - Key: TAG_KEY
          Value: TAG_VALUE
  # GCP specific configuration example
  instance_properties:
    disks:
      - boot: BOOT_OPTION
        auto_delete: AUTO_DELETE_OPTION
        initialize_params:
          disk_size_gb: DISK_SIZE_GB
    service_accounts:
      - email: SERVICE_ACCOUNT_EMAIL
        scopes:
          - SCOPE_URL
    network_interfaces:
      - subnetwork: SUBNETWORK_URL
        access_configs:
          - type: ACCESS_CONFIG_TYPE
    labels:
      LABEL_KEY: LABEL_VALUE
```
:::

:::tab[Python]
```python
from anyscale.compute_config.models import (
    ComputeConfig, HeadNodeConfig, MarketType, WorkerNodeGroupConfig
)

config = ComputeConfig(
    cloud="my-cloud",
    head_node=HeadNodeConfig(
        instance_type="m5.8xlarge",
    ),
    worker_nodes=[
        WorkerNodeGroupConfig(
            instance_type="m5.8xlarge",
            min_nodes=5,
            max_nodes=5,
        ),
        WorkerNodeGroupConfig(
            instance_type="m5.4xlarge",
            min_nodes=1,
            max_nodes=10,
            market_type=MarketType.SPOT,
        ),
    ],
)
```
:::

::::

### `ComputeConfigListResult`

Result object returned by anyscale.compute\_config.list().

Contains a list of compute configs matching the query, along with pagination metadata.

#### Fields

-   **`results` (List\[Any\])**: List of compute config objects matching the query. Each item is a ClusterCompute object with details about the compute configuration.
-   **`next_token` (str | None)**: Pagination token for fetching the next page of results. If None, there are no more results available.
-   **`count` (int)**: Number of results returned in this response. Useful for checking if there are results without iterating through the list.

#### Python Methods

```python
def to_dict(self) -> Dict[str, Any]
    """Return a dictionary representation of the model."""
```

#### Examples

::::tabs

:::tab[Python]
```python
import anyscale
from anyscale.compute_config.models import ComputeConfigListResult

# List compute configs with pagination
result: ComputeConfigListResult = anyscale.compute_config.list(
    cloud_name="aws-prod",
    sort_by="created_at",
    max_items=10
)

# Access results
print(f"Found {result.count} compute configs")
for config in result.results:
    print(f"  - {config.name}:{config.version}")

# Handle pagination
if result.next_token:
    next_page = anyscale.compute_config.list(
        cloud_name="aws-prod",
        max_items=10,
        next_token=result.next_token
    )
```
:::

::::

### `MultiResourceComputeConfig`

EXPERIMENTAL. Compute configuration for a cluster with multiple possible cloud resources.

#### Fields

-   **`cloud` (str | None)**: The Anyscale Cloud to run this workload on. If not provided, the organization default will be used (or, if running in a workspace, the cloud of the workspace).
-   **`configs` (List\[[ComputeConfig](#computeconfig) | Dict\])**: List of compute configurations, one for each cloud resource.
    -   Only available on [customer-hosted clouds](#customer-hosted-only).
-   **`flags` (Dict\[str, Any\] | None)**: Flags specifying advanced or experimental options that should be applied to all cloud resources. Flags specified in the individual compute configurations will override these flags.

#### Python Methods

```python
def __init__(self, **fields) -> MultiResourceComputeConfig
    """Construct a model with the provided field values set."""

def options(self, **fields) -> MultiResourceComputeConfig
    """Return a copy of the model with the provided field values overwritten."""

def to_dict(self) -> Dict[str, Any]
    """Return a dictionary representation of the model."""
```

#### Examples

::::tabs

:::tab[YAML]
```yaml
cloud: my-cloud
configs:
- cloud_resource: vm-aws-us-west-1
  head_node:
    instance_type: m5.2xlarge
  worker_nodes:
  - instance_type: m5.4xlarge
    min_nodes: 1
    max_nodes: 10
- cloud_resource: vm-aws-us-west-2
  head_node:
    instance_type: m5.2xlarge
  worker_nodes:
  - instance_type: m5.4xlarge
    min_nodes: 1
    max_nodes: 10
```
:::

:::tab[Python]
```python
from anyscale.compute_config.models import (
    MultiResourceComputeConfig, ComputeConfig, HeadNodeConfig, WorkerNodeGroupConfig
)
config = MultiResourceComputeConfig(
    cloud="my-cloud",
    configs=[
        ComputeConfig(
            cloud_resource="vm-aws-us-west-1",
            head_node=HeadNodeConfig(
                instance_type="m5.2xlarge",
            ),
            worker_nodes=[
                WorkerNodeGroupConfig(
                    instance_type="m5.4xlarge",
                    min_nodes=1,
                    max_nodes=10,
                ),
            ],
        ),
        ComputeConfig(
            cloud_resource="vm-aws-us-west-2",
            head_node=HeadNodeConfig(
                instance_type="m5.2xlarge",
            ),
            worker_nodes=[
                WorkerNodeGroupConfig(
                    instance_type="m5.4xlarge",
                    min_nodes=1,
                    max_nodes=10,
                ),
            ],
        )
    ]
)
```
:::

::::

### `HeadNodeConfig`

Configuration options for the head node of a cluster.

#### Fields

-   **`instance_type` (str | None)**: Cloud provider instance type, e.g., `m5.2xlarge` on AWS or `n2-standard-8` on GCP. Defaults to 'custom' when required\_resources is provided.
-   **`resources` (Dict\[str, float\] | None)**: Logical resources that will be available on this node. Defaults to match the physical resources of the instance type.
-   **`required_resources` ([PhysicalResources](#physicalresources) | None)**: Physical resources for custom instance types (free pod shapes). Explicitly defines CPU, memory, and GPU resources.
-   **`labels` (Dict\[str, str\] | None)**: Labels to associate the node with for scheduling purposes. Defaults to the list of Ray & Anyscale default labels.
-   **`required_labels` (Dict\[str, str\] | None)**: Required labels that must be present on the node for scheduling purposes.
-   **`advanced_instance_config` (Dict\[str, Any\] | None)**: Advanced instance configurations that will be passed through to the cloud provider.
    -   Only available on [customer-hosted clouds](#customer-hosted-only).
-   **`flags` (Dict\[str, Any\] | None)**: Node-level flags specifying advanced or experimental options.
-   **`cloud_deployment` ([CloudDeployment](#clouddeployment) | Dict\[str, str\] | None)**: Cloud deployment selectors for a node group; one or more selectors may be passed to target a specific deployment from all of a cloud's deployments.

#### Python Methods

```python
def __init__(self, **fields) -> HeadNodeConfig
    """Construct a model with the provided field values set."""

def options(self, **fields) -> HeadNodeConfig
    """Return a copy of the model with the provided field values overwritten."""

def to_dict(self) -> Dict[str, Any]
    """Return a dictionary representation of the model."""
```

#### Examples

::::tabs

:::tab[YAML]
```yaml
head_node:
  instance_type: m5.8xlarge
```
:::

:::tab[Python]
```python
from anyscale.compute_config.models import ComputeConfig, HeadNodeConfig

config = ComputeConfig(
    head_node=HeadNodeConfig(
        instance_type="m5.8xlarge",
    ),
)
```
:::

::::

### `WorkerNodeGroupConfig`

Configuration options for a worker node group in a cluster.

Clusters can have multiple worker node groups that use different instance types or configurations.

#### Fields

-   **`instance_type` (str | None)**: Cloud provider instance type, e.g., `m5.2xlarge` on AWS or `n2-standard-8` on GCP. Defaults to 'custom' when required\_resources is provided.
-   **`resources` (Dict\[str, float\] | None)**: Logical resources that will be available on this node. Defaults to match the physical resources of the instance type.
-   **`required_resources` ([PhysicalResources](#physicalresources) | None)**: Physical resources for custom instance types (free pod shapes). Explicitly defines CPU, memory, and GPU resources.
-   **`labels` (Dict\[str, str\] | None)**: Labels to associate the node with for scheduling purposes. Defaults to the list of Ray & Anyscale default labels.
-   **`required_labels` (Dict\[str, str\] | None)**: Required labels that must be present on the node for scheduling purposes.
-   **`advanced_instance_config` (Dict\[str, Any\] | None)**: Advanced instance configurations that will be passed through to the cloud provider.
    -   Only available on [customer-hosted clouds](#customer-hosted-only).
-   **`flags` (Dict\[str, Any\] | None)**: Node-level flags specifying advanced or experimental options.
-   **`cloud_deployment` ([CloudDeployment](#clouddeployment) | Dict\[str, str\] | None)**: Cloud deployment selectors for a node group; one or more selectors may be passed to target a specific deployment from all of a cloud's deployments.
-   **`name` (str | None)**: Unique name of this worker group. Defaults to a human-friendly representation of the instance type.
-   **`min_nodes` (int)**: Minimum number of nodes of this type that will be kept running in the cluster.
-   **`max_nodes` (int)**: Maximum number of nodes of this type that can be running in the cluster.
-   **`market_type` (str | [MarketType](#markettype))**: The type of instances to use (see `MarketType` enum values for details).
    -   Only available on [customer-hosted clouds](#customer-hosted-only).

#### Python Methods

```python
def __init__(self, **fields) -> WorkerNodeGroupConfig
    """Construct a model with the provided field values set."""

def options(self, **fields) -> WorkerNodeGroupConfig
    """Return a copy of the model with the provided field values overwritten."""

def to_dict(self) -> Dict[str, Any]
    """Return a dictionary representation of the model."""
```

#### Examples

::::tabs

:::tab[YAML]
```yaml
worker_nodes:
- instance_type: m5.8xlarge
  min_nodes: 5
  max_nodes: 5
- instance_type: m5.4xlarge
  min_nodes: 1
  max_nodes: 10
  market_type: SPOT
```
:::

:::tab[Python]
```python
from anyscale.compute_config.models import ComputeConfig, MarketType, WorkerNodeGroupConfig

config = ComputeConfig(
    worker_nodes=[
        WorkerNodeGroupConfig(
            instance_type="m5.8xlarge",
            min_nodes=5,
            max_nodes=5,
        ),
        WorkerNodeGroupConfig(
            instance_type="m5.4xlarge",
            min_nodes=1,
            max_nodes=10,
            market_type=MarketType.SPOT,
        ),
    ],
)
```
:::

::::

### `MarketType`

Market type of instances to use (on-demand vs. spot).

#### Values

-   **`ON_DEMAND`**: Use on-demand instances only.
-   **`SPOT`**: Use spot instances only.
-   **`PREFER_SPOT`**: Prefer to use spot instances, but fall back to on-demand if necessary. If on-demand instances are running and spot instances become available, the on-demand instances will be evicted and replaced with spot instances.

### `CloudDeployment`

Cloud deployment selectors for a node group; one or more selectors may be passed to target a specific deployment from all of a cloud's deployments.

#### Fields

-   **`provider` (str | None)**: Cloud provider name, e.g., `aws` or `gcp`.
-   **`region` (str | None)**: Cloud provider region, e.g., `us-west-2`.
-   **`machine_pool` (str | None)**: Machine pool name.
-   **`id` (str | None)**: Cloud deployment ID from cloud setup.

#### Python Methods

```python
def to_dict(self) -> Dict[str, Any]
    """Return a dictionary representation of the model."""
```

#### Examples

::::tabs

:::tab[YAML]
```yaml
cloud_deployment:
  provider: aws
  region: us-west-2
  machine_pool: machine-pool-name
  id: cldrsrc_1234567890
```
:::

:::tab[Python]
```python
from anyscale.compute_config.models import CloudDeployment

cloud_deployment = CloudDeployment(
    provider="aws",
    region="us-west-2",
    machine_pool="machine-pool-name",
    id="cldrsrc_1234567890",
)
```
:::

::::

### `ComputeConfigVersion`

Details of a created version of a compute config.

Includes the config options and metadata such as the name, version, and ID.

#### Fields

-   **`name` (str)**: Name of the compute config including the version tag, i.e., 'name:version'.
-   **`id` (str)**: Unique ID of the compute config.
-   **`config` ([ComputeConfig](#computeconfig) | [MultiResourceComputeConfig](#multiresourcecomputeconfig) | None)**: The compute configuration.

#### Python Methods

```python
def to_dict(self) -> Dict[str, Any]
    """Return a dictionary representation of the model."""
```

#### Examples

::::tabs

:::tab[Python]
```python
import anyscale
from anyscale.compute_config.models import (
    ComputeConfigVersion
)

version: ComputeConfigVersion = anyscale.compute_config.get("my-compute-config")
```
:::

:::tab[CLI]
```bash
$ anyscale compute-config get -n my-compute-config
name: my-compute-config:1
id: cpt_r4b4b3621rl3uggg7llj3mvme6
config:
  cloud: my-cloud
  head_node:
    instance_type: m5.8xlarge
  worker_nodes:
  - instance_type: m5.8xlarge
    min_nodes: 5
    max_nodes: 5
  - instance_type: m5.4xlarge
    min_nodes: 1
    max_nodes: 10
    market_type: SPOT
```
:::

::::

### `PhysicalResources`

Physical resources specification for compute nodes.

Used for custom instance types (free pod shapes) to explicitly define CPU, memory, and GPU resources instead of deriving from instance type.

#### Fields

-   **`CPU` (int | None)**: Number of CPUs to allocate.
-   **`memory` (str | int | None)**: Amount of memory to allocate. Can be specified as bytes (int) or as a string with units (e.g., '4Gi', '1024Mi').
-   **`GPU` (int | None)**: Number of GPUs to allocate.
-   **`accelerator` (str | None)**: Type of accelerator (e.g., 'T4', 'L4', 'A100', 'H100', 'TPUv4'). Use abbreviated names for readability in generated instance type names.
-   **`TPU` (int | None)**: Number of TPUs to allocate.
-   **`tpu_hosts` (int | None)**: Number of TPU hosts (for anyscale/tpu\_hosts custom resource).
-   **`cpu_architecture` (str | None)**: CPU architecture type. Valid values: 'x86\_64' (default), 'arm64'.

#### Python Methods

```python
def to_dict(self) -> Dict[str, Any]
    """Return a dictionary representation of the model."""
```

#### Examples

::::tabs

:::tab[YAML]
```yaml
required_resources:
  CPU: 4
  memory: 8Gi
  GPU: 1
  accelerator: T4
```
:::

:::tab[Python]
```python
from anyscale.compute_config.models import PhysicalResources

required_resources = PhysicalResources(
    CPU=4,
    memory="8Gi",
    GPU=1,
    accelerator="T4",
)
```
:::

::::

---

Previous: [Cloud](/reference/sdk/cloud.md) | Next: [Image](/reference/sdk/image.md)