Skip to content

Model servers

Without settings, each population's fleet calls the application's stub. With PopulationConfig.model set, it calls OpenAI-compatible model servers, such as vLLM's, which run in a job of their own. AUTONMI finds them through two files, as the repository's model job writes them:

  • endpoints: one base URL per line, without /v1, written once every server answers;
  • api-key: the servers' key, readable by its owner only.

In a script

autonmi.models.wait_for_servers waits until every server in endpoints answers /health, and returns the fleet's settings, a frozen autonmi.models.ModelSettings (API):

from autonmi import CampaignConfig, PopulationConfig
from autonmi.models import wait_for_servers

model = await wait_for_servers("FLEET/endpoints", "FLEET/api-key", name="Qwen3-8B", max_tokens=512)
config = CampaignConfig(run_dir=..., population=PopulationConfig(model=model))
ModelSettings field Default What it is
endpoints, endpoints_file (), None the servers' base URLs (a tuple), and the file read again after an outage
api_key_file None the key's file; never the key itself, since the settings go into the run's records
name Qwen3-8B the served model's name
max_tokens 512 per reply
timeout_s 600 per call
thinking_off {"enable_thinking": False} chat-template arguments sent with every call; {} sends none, so a model whose template thinks by default, as Qwen3's does, thinks
outage_s 1,800 how long a call waits for its server to come back (Failures)
poll_s 5 seconds between checks of the servers, while waiting for them and during an outage

wait_for_servers takes the fields after its two files as keywords, and raises TypeError for a keyword that is not one. It waits at most wait_s (1,800 s) for every server to answer, and raises TimeoutError past it. The example mini-app's --model-wait sets wait_s.

Each population gets one Flowgentic HTTPTransport per server, with temperature 0. The settings have no field for the key itself: they go into the run's records.

To compare the fleet's token counts with the servers' own, the script samples the servers' counters over the campaign with autonmi.vllm.VllmSampler and writes them to RUN/vllm/vllm.json before it calls campaign.check(), which then adds the check tokens_match_the_servers when the campaign has the run's MiniApp and Flowgentic's export. The example mini-app, examples/miniapp.py, does this with --model openai.

vllm.json holds, per server, the samples' times in Unix seconds and ten of vLLM's metrics as the server reported them, summed over their labels: running and waiting requests, KV cache use, tokens, prefix-cache queries and hits, preemptions and successful requests. Counters count since the server started; kv_cache_usage_perc is a fraction per engine, 1 for a full cache. A sample a server missed is counted in errors and leaves no entry. The names are in the API reference.

Try it on a laptop

The tests run this path against two fake vLLM servers (tests/fake_vllm.py) that answer with the tool-calling toy's stub, with vLLM's /health, chat API and counters:

.venv/bin/python -m pytest -q tests/test_autonmi.py -k "model_servers or outage"

One server refuses its first requests in the second test; the fleet waits it out, and the run's checks, tokens_match_the_servers among them, pass.

The model job on Slurm

jobs/submit model FLEET [sbatch options] submits jobs/model.sh with the cluster's settings from jobs/local.env (see Run under Dragon). It starts one vllm serve per GPU of the job, one at a time, and writes into FLEET: endpoints and api-key, gpu.csv (nvidia-smi every second) and a log per server.

jobs/submit model FLEET --cpus-per-task=8 --mem=64G --time=01:30:00
  • The servers run with prefix caching, automatic tool choice, a context of 32,768 tokens, 90 % of each GPU's memory, and --enable-prompt-tokens-details, so each call records how much of its prompt was still in the server's prefix cache.
  • A server that dies is started again on its own port, up to AUTONMI_VLLM_RESTARTS times (3); past that the job ends.
  • The job is requeueable. A requeued job starts over with the same key, on new ports; campaigns read endpoints again while they wait.
  • It ends when FLEET/stop appears, or at its time limit. One model job can serve several campaigns.
Variable Default What it sets
AUTONMI_MODEL the model's weights (a directory)
AUTONMI_MODEL_NAME Qwen3-8B the served name; give a mini-app the same with --model-name
AUTONMI_TOOL_PARSER hermes vLLM's tool-call parser
AUTONMI_REASONING unset: no parser, and requests with a thinking budget fail vLLM's reasoning parser, such as qwen3
AUTONMI_REASONING_START, AUTONMI_REASONING_END <think>, </think> what starts and ends the thinking
AUTONMI_TP 1 GPUs per server (tensor parallelism)
AUTONMI_VLLM_ARGS more vllm serve options
AUTONMI_VLLM_RESTARTS 3 restarts of a server that dies

A model larger than one GPU

AUTONMI_TP=k jobs/submit model ... starts one vLLM server per k GPUs of the job (--tensor-parallel-size k). The fleet sees one replica per server, with its admission caps.

On hosts whose GPUs report peer access that their IOMMU then blocks, tensor parallelism hangs twice, and needs two settings in jobs/local.env:

export NCCL_P2P_DISABLE=1                        # else NCCL hangs at start-up; with it, NCCL goes through host memory
AUTONMI_VLLM_ARGS="--disable-custom-all-reduce"  # else vLLM's own all-reduce hangs after a few minutes of serving

The first must be exported: the job scripts read jobs/local.env but pass on only what is exported, and NCCL runs inside vLLM. Without the second, the server starts, serves for a few minutes, then its engine times out waiting for its workers (shm_broadcast TimeoutError).

Admission caps

Each replica admits calls while its live context in flight stays under cap_tokens and its requests in flight under cap_requests, whichever binds first. The defaults are where one 96 GB GPU's throughput peaked for Qwen3-8B on the screening workflow:

  • 235,000 tokens of live context, with long contexts (7,400 tokens per call): well before the prefix cache starts evicting contexts about to be reused;
  • 96 requests, with short contexts (1,500 tokens per call): past that, decoding slows with the number of sequences.

For another model or GPU, measure before you change them.