> This page is for version latest (default).
> For other versions, use one of these documentation indexes:
> - latest (default): https://docs.nvidia.com/alchemi/vasp/latest/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/alchemi/vasp/llms.txt.

# Configure

> Environment variables that control calculation execution and file management.

The ALCHEMI VASP microservice provides configuration options that control the
calculations that are run and how they are executed.

## Backend Environment Variables

The backend manages executing the tasks. Configure it using
the following environment variables:

| Variable                         | Description                                                                                                                                                                                              |
| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ALCHEMI_MAX_JOBS_PER_GPU`       | Maximum number of concurrent tasks to run on each GPU. Default gives each task at least one CPU core: `max(1, num_cpus // num_gpus)`.                                                                    |
| `ALCHEMI_MAX_CPUS_PER_CORE`      | Maximum number of CPU threads to use per physical core. Reduce for better performance in codes with high CPU utilization. Default uses all available threads per core.                                   |
| `ALCHEMI_OUTPUT_RETENTION`       | Number of output files to retain per replica for completed tasks. Default retains none. Set to `all` to retain all outputs, or an integer to retain the most recent outputs.                             |
| `ALCHEMI_OUTPUT_DIRECTORY`       | Directory in which to copy output files for completed tasks. Default is `/workspace/completed/`.                                                                                                         |
| `ALCHEMI_SCHEDULE_DEPTH`         | Limits how many submitted requests may concurrently wait in the GPU-selection step. Higher values improve utilization under load. Set it to `1` for first-come, first-served scheduling. Default is `8`. |
| `ALCHEMI_DEFAULT_SIZE`           | Default amount of GPU memory to assume for tasks, in MB. Default is `512`.                                                                                                                               |
| `ALCHEMI_IGNORE_SIZE`            | Ignore size estimates made using VASP. Use the value of `ALCHEMI_DEFAULT_SIZE` instead                                                                                                                   |
| `ALCHEMI_LAUNCH_DELAY`           | Minimum time between launching two tasks, in seconds. Avoids conflicts from multiple MPI launches on the same node. Default is 500 ms.                                                                   |
| `ALCHEMI_INPUTS_CAPACITY`        | Maximum disk space to use for storing input files *per replica*, in GB. Default is `10`.                                                                                                                 |
| `ALCHEMI_INLINE_FILE_MAX_MB`     | Maximum size of any file provide as part of an single inference request, in MB. Default is `50`                                                                                                          |
| `ALCHEMI_INLINE_FILES_MAX_MB`    | Maximum size for all files provided as part of a single inference request, in MB. Default is `50`                                                                                                        |
| `ALCHEMI_INLINE_FILES_MAX_COUNT` | Maximum number of files provided as part of a single inference request, in MB. Default is `100`                                                                                                          |
| `ALCHEMI_INPUTS_DIRECTORY`       | Directory in which to store input files. Default is `/workspace/input`.                                                                                                                                  |
| `ALCHEMI_ACTIVE_DIRECTORY`       | Directory in which the microservice executes VASP. Default is `/workspace/active`.                                                                                                                       |
| `ALCHEMI_MAX_PENDING_REQUESTS`   | Maximum number of requests to process on a single instance at one time. Default is 64.                                                                                                                   |
| `ALCHEMI_SERVICE_TOKEN`          | A bearer token used to authenticate requests. Default is to make a random 32-bit token                                                                                                                   |
| `ALCHEMI_ALLOW_UNAUTHENTICATED`  | Disable the bearer token authentication if value is "1". Only use if other security is employed.                                                                                                         |

## Performance Tuning

The microservice defaults to running as many tasks as possible on the system.
This may not be optimal for all workloads.

Determine the optimal settings by first reducing the number of concurrent tasks
on the CPUs by setting `ALCHEMI_MAX_CPUS_PER_CORE` to `1` if your system has
multiple threads per core.

Then reduce the number of concurrent tasks on the GPUs by setting
`ALCHEMI_MAX_JOBS_PER_GPU` to a fixed number. Use values between `8` and `16`
for most workloads.

## Managing Disk Space

Control the amount of disk space used by the service through controlling
either the number of output files retained from completed tasks
or quotas for the input files used by new tasks.

### Output File Retention

The `ALCHEMI_OUTPUT_RETENTION` environment variable defines the
maximum number of output file sets to retain *per replica*.

There are no explicit limits to the amount of disk space used by output files.

### Input File Quotas

Input files used in calculations are provided by pre-staging them through
the `POST /input/upload` endpoint or as part of the inference request
sent to `POST /submit` or `POST /infer`.

Manage the disk space available for pre-staged files by
`ALCHEMI_INPUTS_CAPACITY` variable.
Like the outputs, the capacity is defined *per replica* so that
the disk capacity scals as more replicas are created.

Restrict the volume of input files provided as part of inference requests
by limiting the disk space via `ALCHEMI_INLINE_FILE_MAX_MB` and
`ALCHEMI_INLINE_FILES_MAX_MB` or the number allowed via
`ALCHEMI_INLINE_FILES_MAX_COUNT`.

## Rate Limiting

Control the number of calculations which the service will
run at one time through `ALCHEMI_MAX_PENDING_REQUESTS`.
Pending requests include both the tasks currently running
on the GPUs and those which are waiting for GPU
resources to become available.