> This page is for OpenFold3, version 1.2.0.
> For other versions, use one of these documentation indexes:
> - 1.6.0 (Latest) (default): https://docs.nvidia.com/nim/bionemo/openfold3/1.6.0/llms.txt
> - 1.5.0: https://docs.nvidia.com/nim/bionemo/openfold3/1.5.0/llms.txt
> - 1.4.0: https://docs.nvidia.com/nim/bionemo/openfold3/1.4.0/llms.txt
> - 1.3.0: https://docs.nvidia.com/nim/bionemo/openfold3/1.3.0/llms.txt
> - 1.2.0: https://docs.nvidia.com/nim/bionemo/openfold3/1.2.0/llms.txt
> - 1.1.0: https://docs.nvidia.com/nim/bionemo/openfold3/1.1.0/llms.txt
> - 1.0.0: https://docs.nvidia.com/nim/bionemo/openfold3/1.0.0/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nim/bionemo/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nim/bionemo/_mcp/server.

# Configuration Alternatives at Runtime

This section provides a guide on how to run the OpenFold3 NIM with different settings for
1. port number for http requests
2. backend
3. template processing

These instructions assume

1. You have installed and set up [Prerequisite Software](/nim/bionemo/openfold3/1.2.0/prerequisites) (Docker, NGC CLI, NGC registry access).
2. You have pulled the container as described in [Getting Started](/nim/bionemo/openfold3/1.2.0/getting-started)

## Start the OpenFold3 NIM

To start the NIM:

```bash
export NGC_API_KEY=<Your NGC API Key>
export LOCAL_NIM_CACHE=~/.cache/nim
```

```bash
docker run --rm --name openfold3 \
    --runtime=nvidia \
    --gpus 'device=0' \
    -e NGC_API_KEY \
    -v $LOCAL_NIM_CACHE:/opt/nim/.cache \
    -p 8000:8000 \
    --shm-size=16g \
    nvcr.io/nim/openfold/openfold3:latest
```


<Note>
The meaning of the following [docker run options](https://docs.docker.com/reference/cli/docker/container/run) are given below
- The `-p` option sets the port for the NIM.
- The `-e` options define the environment variables, which are passed into the NIM's container at runtime.
- The `--rm` option removes the container and associated file system usage when it exits / terminates.
</Note>

## Using an Alternative Port for OpenFold3 NIM Requests

If you have other HTTP servers running (for example, other NIMs), you may
need to make the 8000 port available by using another port for your NIM. To use an alternative port:

1. Change the exposed port by setting the `-p` option.
2. Set the `NIM_HTTP_API_PORT` environment variable to the new port.

The following is an example of setting the NIM to run on port 6626:

```bash
export NGC_API_KEY=<Your NGC API Key>
export LOCAL_NIM_CACHE=/mount/largedisk/nim/.cache
```

```bash
docker run --rm --name openfold3 \
    --runtime=nvidia \
    --gpus 'device=0' \
    -e NGC_API_KEY \
    -e NIM_HTTP_API_PORT=6626 \ ## We must set the NIM_HTTP_API_PORT environment variable...
    -v $LOCAL_NIM_CACHE:/opt/nim/.cache \
    -p 6626:6626 \ ## as well as forward the port to host.
    --shm-size=16g \
    nvcr.io/nim/openfold/openfold3:latest
```


## Backend Optimization Options

By default, the NIM will run in TensorRT mode for supported GPUs. You can override the default backend optimization by setting the `NIM_OPTIMIZED_BACKEND` environment variable.

The following backend options are available:

- **`trt`** (default): TensorRT with cuEquivariance kernels for optimized performance on supported GPUs
- **`torch`**: PyTorch with cuEquivariance kernels for GPU memory-management and acceleration
- **`torch_baseline`**: PyTorch with DeepSpeed kernels for GPU memory-managment and acceleration

### Running with PyTorch+cuEquivariance

The following is an example of setting the NIM to run with PyTorch+cuEquivariance:

```bash
export NGC_API_KEY=<Your NGC API Key>
export LOCAL_NIM_CACHE=~/.cache/nim
```

```bash
docker run --rm --name openfold3 \
    --runtime=nvidia \
    --gpus 'device=0' \
    -e NGC_API_KEY \
    -e NIM_OPTIMIZED_BACKEND=torch \ ## Set the backend to PyTorch+cuEquivariance
    -v $LOCAL_NIM_CACHE:/opt/nim/.cache \
    -p 8000:8000 \
    --shm-size=16g \
    nvcr.io/nim/openfold/openfold3:latest
```


### Running with PyTorch+DeepSpeed

The following is an example of setting the NIM to run with PyTorch+DeepSpeed:

```bash
export NGC_API_KEY=<Your NGC API Key>
export LOCAL_NIM_CACHE=~/.cache/nim
```

```bash
docker run --rm --name openfold3 \
    --runtime=nvidia \
    --gpus 'device=0' \
    -e NGC_API_KEY \
    -e NIM_OPTIMIZED_BACKEND=torch_baseline \ ## Set the backend to PyTorch+DeepSpeed
    -v $LOCAL_NIM_CACHE:/opt/nim/.cache \
    -p 8000:8000 \
    --shm-size=16g \
    nvcr.io/nim/openfold/openfold3:latest
```


## Template Configuration Options

### Configuring Template Chain Selection Threshold

When using structural templates, the NIM validates that template chains have sufficient similarity to your query sequence. You can control the minimum score threshold using the `CIF_DIRECT_MIN_SCORE` environment variable.

**Score Calculation:**

```
score = sequence_identity × query_coverage
```

The variables are:
- `sequence_identity`: Fraction of aligned residues that match between template and query
- `query_coverage`: Fraction of the query sequence covered by the alignment

**Default Value:** `0.1` (10% identity × coverage)

**How It Works:**

- **With `chain_id` specified**: The specified chain in the input CIF string, is validated against the threshold. If the score is below the threshold, the template is rejected.
- **Without `chain_id` (automatic selection)**: All chains in the input CIF string are evaluated. The best matching chain is selected only if its score meets the threshold. If no chain meets the threshold, then
no chain from the input CIF string is used.

<Note>
The `chain_id` parameter is specified in the inference request payload when providing structural templates. For example, in the `templates` field of your API request, you can include `"chain_id": "A"` to specify which chain from the input CIF string should be used for alignment validation.
</Note>

**Configuration Example:**

```bash
export NGC_API_KEY=<Your NGC API Key>
export LOCAL_NIM_CACHE=~/.cache/nim
```

```bash
docker run --rm --name openfold3 \
    --runtime=nvidia \
    --gpus 'device=0' \
    -e NGC_API_KEY \
    -e CIF_DIRECT_MIN_SCORE=0.2 \ ## Set minimum score threshold to 0.2
    -v $LOCAL_NIM_CACHE:/opt/nim/.cache \
    -p 8000:8000 \
    --shm-size=16g \
    nvcr.io/nim/openfold/openfold3:latest
```


**Guidance:**
- **Lower values (0.05-0.15)**: More permissive, includes template sequence with very few residues in common with the query sequence.
- **Default value (0.1)**: Balanced approach for most use cases.
- **Higher values (0.2-0.4)**: More restrictive, includes only template sequences with many residues in common with the query sequence.