aisim-gpu-selection-and-sizing

Created about 12 hours ago

attributes
additional_license_urlshttps://github.com/NVIDIA/skills/blob/4c28452d0f686e185de5d2fd0d445ab85308a380/LICENSE-CC-BY-4.0
allowed-toolsBash Read Write
compatibilityPython 3.11-3.13; aisim 0.14.x (targets 0.14.0); CPU only; PyYAML (installed with aisim)
descriptionSizes how many GPUs of which type serve a model's inference request rate within a latency SLA (AISim on CPU). Not for tuning a GPU budget already chosen (use aisim-deployment-search) and not for training jobs.
licenseApache-2.0
license_urlhttps://github.com/NVIDIA/skills/blob/4c28452d0f686e185de5d2fd0d445ab85308a380/LICENSE-APACHE
metadata{"author": "NVIDIA AISim team", "version": "0.1.0", "tags": ["aisim", "capacity-planning", "gpu-sizing", "inference", "simulation"]}
nameaisim-gpu-selection-and-sizing
permissionsenv, file_read, file_write, network, shell
publisherNVIDIA
repository_urlhttps://github.com/NVIDIA/skills
source_urlhttps://github.com/NVIDIA/skills/blob/4c28452d0f686e185de5d2fd0d445ab85308a380/skills/aisim-gpu-selection-and-sizing/SKILL.md
upstream_copyrightCopyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
upstream_licenseApache-2.0
upstream_revision4c28452d0f686e185de5d2fd0d445ab85308a380

AISim GPU Selection and Sizing

Purpose

Answer "how much hardware does this workload need?" for a model, an
expected request rate and a latency SLA. For each candidate GPU type, the
result is the smallest qualifying configuration found in the tested search
space: GPU count, serving configuration, latency at the planned load, the
highest tested load multiple that still qualifies, and cost if the user
supplies prices. Everything runs on CPU, in simulation.

The decision variable is the GPU count. Owning GPUs does not change that:
"I own eight B200s; how many must I allocate to this service?" and "can
these eight B200s handle 100 requests per second?" are sizing questions.
"How do I get the most out of these eight B200s?" is not; that is
aisim-deployment-search.

Scope of this version

  • Load must be a request rate: traffic.load.type poisson or
    constant_rate, with input and output token lengths.
  • If the user gives the load as a fixed concurrency (closed loop) or as a
    recorded trace, say this version sizes request-rate workloads only. Ask
    for the expected request rate, or decline. The bundled scripts reject
    other load types.
  • Use one backend per run, such as vllm or sglang.
  • The GPU count is for a static deployment at one load, not autoscaling.

When not to use

  • Best configuration, throughput or latency on a fixed GPU budget:
    aisim-deployment-search.
  • Published benchmark results for a GPU, or sizing training jobs.

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:

    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; the scripts then find aisim and PyYAML. Tell the
    user what you installed. The PyPI installer fetches the wheel from
    pypi.nvidia.com. If setup fails, report the error and stop; it says
    nothing about the model or hardware.

  • Network: none for the roughly 95 models whose configs ship with AISim.
    For other models, AISim fetches config.json from huggingface.co over
    HTTPS, and HF_HUB_OFFLINE does not stop that fetch. Gated models also
    need HF_TOKEN.

  • Files are written under the output directories you pass, plus the
    Python package cache during installation.

  • Memory: AISim exits 3 at once if its memory cap is above free RAM. On a
    small machine add --set execution.resources.memory_limit_gb=<GB>, with
    a value below free RAM (MemAvailable in /proc/meminfo), and
    --set execution.resources.cpu_limit=<N> to run fewer candidates at
    once; each needs about 1 GB.

  • SKILL_DIR below means the directory that contains this SKILL.md.
    Run the scripts as python3 "$SKILL_DIR/scripts/<name>.py".

Instructions

Work through the steps without pausing between them. Stop only when step
1 says an input is missing. 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 sizing question

Use the supplied values. The inputs are:

  • Model (Hugging Face ID) and the GPU types to evaluate. Blackwell first:
    b200_sxm, b300_sxm, gb200, gb300. Hopper (h200_sxm, h100_sxm)
    is available for comparison. GB200 and GB300 are modeled as 4-GPU nodes
    in one NVLink domain, so counts above 4 span nodes. NVFP4 checkpoints need
    a Blackwell GPU type; on Hopper every candidate fails.
  • Backend: one per run. Use the one the user names; if they name none,
    use vllm and say so.
  • Request rate, arrival pattern (poisson unless they say evenly spaced)
    and input/output token lengths. Mixed-length workloads are fine.
  • SLA: ttft_ms and/or itl_ms (AISim checks itl_ms against mean TPOT,
    time per output token per request), or e2e_ms alone. These are bounds
    on aggregate means, not percentiles. For a 3-second mean end-to-end
    target, set only evaluation.sla: {e2e_ms: 3000}; AISim supports it
    directly. Ask for TTFT/TPOT limits only if the user also needs separate
    limits. Evaluate those separately from the E2E-only configuration.
    If the user requires a joint compliance share across E2E and TTFT/TPOT,
    state that separate evaluations do not establish that joint share.
  • The capacity rule, two numbers that come from the user:
    • required SLA-compliant throughput (min_goodput_rps): requests per
      second that must finish within the per-request SLA.
    • required compliance share: the share of all requests that must meet
      that run's per-request SLA, for example 99%. It is checked in step 5.
  • Optional price per GPU-hour for each GPU type. Never invent prices.

What to do when part of the capacity rule is missing:

  • The user gave the throughput requirement but no compliance share: run
    the sizing now. Their requirement is the rule. Use it as
    min_goodput_rps, and in step 5 use that requirement divided by the
    request rate for both shares (90 of 100 requests per second is 0.90).
    Say in the report that no separate compliance share was given and which
    value you used.
  • The user gave no throughput requirement: a request rate alone does not
    say how many late requests they accept. Before running any search, ask
    for it, and for the compliance share if that is missing too. Offer the
    planned rate and a share such as 99% as defaults, explain that the
    measured throughput runs slightly below the planned rate on a finite
    run, and wait for the answer. Stating values you chose yourself is not
    agreement.

Everything else can be derived: context_length is the next power of two
at or above the longest input plus output, and the request count is the
request rate times 300 seconds unless the user fixed it.

2. Write sizing.yaml

traffic:
  source: {type: synthetic, input_tokens: 2048, output_tokens: 256}
  load: {type: poisson, requests_per_second: 20}
  stop: {requests: 6000}          # at least 300 s of arrivals: rate x 300

engine:
  mode: {choices: [aggregated, disaggregated]}
  model: Qwen/Qwen3.5-35B-A3B
  hardware: b200_sxm              # replaced per GPU type by the ladder
  backend: vllm
  context_length: 4096            # at least input + output tokens
  workers:
    aggregated: {parallelism: {preset: default}}
    prefill: {parallelism: {preset: default}}
    decode: {parallelism: {preset: default}}

evaluation:
  sla: {ttft_ms: 500, itl_ms: 50}

optimization:
  target: min_gpus
  constraints:
    max_candidate_gpus: 16        # replaced per step by the ladder
    min_goodput_rps: 18           # the agreed SLA-compliant throughput

optimizer:
  max_trials: 16

Use an observation window of at least 300 seconds. A shorter run can miss
queue buildup. Check the per-request compliance share and SLA-compliant
throughput as well as aggregate latency means before presenting a GPU count
as sufficient.

3. Run the sizing ladder for each GPU type

python3 "$SKILL_DIR/scripts/size_ladder.py" sizing.yaml \
  --hardware b200_sxm --out-root ./sizing-b200_sxm > ladder-b200_sxm.json

The report is printed to standard output; save it as shown. A ladder at
100 requests per second takes a few minutes per GPU type, so let it
finish. Use --hardware for the GPU type and --budgets for the maximum
GPU counts at each step. When the user owns a fixed number of GPUs, or
asks whether a given number can carry the load, end --budgets at that
number (--budgets 1,2,4,8 for eight); the load fits when the ladder
qualifies a count within it. Do not override engine.hardware or
optimization.constraints.max_candidate_gpus with --set, including through
parent mappings such as engine or optimization.constraints. The script
rejects those overrides with exit 2 before probing or searching, so its
coverage probe, search steps and report refer to the same hardware and budgets.
Other overrides, such as resource limits and min_candidate_gpus, remain available.

The script works around an issue in AISim 0.14.0: one large-budget
min_gpus search can miss smaller qualifying configurations. It is fixed on
main after 0.14.0 (https://github.com/ai-dynamo/aisim/pull/913). Remove the
script once this skill pins a release that includes the fix. It:

  1. validates the config and refuses non-request-rate loads or a missing
    min_goodput_rps;
  2. probes coverage with a one-request prediction per backend, and stops
    with exit 4 if AISim has no timing data or does not model the
    architecture. A one-GPU KV-memory fit failure can proceed to the ladder.
    For an invalid configuration or an unexplained probe error, quote the
    diagnostic and stop before starting a larger search;
  3. runs aisim recommend at budgets 1, 2, 4, 8, 16 (or the --budgets
    you pass), each in a fresh directory. It raises the budget only on
    genuine infeasibility: every
    evaluated candidate missed the SLA or load constraints, or no shape
    fits the budget. It stops on configuration, data, resource or
    evaluation errors;
  4. stops increasing the cap at the first qualifying budget, then tests
    budgets above the last failing budget and below the qualifying result's
    GPU count in ascending order, stopping at a qualifying result or an error.
    It does not revisit untried budgets below the last failure. Use the refined
    answer.used_gpus and answer.config_file for step 5.

It prints a JSON report with every step, an answer and a warnings
list; relay every warning to the user. Exit codes:

Exit Meaning What to tell the user
0 answer holds the smallest qualifying configuration found in the tested search space GPU count and configuration, with that wording
1 nothing qualified up to the largest budget (16 GPUs by default) in the sampled search not "impossible"; give the closest misses from the not-feasible rows
2 input or configuration error fix the input; no sizing conclusion
3 local resource limit, timeout or evaluation error no sizing conclusion; retry with a lower memory cap or longer timeout
4 no AISim coverage for model, GPU type and backend Quote the probe reason and stop sizing that combination. No GPU count or cost can be inferred.

A step with status qualified_partial (AISim exit 3 with a selected
result) means some candidates were resource-limited; say the result covers
only the evaluated candidates.

Read any step's candidates with:

python3 "$SKILL_DIR/scripts/summarize_recommendation.py" <output_dir> --top 3

It shows mean TTFT, TPOT and E2E, completed and SLA-compliant request
counts, goodput and output tokens per second per GPU. It also states how
many rows it left out.

4. Keep the fallback disclosures

If the AISim log shows "Loading low-fidelity fallback rows" or "No exact
CLI args template", tell the user the prediction uses substituted
performance data or templates for some operations. size_ladder.py and
headroom_scan.py save each AISim run's log next to its output directory
(log_file) and copy any such lines into fallback_warnings in their JSON
report, including for runs that succeeded. Check fallback_warnings on the
step or row you report.

5. Confirm the compliance share and measure headroom

python3 "$SKILL_DIR/scripts/headroom_scan.py" \
  ./sizing-b200_sxm/<phase>-b<budget>/recommendations/0001.yaml \
  --min-compliant-share 0.99 --min-goodput-share 0.90 \
  --steps 1.0,1.25,1.5,2.0 --workdir ./headroom-b200_sxm \
  > headroom-b200_sxm.json

Use the config_file from the ladder's answer. Set --min-compliant-share
to the agreed compliance share before using the scan's verdict: 99.9% needs
0.999, replacing the example's 0.99. Set --min-goodput-share
to the agreed min_goodput_rps divided by the planned request rate: the
template uses 18 / 20 = 0.90. This keeps the agreed floor at 1.0x and scales
it with the offered rate at higher multiples. For each tested load, the
scan reports pass, fail or unknown:

  • the SLA is checked with AISim's own aggregate check (all configured
    bounds, fail-closed on missing data);
  • the compliance share and the goodput share must both meet the agreed
    numbers;
  • it also reports completed and compliant counts, the arrival window and
    the run duration.

For separate E2E and TTFT/TPOT evaluations, report each compliance share
separately. If the user needs a joint share, mark it as unestablished; two
99% shares can have only 98% joint compliance.

The scan reads traffic.load, traffic.stop and evaluation.sla from
the prediction YAML; the ladder's config_file already carries them, so
it needs no edit. --set overrides of these sections, their children or
parent mappings are rejected with exit 2 before any prediction; otherwise a
late override could replace a scanned rate or make the verdict use a different
SLA. Overrides for other settings, such as
--set execution.resources.memory_limit_gb=4, remain available.

It exits 3 if any load could not be evaluated.

  • Accept a count only when the 1.0x row passes, the sizing window covers
    at least 300 seconds, and the evidence applies to that exact pick. If the
    user requested a shorter sizing run, label the ladder result provisional
    and relay its warnings, even when the separately extended scan passes.
    An unknown 1.0x result leaves capacity unverified.
    If the user requires joint E2E and TTFT/TPOT compliance, separate passing
    scans leave the count unestablished for that joint requirement; do not
    label it qualifying, even when both 1.0x rows pass.

  • If the 1.0x row fails, the configuration does not meet the user's
    compliance rule at the planned load. To retry above its GPU count, set
    optimization.constraints.min_candidate_gpus to that count + 1, start
    --budgets at that minimum, and use --no-refine so refinement cannot
    revisit smaller budgets. For a rejected two-GPU answer:

    python3 "$SKILL_DIR/scripts/size_ladder.py" sizing.yaml \
      --hardware b200_sxm --out-root ./sizing-b200_sxm-retry \
      --budgets 3,4,8,16 --no-refine \
      --set optimization.constraints.min_candidate_gpus=3
    

    --budgets alone sets upper bounds and can select the rejected answer
    again. Check that the new answer.used_gpus is above the rejected count
    before running its headroom scan. If it is not, stop and report that the
    retry made no progress. Only report a qualifying replacement after its
    1.0x row passes the same compliance and throughput rules.

  • Report highest_tested_passing_multiplier as "qualifies at the tested
    loads up to N x the planned rate". It says nothing about loads between
    or beyond the tested points.

6. Cost (only with user-supplied prices)

For each qualifying type, use answer.used_gpus and the passing 1.0x
headroom row's sla_compliant_output_tok_s for that same configuration.
For example, four GPUs at $4.50 per GPU-hour cost $18/hour. At 2,500
SLA-compliant output tokens/s they deliver 9 million such tokens/hour:
$18 / 9 = **$2 per million SLA-compliant output tokens**. Use the user's
prices and the simulated rate in their result. If the rate is missing or
zero, report the hourly price only; raw token throughput counts late work.

7. Report

One table per GPU type, with these columns:

  • smallest qualifying GPU count found, and the configuration, or
    "unestablished for the requested joint requirement" when only separate
    E2E and TTFT/TPOT shares were evaluated;
  • mean TTFT, TPOT and E2E at the planned rate;
  • completed and SLA-compliant requests;
  • highest tested passing multiple;
  • cost, if priced.

Then state:

  • the results are simulated;
  • for established requirements, the count is the smallest qualifying
    configuration found in the tested search space;
  • the SLA is checked on means;
  • when both E2E and TTFT/TPOT bounds were requested: separate compliance
    shares do not establish a joint compliance share;
  • the final choice should be measured on hardware with the same request
    rate and arrival pattern.

Examples

User: "We expect 100 requests per second of 2k in / 256 out on
Qwen3.5-35B-A3B. TTFT must stay under 500 ms and TPOT under 50 ms, 99% of
requests within SLA, and we need 90 SLA-compliant requests per second.
How many B200s or GB300s do we need?"

Agent:

  1. Has every input, so asks nothing. Sets min_goodput_rps: 90 and
    30,000 requests (300 seconds of arrivals).
  2. Runs size_ladder.py for b200_sxm and gb300.
  3. Runs headroom_scan.py with --min-compliant-share 0.99.
  4. Reports per type: the GPU count found, whether 1.0x passed the 99% rule,
    the highest tested passing multiple, and that all of it is simulated.

Read each result from the saved artifacts. If a type fails the 99% rule at
1.0x, report that failure and do not present its ladder count as sufficient.

User: "I own eight B200s. How many do I need to set aside for 100
requests per second of the same workload, with at least 90 SLA-compliant
requests per second?"

Agent: treats it as sizing with --budgets 1,2,4,8. No compliance
share was given, so it uses 90 / 100 = 0.90 for both shares and says so.
It reports the GPU count found, or that nothing qualified within eight.

User: "How many B200s for 50 requests per second of that workload,
TTFT under 500 ms?"

Agent: runs nothing yet. The request has no required SLA-compliant
throughput and no compliance share, so it asks for both, offering 50
requests per second and 99% as defaults.

User: "We run at concurrency 64. How many GPUs?"

Agent: asks for the expected request rate, because this version sizes
request-rate workloads only.

Limits to state to the user

  • Simulated, not measured. Accuracy varies by model, GPU type and backend;
    see https://ai-dynamo.org/aisim/e2e-accuracy/.
  • Each budget step is a sampled search (optimizer.max_trials), so a
    smaller configuration can exist.
  • SLA bounds are checked on aggregate means; tails (p90, p99) can exceed
    them. The 0.14.0 recommendation ledger provides mean TTFT, TPOT and E2E;
    the summarizer does not report tail latency from this ledger.

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

The license files are attached. Apache 2.0 · CC BY 4.0

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

Like how this is organised?

Build your own Memory tree on knowen.md: notes, decisions and tasks in one connected markdown graph, shared with your team and your AI agents.