Skip to navigation

Deploy

View as MarkdownOpen in Claude

The example commands are for Docker on a Linux host.

The microservice runs inside a container and uses NVIDIA’s Container Toolkit to access the GPU. The container launches a FastAPI frontend webservice and a multiprocess backend that manages the execution of jobs on each available GPU.

Launching and Configuring the Container

A minimal command to run the service is:

docker run -it --rm \
--runtime=nvidia \
-p 127.0.0.1:8000:8000 \
--pid=host \
alchemi-vasp:latest

This command uses the following options:

  • -it launches the command in an interactive terminal.
  • --rm deletes the file system on exit.
  • --runtime=nvidia enables NVIDIA Container Toolkit support.
  • -p 127.0.0.1:8000:8000 exposes the webservice to a port accessible from the host.
  • --pid=host is optional and only required to track memory use.
  • alchemi-vasp:latest is the name of the container image to run.

Add further configuration options by setting environment variables.

Ensure the service is only available to those licensed by VASP GmbH.

Providing POTCAR Files

Make POTCARs available to the microservice after building by mounting VASP pseudopotential files (POTCARs) to /opt/potcar.

docker run -it --rm \
--runtime=nvidia \
-p 127.0.0.1:8000:8000 \
-v /path/to/vasp-potcars/:/opt/potcar \
--pid=host \
alchemi-vasp:latest

Mounting a POTCAR directory is optional. You can also supply POTCAR files when in the request to the microservice.

Directory Structure

The pseudopotential directory structure can contain multiple types of POTCARs as separate subdirectories. For example, the following directory structure supplies both PAW_GGA and PAW_GGA_54 as the potcar_type field.

/path/to/vasp-potcars/
├── PAW_GGA
│ ├── Ac
│ │ ├── POTCAR.Z
[...]
├── PAW_GGA_54
│ ├── Ac
│ │ ├── POTCAR
[...]

POTCARs must be in a unique directory named after the element symbol and can be compressed with a .Z extension.

The microservice expects the directories holding POTCAR types to follow a specific naming format if requests use default pseudopotential sets. Name directories as PAW_<functional>_<version> where “functional” is the name of the functional (for example, PBE or LDA) and the version is a two-digit number (for example, 64). For example, place the Be_sv pseudopotential for a PBE functional from version 54 at ./PAW_PBE_54/Be_sv/POTCAR.

Authentication

The microservice uses bearer token authorization to ensure only authorized users are able to run VASP calculations.

Supply a pre-selected token via the ALCHEMI_SERVICE_TOKEN environment variable on launching the container.

docker run -it --rm \
--runtime=nvidia \
-p 127.0.0.1:8000:8000 \
-e ALCHEMI_SERVICE_TOKEN=private-token \
--pid=host \
alchemi-vasp:latest

A random token will be generated then printed to the log file if no token is provided.

$ docker logs alchemi-vasp
[...]
2026-11-04 15:33:31,763 - alchemi_qc.service.backend - INFO - Enforcing a minimum spacing of 500 ms between task launches
2026-11-04 15:33:31,763 - alchemi_qc.service.auth - WARNING - No ALCHEMI_SERVICE_TOKEN provided. Generated token: -8n7nmGVJW-WnA3v8kvTKsZuDDVfTk2RdOOLpDDF11w
2026-11-04 15:33:31,781 - uvicorn.error - INFO - Started server process [9355]
[...]

Running Multiple Replicas

The microservice must share a file system for several directories if running multiple replicas behind a load balancer:

  • /workspace/completed stores the output summaries and, if configured, output files for completed requests.
  • /workspace/inputs stores the input files for requests.

Every replica can retrieve files from the shared directories when required and deletes files when users request them.

File Management

The microservice manages input and output files separately, and both follow first-in-first-out (FIFO) deletion policies.

The microservice stores input files in the /workspace/inputs directory. You can delete a specific input file (GET /input/delete/{file_id}) or files older than a certain age (DELETE /input/purge). The microservice also deletes files automatically when the number of files exceeds the configured limit, starting with the oldest files.

The microservice stores results in the /workspace/completed directory. It stores two types of files:

  • Summary files ({request_id}.json) are either empty placeholders for the results or a fully formed ready reply.
  • Output files ({request_id}.tar) are the full output files from VASP.

The microservice deletes both types of files when a client successfully retrieves them (for example, GET /result/{request_id} or GET /files/{request_id}/download). It deletes output files if more than a configured number are present in the directory, removing the oldest first.

Use the DELETE /status/purge and DELETE /files/purge endpoints to remove old output files from the service.

For Multiple Replicas

Each replica manages its own output files. Each replica maintains its own FIFO queue for deleting unclaimed output files and old input files. As a consequence, the disk space required for the shared directories grows with the number of replicas.

Exposing Output Files to Clients

Allow clients to access the output files of a service directory by mounting the /workspace/completed directory as a volume.

docker run --rm -it \
--mount type=bind,src=./outputs,dst=/workspace/completed \
-e ALCHEMI_OUTPUT_RETENTION=all \
-p 127.0.0.1:8000:8000 \
-u $(id -u):$(id -g) \
alchemi-vasp:latest

The --user $(id -u):$(id -g) option allows the container to write files with the same user and group ID as the host user.

Logging Behavior

The service writes logs to standard output by default. An example log on a workstation with a single GPU is as follows:

2026-05-29 14:42:15,914 - alchemi_qc.drivers.vasp - INFO - Using VASP command: ['/usr/bin/vasp']
2026-05-29 14:42:15,914 - alchemi_qc.service.frontend - INFO - Using backend driver: vasp
2026-05-29 14:42:15,916 - alchemi_qc.service.backend - INFO - Using a maximum of 32 jobs per GPU
2026-05-29 14:42:15,916 - alchemi_qc.service.backend - INFO - Output retention policy set to 8
2026-05-29 14:42:15,916 - alchemi_qc.service.backend - INFO - Schedule depth set to 8
2026-05-29 14:42:16,385 - alchemi_qc.service.frontend - INFO - Server startup complete
2026-05-29 14:42:16,387 - uvicorn.error - INFO - Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)

The launch procedure is as follows:

  1. FastAPI initializes the driver which manages VASP calculations.
  2. The backend starts and configures itself according to the environment variables and available hardware.
  3. The frontend detects default configuration settings to use for all requests.
  4. The backend detects the CPU and GPU memory hierarchy and launches an executor process for each GPU using only the appropriate CPU cores for that GPU.
  5. The server is ready to accept requests.