# AISim Deployment Search

<!--
SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
SPDX-License-Identifier: Apache-2.0
-->

## Purpose

The GPU type and budget are given, and the question is how to run the
model on them: "maximize throughput on these eight B200s", "aggregated or
disaggregated on this node?". AISim simulates candidate
deployments on CPU (backend, aggregated or prefill/decode disaggregated,
tensor/data/expert parallelism, replicas, scheduler limits), ranks them for
the user's goal, and writes each pick as a concrete config. GPUs are used
only at the end, with approval, to spot-check a short list.

AISim narrows the search. It does not replace measurement on the target
hardware. Label predicted numbers as simulated, also after a spot-check;
the spot-check adds measured numbers next to them, it does not turn the
predictions into measurements.

## When to use

- Fixed GPU type and budget; the question is the best configuration on them
  (most throughput per GPU, lowest TTFT, best goodput under an SLA, or the
  throughput/latency trade-off).
- Aggregated against disaggregated, or vLLM against SGLang, on given GPUs.
- Deploying and benchmarking the top picks of an AISim search.

Do not use this skill when:

- the decision is the GPU count or GPU type: "how many do we need?", "how
  many of my eight must I allocate?", "can these eight handle 100 requests
  per second?". That is sizing: use `aisim-gpu-selection-and-sizing` if it
  is installed, otherwise say this skill does not size hardware;
- the user wants a published, already-measured recipe, a broken
  deployment fixed, or an endpoint that is already running benchmarked.
  Those need recipe, troubleshooting or benchmarking tools, not
  simulation.

## Former names

AISim was previously called AIConfigurator and then AISimulate. You will still
see those names in places: the `aiconfigurator` and `aisimulate` packages, an
`aiconfigurator` command that AISim 0.14 still installs, `AICONFIGURATOR_*`
variables in generated scripts, and the AIConfigurator paper. Treat them as
legacy names for AISim. Use the `aisim` package and the `aisim` CLI only. Do
not install `aiconfigurator` or `aisimulate`, and do not use the `aiconfigurator`
command (its `support` subcommand answers a different question and often says
NO for combinations AISim handles).

## Prerequisites

- `aisim` 0.14.x in a Python 3.11 to 3.13 environment. Before the first
  AISim command, run this once, as one command. It installs AISim only
  when it is missing, into a virtual environment in the working
  directory. AISim is a CPU-only package, so this needs no separate
  approval; carry on with the task afterwards:

  ```bash
  command -v aisim >/dev/null || {
    python3 -m venv .venv-aisim 2>/dev/null || {
      python3 -m venv --without-pip .venv-aisim
      python3 -c "import urllib.request as u; u.urlretrieve('https://bootstrap.pypa.io/get-pip.py', 'get-pip.py')"
      .venv-aisim/bin/python get-pip.py
    }
    .venv-aisim/bin/python -m pip install -q "aisim==0.14.0"
  }
  PATH="$PWD/.venv-aisim/bin:$PATH" aisim --version    # expect 0.14.x
  ```

  The inner fallback covers Python images that ship without `pip`. Shell
  state may not carry over between commands, so start later commands
  with `export PATH="$PWD/.venv-aisim/bin:$PATH"` when AISim was
  installed this way. Tell the user what you installed. If an
  installation exists under an old name, follow
  [references/install-and-support.md](references/install-and-support.md).
  If AISim cannot be installed, report the installation error and stop.
- Model metadata: AISim ships configs for about 95 models. For any other model it
  fetches `config.json` from huggingface.co over HTTPS. `HF_HUB_OFFLINE` does
  not stop that fetch, so a model outside the bundled set needs network
  access (and `HF_TOKEN` for gated models).
- About 1 GB of free RAM per parallel candidate. On a small machine or
  sandbox, cap AISim with
  `execution: {resources: {memory_limit_gb: 4, cpu_limit: 4}}`.
  A cap above free RAM fails at once with exit 3.
- Files are written under the output directories you pass, plus the
  Python package cache during installation. The optional spot-check also
  writes on the GPU host or cluster.
- For step 6 only: a GPU host or Kubernetes cluster with NVIDIA Dynamo, the
  model weights, and explicit approval from the user.
- `SKILL_DIR` below means the directory that contains this `SKILL.md`.

## Instructions

Work through the steps without pausing between them. Stop only for a
missing input (step 1) or for approval before GPUs are used (step 6).
Keep the number of commands small: write each YAML file with a shell
heredoc in the same command that runs it.
Always finish with a written answer: what ran, the numbers from the saved
artifacts labeled as simulated, or the failure and its message.

### 1. Pin the question

Reuse the inputs the user supplied. Before starting a search, identify:

- Model: Hugging Face ID, for example `Qwen/Qwen3.5-35B-A3B`.
- GPU type: an AISim system ID. Blackwell first: `b200_sxm`, `b300_sxm`,
  `gb200`, `gb300` (all have vLLM, SGLang and TensorRT-LLM data in 0.14.0).
  Also available: `h200_sxm`, `h100_sxm`, `h100_pcie`, `a100_sxm`,
  `a100_pcie`, `a30`, `l40s`, `l4`, `b60`, `rtx_pro_6000_server`; coverage
  per backend varies. GB200 and GB300 systems are modeled as 4 GPUs per
  node in an NVLink domain, so candidates above 4 GPUs span nodes.
- GPU budget: the most GPUs a candidate may use.
- Workload: input and output tokens or the original trace, how requests
  arrive, and the longest request for `context_length`. Record the stopping
  rule. For an every-request target, establish the exact request count
  from the supplied workload or agree on a sample size with the user.
- Goal: `throughput_per_gpu`, `throughput`, `throughput_per_user`,
  `goodput`, `goodput_per_gpu` (needs an SLA), `ttft`, `e2e_latency` or
  `pareto`, plus any SLA (`ttft_ms`, `itl_ms`, or `e2e_ms`). `itl_ms` is
  checked against mean TPOT.

Derive what follows from the request instead of asking, and state the
values you derived: `context_length` is the next power of two at or above
the longest input plus output (1024 in / 128 out gives 2048), and the
request count defaults to ten times the concurrency for synthetic traffic
and to the whole trace for a recorded one. Ask only when the model, GPU
type, GPU budget, workload or goal is missing, and ask for all of them at
once. If the user named one exact deployment to predict, skip the search:
go directly to step 5 with their YAML, or write it from template E when
they described it in words. If the request also asks to deploy the
winner, run the CPU search and report it first; deployment waits for the
approval in step 6.

### 2. Write recommendation.yaml

Use a template from
[references/config-templates.md](references/config-templates.md) and fill in
only the pinned values. Always set `engine.context_length`; leaving it unset
uses the model maximum (262144 tokens for Qwen3.5) and silently drops
parallel shapes whose KV cache cannot hold one such sequence. Keep
`parallelism: {preset: default}` unless the user names shapes. Start with
`optimizer.max_trials` between 8 and 32 and tell the user it is a sample.

For a mode comparison, use template B: one search per GPU type with
`engine.mode.choices: [aggregated, disaggregated]` and all three worker
roles. Hold traffic, backend choices and budget constant across modes.
For a recorded trace, use template D (`traffic.source.type: trace` with a
`paths` list).
For an end-to-end-only limit, set `evaluation.sla.e2e_ms` alone. If the
user also requires TTFT or TPOT, keep all of their bounds in the report.
AISim 0.14.0 accepts E2E and token-latency SLAs in separate runs. Hold
the candidate and workload fixed when reporting separate results. Leave
joint compliance unverified unless a single run's per-request records
show which requests met all the requested bounds.
For a goodput goal, select `goodput` or `goodput_per_gpu` and set
`optimization.strict_sla: true`. This checks aggregate latency; step 4
verifies a promise about **every** request.

### 3. Run the search on CPU

```bash
aisim recommend --stack engine \
  --config recommendation.yaml \
  --output-dir ./aisim-recommendation
```

Use a new output directory for every run. An existing non-empty directory
fails with exit 2 unless `--overwrite` is passed, and a failed run can leave
files behind. Exit codes:

- `0`: at least one candidate selected.
- `1`: no feasible candidate. Explain why from the not-feasible rows below
  (step 4 prints each failure reason). Report that reason for this GPU
  type and stop there; a rerun with other settings, or extra runs the user
  did not ask for, does not change it.
- `2`: invalid configuration, or no shape is viable for the model, GPU type
  and backend (for example "no deployment_mode has a viable parallel
  config"). Report the message; do not retry with invented data.
- `3`: local resource limit. If `recommendations/` was still written, the
  result covers only the candidates that ran; say so. Then read the reason
  in `resource-runtime.json` and the error message, and act on the cause:

  - the run's processes exceeded the memory cap: a lower cap fails again.
    Raise the cap (it must stay below free RAM) or shrink the search, for
    example fewer GPUs or backends, then rerun.
  - free host memory fell below the reserved headroom: free host memory
    until the reserve is available, then rerun. Lowering the cap does not
    restore free-memory headroom.
  - the cap was above free RAM at start: lower the cap below free RAM or
    free enough host memory for that cap, then rerun.

  Check available host memory (on Linux, `MemAvailable` in `/proc/meminfo`)
  and retry in a new directory only after correcting the reported cause.
  If the same limit recurs, report it and the candidates that ran.

The run log can include "Loading low-fidelity fallback rows" or "Sibling
version ... excluded from implicit nearest-earlier fallback". They do not
stop the run, but they mean some operations are priced from substituted
data. Tell the user when they appear.

### 4. Read the result

`recommendation.csv` stores each candidate's config and metrics as JSON
blobs and is hard to read. Use the bundled summarizer:

```bash
python3 "$SKILL_DIR/scripts/summarize_recommendation.py" ./aisim-recommendation --top 5
```

It prints, in rank order: the YAML file, backend and version, parallel
shape, GPUs used, score, output tokens per second (total and per GPU),
mean TTFT, TPOT and E2E, and completed and SLA-compliant requests. It then
lists the not-feasible candidates and why, and states how many rows it
left out. Add `--json` for machine-readable output. Report the top three
and say how many candidates were evaluated and rejected.

If **every request** must meet a bound, pass the workload's full request
count, for example `--require-all-requests 320` for 320 requests. The
summarizer checks every feasible candidate in `recommendation.json` for
`goodput_completed_requests == completed_requests == num_requests == 320`
before ranking. A missing total request count cannot establish this guarantee.
For `pareto`, it recomputes the non-dominated set among qualifying candidates
using their recorded objective vectors and lists it by the last objective,
ascending. Single-objective runs keep score ordering.
If none qualify, report that result for this sample. A mean of 2.5 seconds
can hide a 4-second request under a 3-second limit. For a mean-only SLA,
use the ordinary summary.

When the user compares modes (aggregated against disaggregated), add
`--best-per-mode`. The best candidate of a mode can rank below the top
three; the script prints it anyway. If a mode has no qualifying candidate,
report that explicitly.
When comparing modes, disclose that an omitted `engine.kv_transfer` (a null
`kv_transfer_bandwidth` in the result) assumes zero KV-transfer delay, so the
disaggregated result can be optimistic. For a deployment decision, rerun the
disaggregated mode separately with a representative
`engine.kv_transfer.bandwidth_gb_per_second`; aggregated mode rejects that block.


At fixed concurrency, `throughput_per_gpu` favors the smallest pool that
holds the load. If the user cares about latency too, say so and offer a
`pareto` run.

### 5. Predict the selected configuration

Use the chosen row's `config_file` under the search output directory.
Check that the file exists; if the path is null or the file is absent,
export that row by candidate ID. For example, for an
every-request deadline on 320 requests:

```bash
python3 "$SKILL_DIR/scripts/summarize_recommendation.py" ./aisim-recommendation \
  --require-all-requests 320 --export "$candidate_id" --to ./selected.yaml
```

Set `pick_yaml` to the selected or exported path (or the exact input YAML
for a prediction-only request). Filtering can put a different candidate
ahead of the one in `0001.yaml`.

Set `pick_stack=engine` for the engine recommendations above and for supplied
YAML without top-level `router` or `planner` sections. If supplied YAML has
either section, set `pick_stack=dynamo` and use the matched Dynamo integration.
If that integration is unavailable, report it and stop the prediction; keep
the supplied sections intact.

Use a fresh output directory for each pick and each run, including retries,
so earlier results remain available. The command below creates a unique empty
directory on each invocation:

```bash
pick_output=$(mktemp -d ./aisim-pick.XXXXXX)
aisim predict --stack "$pick_stack" \
  --config "$pick_yaml" \
  --capture-per-request \
  --output-dir "$pick_output"
```

If prediction fails, quote its diagnostic and keep the selected YAML and
output directory. Classify it with the table in
[references/install-and-support.md](references/install-and-support.md): a
model that does not fit ("no KV budget") is a different conclusion from
missing coverage. Give no performance numbers for a failed prediction.
Correct the reported input, integration, or resource problem before
retrying. Proceed to a hardware spot-check only with a successful
prediction for the chosen workload.

The printed table shows mean TTFT, request latency and Inter Token
Latency. `prediction.json` in the output directory adds `mean_tpot_ms`,
the time per output token of each request, averaged over requests. Judge
a per-output-token latency target against `mean_tpot_ms`, which is what
an `itl_ms` SLA checks. With mixed request lengths it differs from
`mean_itl_ms`; report both and say which one the target applies to.
In the per-request records (`requests.jsonl`, and `per_request` in
`prediction.json`) that per-request value is the field `itl_ms`.

The summary prints a `Timing (<role>): estimator=...; source=...;
data_version=...` line per worker role; report it with the numbers. For a
search result, keep the recommendation's stack. The numbered YAML files contain
absolute paths into the local AISim install (`systems_paths`), so re-run
them on the same installation rather than copying them elsewhere.

### 6. Spot-check on GPUs (only with approval)

Give the CPU result first. Before a command allocates GPUs or changes the
cluster, obtain approval for the actual pick, GPU count, target host or
namespace, and duration. An initial request to “deploy the winner” leaves
the pick open. In the answer that reports the CPU result, name the
proposed pick, its GPU count and the target, ask the user to confirm them
and the duration, and end there. Until they do, leave the cluster alone:
run no `kubectl` or `helm` commands and do not inspect how this machine
connects to it. After confirmation, follow
[references/gpu-spot-check.md](references/gpu-spot-check.md): render
Dynamo launch scripts for the pick with `aisim.generator` (on CPU), launch
on the user's host or cluster, and benchmark with the same arrival process
the simulation used:

- For a trace, use its original per-request lengths and the selected load
  policy. The reference covers Mooncake replay with recorded timestamps,
  fixed concurrency, and request-rate load. Verify that replay is supported
  before allocating GPUs.
- For fixed-length synthetic traffic, use the AIPerf command matching the
  selected concurrency or request rate and the simulated request count.

Never apply a numbered `recommendations/*.yaml` file as a Kubernetes
manifest.

### 7. Compare and conclude

Put predicted next to measured for each pick: output tokens per second per
GPU, TTFT, per-request TPOT (AIPerf's per-request average ITL is AISim's
TPOT), and completed requests. Report the prediction's stack. For
`--stack engine` against a full Dynamo deployment on hardware, explain that
frontend and routing effects are only in the measurement. Name the pick
that won on hardware. If the measured order differs from the predicted
order, say so and keep the measured result.

## Examples

**User:** "Maximize throughput per GPU for Qwen3.5-35B-A3B on these eight
B200s, 1k in / 128 out at concurrency 10."

**Agent:** writes `recommendation.yaml` with `hardware: b200_sxm`,
`backend: {choices: [vllm, sglang]}`, `context_length: 2048`,
`max_candidate_gpus: 8` and target `throughput_per_gpu`. It runs
`aisim recommend` and summarizes the top three with the script. It notes
when the per-GPU winner uses fewer than the eight GPUs, and asks before
any spot-check.

**User:** "On sixteen GB300s, is prefill/decode disaggregation worth it for
Qwen3.5-35B-A3B at 4k in / 512 out, concurrency 32, for throughput per
GPU?"

**Agent:** uses `mode: {choices: [aggregated, disaggregated]}` with
aggregated, prefill and decode worker roles in one run. It runs the
summarizer with `--best-per-mode` and reports the best of each mode side by
side, even when one ranks below the top three.

## Limits to state to the user

- Rankings come from simulation. Accuracy varies by model, GPU, backend and
  version; see the end-to-end accuracy page in the references.
- A small `max_trials` is a sample, not an exhaustive search.
- Missing data for a model, GPU and backend means AISim cannot price that
  candidate. It is not evidence that the candidate is bad.

---

Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.

The license files are attached. [Apache 2.0](https://knowen.md/f/d1b26c59-a154-4da4-a063-aca638c651b1) · [CC BY 4.0](https://knowen.md/f/7f7aaa6a-a0bf-4460-9b22-48da4ce0fdc9)

The attached ZIP contains the pinned supporting files and applicable license notices.