Contact
Skip to the page text

Documentation / Guides / Models and deployments

Tuning a Model's Performance

A model's speed on a GPU depends on its checkpoint, its engine and the engine's options in the profile's compose.yaml. The defaults are rarely the best for one GPU. This guide finds better settings with a guided search, not a grid of every value: read what this model, checkpoint, engine and GPU offer; check the answers before any speed number; change one option per round and measure it with a short probe; run the full benchmark once, on the settings you chose. The optimize-model skill runs these steps.

Before you start

  • Work in a draft. Change the profile in a draft of a catalog without an upstream (see Catalogs, "Try changes in a draft"). To tune a profile of a catalog that follows an upstream, duplicate it into a catalog without one first. Everyone else keeps deploying the published profile while you work.
  • Give the draft its own model name. The API gateway sends a model's requests to every inference service with that model name. A test service that keeps the published name receives real clients' requests: your measurements are wrong, and a setting under test answers real clients. In the draft, change api.routing_model_id in ai-deploy.yaml (for example add -tuning), and the engine's served model name in compose.yaml to the same value. Set both back before you publish.
  • Use a GPU like the one the model runs on. A result on another GPU model, or another number of GPUs, does not carry over.
  • Agree on the plan with the operator first: the model, the GPUs, the goal (one user, many users, long context, or a balance), the time budget and the options to try. Every round redeploys the test service.

Research

Most of the result is decided by reading, before any GPU time.

  • The checkpoint. Read the model card and config.json: dense or mixture of experts, the active parameters, the attention (full, sliding window, linear, Mamba), the KV heads, the native context, the weight precision. Estimate the KV cache bytes per token (layers that keep the whole context x 2 x KV heads x head size x bytes per value): it tells you early whether memory, context or compute is the limit. Prefer the publisher's own checkpoint, then a well-known quantizer, then a community build only after checking its downloads, age and quantization config. Diff a repackaged checkpoint's chat template, generation config and tokenizer files against the publisher's, and take the publisher's where they differ. Pin the weights by revision and the image by digest.
  • Precision: FP8 by default. The weights, the KV cache and any drafter are FP8 (on NVIDIA Hopper), or a smaller format where the publisher or the engine recommends one for the GPU (NVFP4 on Blackwell). Without a trusted FP8 checkpoint, the engine can quantize the official 16-bit weights at load time (vLLM --quantization fp8_per_block). Name the KV cache's type in the engine command (vLLM --kv-cache-dtype fp8, SGLang --kv-cache-dtype fp8_e4m3), and never write auto or leave the option out: the engine then chooses the type, its choice can change with the engine version, the model or the GPU, and the profile check gives the hint engine.kv-cache-dtype. Where 16-bit is right (see below), name that type too (--kv-cache-dtype bfloat16) with a comment naming the reason. Quantize a drafter as well where the engine can (vLLM's quantization in --speculative-config, SGLang --speculative-draft-model-quantization fp8); it is read on every draft step. A checkpoint without calibrated KV scales runs with scale 1.0: check the answers, and do not stay at 16-bit for it. 16-bit is used only for a specific reason: an explicit recommendation against FP8 for this model by its publisher or the engine (model card, serving recipe, issue), or a quality loss the answer checks measured. Write the precision of all three into the journal, and each reason for 16-bit with a link to its source.
  • Speculative decoding. Look, in this order, for built-in prediction heads (MTP, "nextn" layers: num_nextn_predict_layers or mtp_* in config.json, their tensors in the weight index), a drafter from the publisher (DFlash, EAGLE, an "assistant" or "draft" repository), a drafter from a trusted source, and a model-free method of the engine (n-gram, suffix matching). If one exists, deploy the baseline with it on, as the publisher recommends it. It is usually the largest gain for one user.
  • The engine. Which engines support the architecture natively, and since which version: the engine's model registry and recipes, the publisher's own image or plugin. Confirm the support inside the exact image you pin. Use the reasoning and tool-call parsers the publisher names. Note a nightly image and the release that will replace it.
  • Missing pieces are built, not skipped. When the best setting needs something the image lacks (a package, a plugin), build an image with it rather than take a weaker setting.
  • The levers. Write the candidate options in the order you expect them to matter: the speculative length, the KV cache and context, the scheduler limits, kernels and backends (the start-up log names a missing tuned kernel configuration), options that change with the load. Only what this model, engine and GPU support goes on the list.

Check the answers first

A faster model that answers worse is a failed result. With the baseline settings, check through the path clients use, and again in every round that can change answers (precision, quantization, speculative settings that are not lossless):

  • every reasoning mode the model offers, tool calls (parallel ones if the card claims them), an answer built from a tool result, every input type and every API the card lists;
  • a fixed set of short questions with known answers in the model's languages and domain, each asked several times, compared with the baseline;
  • a hidden fact at increasing context lengths up to the card's maximum.

Read the start-up log (Model logs): the memory the weights took, the KV cache size in tokens, the kernels and backends chosen, the time each phase took, and every warning; warnings often name the next lever.

The probe

A round is decided with a short probe, not the full benchmark: the full benchmark runs every level of every workload and takes up to an hour, the probe a few minutes.

  • Run it as a benchmark at chosen levels: inference_services_change, operation replicas_benchmark_start, with workloads naming one workload (usually mixed-load/1.1.0; max-prefill/1.0.0 for a change to prefill; coding-greedy/1.0.0 for a speculative decoding setting) and concurrency_levels naming the levels, for example [1, 16, 64, 256]. The load generator measures exactly those levels, in that order, the same way the benchmark measures each level, and no plateau ends the workload: its stop_reason is requested-levels.
  • requests_per_level (at least 4) sets how many requests each level measures, instead of the workload's at least 20 and at least twice the level. Fewer requests finish a level sooner and give rougher percentiles; at level 1 the 20 requests of the full benchmark take minutes on a large model.
  • The probe offers no benchmark file to commit (benchmark_file is null): read its figures from results of replicas_benchmark_get. A model card shows the newest committed benchmark file, and a probe of a few levels must never stand in for a full benchmark there.
  • Every request has a unique prompt (no prefix cache or speculative cache answers it from an earlier request) and, where the engine can ignore the end-of-sequence token, a fixed answer length. After a warm-up the level measures a window and counts only the tokens generated inside it: decode tokens per second, the inter-token latency, time to first token and prefill tokens per second.
  • Do not probe a speculative decoding setting with mixed-load or max-decode: their prompts are random words and their answers continue past the end, which a drafter guesses far too rarely or far too often, so the speed they show is not the speed clients get. Probe it with coding-greedy/1.0.0 (below), whose real prompts are answered to their natural end.
  • Levels: 1 (one user), a middle one and a high one; add a level only when a change targets it. In mixed-load, the lengths come from one seeded draw across the levels, so a probe that skips levels sends each level other lengths than the full benchmark does (the same distribution, not the same requests): compare probes with probes.
  • Calibrate it once against the full benchmark at two levels, and repeat one run: the spread between runs is the noise. Decide on the inter-token latency and per-user speed, which repeat within a few percent; a throughput difference inside the noise is not a result. Discard the first run after a deploy.
  • Keep the method identical across the rounds of one session: the same workload, levels and requests_per_level.

One round

  1. Change one option in the draft's compose.yaml and commit it, with a message that names the option and its new value.
  2. Redeploy the test service (inference_services_change, operation redeploy), and wait until its replica is ready.
  3. Repeat the answer checks the change could affect.
  4. Probe at the agreed levels.
  5. Read the engine's own figures: KV cache size and use, running and waiting requests, preemptions, the speculative acceptance rate.
  6. Keep the change only when it wins where the goal needs it. Stop a direction when it loses at every level; when a numeric value wins, try one value on each side. When a setting wins at one end and loses at the other (one user against many), look for an option that adapts to the load, and check that the engine supports the combination.
  7. Write the round in the journal at once: the option, the value, the numbers, the engine's figures, and what you saw.

A round where the engine does not start (out of GPU memory, a refused option) is a result too. Read the replica's log (Model logs), write down why, set the option back, and continue.

The benchmark

The full benchmark runs once, on the chosen settings. It measures one replica, on its inference node. The node runs the load generator as a one-off job next to the replica, and the load generator sends requests straight to the engine, not through the API gateway. Start it with inference_services_change, operation replicas_benchmark_start. It runs in the background for minutes to an hour; read it with inference_services_read, operation replicas_benchmark_get, until its state is no longer running. Stop it early with operation replicas_benchmark_cancel.

It measures three workloads, each with throughput and latency figures at every concurrency level:

WorkloadPromptAnswerStands forPlateau decided by
max-prefill/1.0.08192 tokens64 tokenslong documents with short answersprefill tokens per second
max-decode/1.1.0256 tokens1024 tokensshort prompts with long answersdecode tokens per second
mixed-load/1.1.0128 to 8192 tokens64 to 1024 tokensreal traffic: short and long requests batched togetherboth

In mixed-load, each request draws its prompt and answer length from the ranges, as often a short length as a long one by ratio (log-uniform), from a fixed seed: every run sends the same lengths in the same order. Results compare when the workload's name and major version match: a max-decode/1.1.0 result compares with a max-decode/1.0.0 one at the levels both have. The load generator's WORKLOADS.md defines each workload and every figure.

Each level keeps exactly that many requests in flight and measures in a steady window after a warm-up, over at least 20 requests. The levels 1, 2, 4, 8, 12, 16, 20, 24 and 32 are always measured; after 32, the workload continues with 40, 48, 64, 80, 96, 112 and 128 (max-prefill), and then 160, 192, 256, 384, 512, 768 and 1024 (max-decode, mixed-load) while the throughput still grows, and stops when two levels in a row gain less than 5 percent. A replica that climbs to 1024 takes 15 to 25 minutes longer. plateau_concurrency is the lowest level that reaches 95 percent of the best throughput: the most requests the replica takes at once before they only wait longer.

A replica that still gains at 1024, a small model on the largest nodes, is measured further with max-decode/1.2.0 and mixed-load/1.2.0, named in workloads: the same workloads with the levels 1536, 2048, 3072 and 4096 after 1024. They compare with their 1.1.0 results at every level both have. They run only when named, and a level keeps the same rule for its sample: 4096 measures 8,192 requests, so only a replica that has not reached its plateau climbs that far.

When the full benchmark fails on one workload (a failed request, an engine crash, a sudden drop at some level), do not rerun the whole benchmark to test a fix: the workloads that passed take most of its hour. Find the cause in the replica's log, change one setting, and run only the failing workload (replicas_benchmark_start with workloads naming it, and concurrency_levels naming the level where it failed and the one above) to check the fix. Run the full benchmark again once that workload passes, on the final settings.

A benchmark loads the replica to its limit. It is refused on a replica that serves clients, unless you set measure_while_serving_clients: measure a test service instead. Only one job of a replica runs at a time. The inference node keeps the latest one of each replica until the replica is removed or the node restarts; nothing else keeps it.

One run measures one kind of workload and writes one benchmark file of that kind: text generation (the coding workloads included), embeddings, OCR or decisions. A run that names workloads of two kinds is refused; start a second run for the other kind. The run's benchmark_file_schema names the kind of file it writes, and so the shape of its results.

The OCR benchmark

An OCR model takes one page image and answers the page's text. The workload ocr-pages/1.1.0 measures it with the pages of olmOCR-Bench, rendered once into page images: each request sends one page and no text. It runs only when you name it in workloads, and only on a model whose deploy profile lists image in model.capabilities.input; for another model the start is refused with that reason. Its figures are pages per minute and seconds per page, at every concurrency level, by the same method as the other workloads, with at least 100 pages per level.

The page images reach the inference node once. The first OCR run on a node adds them to the node's downloads (they show on the server's page under "Cached benchmark files"), and the run waits until they are downloaded; its output says so. The node keeps them, so later runs start at once. An inference node that runs a release too old for the OCR benchmark is refused it with the next step: update it under Servers. The other benchmarks run on it as they are.

After the levels, the run reads every page once at the plateau concurrency and scores the page texts with the official olmOCR-Bench checker, in the same job: the result's full_pass, with accuracy inside it. accuracy.score is the olmOCR-Bench score from 0 to 1, the mean of the checker's test groups, so it compares with published olmOCR-Bench scores (published as percentages); accuracy.groups gives each group's share of passed tests. A page whose request failed has no text, so its tests fail. When the checker cannot score, full_pass.accuracy_failure says why, and the speed figures stand. The earlier ocr-pages/1.0.0 measures the levels only.

Some OCR models read a page only when the request also asks them in their own words: task tokens, or a sentence such as OCR:. Sent a page image alone, such a model answers nothing useful or refuses the request (NVIDIA Nemotron Parse 2.0 answers The decoder prompt cannot be empty), and every level fails. Give such a model's deploy profile the file benchmarks/ocr-prompt.txt with that text, as its model card states it. The run sends it in every request, in the same user message, after the page image; you set nothing when you start the benchmark. The place is fixed: a model that needs its text before the image, or as a system message, is not covered. The text is sent as the file has it, with its spaces and the line breaks inside it; only the line breaks at the file's end are left out. It is UTF-8 and at most 4,096 bytes. Its tokens count in the run's prompt_tokens_mean. It changes only the benchmark's requests: the model's own users send what they send. It is read from the profile as it was deployed, so deploy the profile again after you change it; the run's result names the text it sent (prompt, null when it sent the page image alone), so you can see which one a run used. A wrong text is not refused: the model answers badly, and the full pass's accuracy shows it. A file that is too long, not UTF-8, or empty (nothing but spaces and line breaks) refuses the start with the reason, and the deploy profile checker warns about it; the warning does not stop a deploy. A profile without the file is sent the page image alone. Two models asked with different prompts still compare: each is asked the way its publisher says to ask it.

The checker reads Markdown: formulas between $ or $$, tables as Markdown or HTML tables, no page headers or footers. A model that answers a page in a format of its own (layout HTML with a block per region, formulas in tags) gets a low score for its format, not for its reading: its formulas are not found and its page headers count as text. Give such a model's deploy profile the file benchmarks/ocr-answer-to-markdown.py, a Python file that defines to_markdown(answer: str) -> str. The run hands it to the checker, which converts every page's answer before it scores. The file may use the Python standard library and BeautifulSoup (bs4, with its html.parser and lxml parsers), at most 64 KiB. It changes only what is scored: the model answers its users as before, and no converted text is kept. It is a plain function, so test it on your machine with a few of the model's answers before you deploy. It runs inside the benchmark job's container, as the job's user, with no time limit of its own: a converter that never returns holds the run until you cancel it. It is read from the profile as it was deployed, so deploy the profile again after you change it. The deploy profile checker warns about a file that is too large, not Python, or without the function; the warning does not stop a deploy. A converter that fails on one page stops the scoring of every page: the pass has no accuracy, and full_pass.accuracy_failure names the page and the reason. Correct the file, deploy again and start the benchmark again; the speed figures of the failed run stand. A profile without the file is scored on its answers as they are.

An OCR run uses its own load generator image, the OCR load generator: the same program with the checker and the headless browser the checker's math tests need, about 1.5 GB. The inference node pulls it the first time an OCR benchmark starts; the other benchmarks never pull it. GET /api/config/replica-benchmark shows both images, and PUT sets another OCR image with replica_ocr_benchmark_image.

The decision benchmark

A decision model answers a typed question about an input (yes or no, one of several options) with a probability for every allowed answer, in one pass and without writing text. Tokens per second say nothing about it: its speed is decisions per second and seconds per decision. The workloads decide-text/1.0.1 (7,516 text cases) and decide-image/1.0.1 (751 cases with one image each) measure it with cases built from JevBench, a public benchmark for decision models: content safety, agent safety, banking intent, medicine and examination questions. Each request sends one case to POST /v1/decisions.

They run only when you name them in workloads, and only on a model whose deploy profile declares model.capabilities.decisions; decide-image/1.0.1 also needs image in model.capabilities.input. For another model the start is refused with that reason. A decision model also generates text, so benchmark it twice: one run with the text generation workloads, one with the decision workloads.

A decision run measures two things:

  • The levels. Decisions per second and seconds per decision at every concurrency level, by the same method as the other workloads, with at least 200 decisions per level. Every case has a known right answer, so each level also counts its correct answers (decisions_correct). A level whose share of correct answers falls below the other levels' answered fast and wrong: the engine does not serve that concurrency correctly, and its speed there is not a figure to use.
  • The full pass. After the levels, the run sends every case once at the plateau concurrency and scores the answers: full_pass, with accuracy inside it. accuracy.score is the share of all cases answered correctly, from 0 to 1; accuracy.groups gives each group's share; accuracy.expected_calibration_error says how far the stated probabilities are from the share of correct answers (0 is best). A failed request does not end the pass: its case counts as not correct, and requests_failed counts it.

A full run takes about 15 to 25 minutes on one GPU. The cases reach the inference node once, like the OCR page images: the first decision run on a node adds them to its downloads under "Cached benchmark files" (about 76 MB), and waits until they are downloaded.

The coding benchmark

Speculative decoding guesses the next tokens with a small drafter and keeps the guesses the model agrees with. How much it gains depends on what the model writes, so it is measured with real requests. The workloads coding-greedy/1.0.0 and coding-sampled/1.0.0 send 10,000 real coding requests (edit a file, write code, explain or fix pasted code), taken from public datasets, and let every answer end where the model ends it, at most 4,096 tokens. coding-greedy answers at temperature 0: every speculative decoding setting of one model then writes the same answers, so their speeds compare exactly. coding-sampled answers at temperature 0.7, as clients usually ask, and accepts fewer guesses. They are text generation workloads: name them in workloads, alone or with the other text generation workloads. They run only when named, and only on a model with a context of at least 12,288 tokens; for a smaller one the run lists them in not_run with that reason.

Code is predictable text, so these workloads show speculative decoding at its best. Settings tuned on them suit a coding model: say so in the deploy profile's description.

Each level adds figures to the text generation figures; the run keeps them in the job's output, and the benchmark file keeps the text generation figures only:

  • completion_tokens_per_stream_event: about 1 without speculative decoding, and about the tokens one step produces with it, on every engine.
  • draft_acceptance_rate and draft_acceptance_length: the engine's own counts over the measured window (vLLM). draft_acceptance_unavailable_reason says why they are empty on another engine or without speculative decoding.
  • prompt_tokens_cached: near 0 when no request was answered from the prefix cache. Every request starts with a sentence of its own and asks the engine not to reuse a cached prefix.
  • prompts_reused and answers_truncated: requests that repeated an earlier request of the run, and answers cut at 4,096 tokens. A drafter that learns from earlier answers (n-gram or suffix speculation) guesses a repeated request too well; it also remembers an earlier run, so restart the replica between two runs you compare.

The requests reach the inference node once, like the OCR page images: the first coding run on a node adds them to its downloads under "Cached benchmark files", and waits until they are downloaded.

Engine options

The options most rounds change, in the two engines most profiles use. The research decides their order for one model.

OrdervLLMSGLangWhat it changes
1the engine booking (runtime.engine_memory_booking_bytes_per_device in ai-deploy.yaml)--mem-fraction-statichow much GPU memory the engine takes; more leaves more room for the KV cache, too much fails at start or under load. For vLLM the deploy writes --gpu-memory-utilization from the engine booking, so change the booking, not the flag; keep the hardware booking above it by the overshoot measured under load (measuring GPU memory)
2--max-model-len--context-lengththe longest request; a shorter limit leaves room for more requests at once
3--kv-cache-dtype fp8--kv-cache-dtype fp8_e4m3the KV cache's precision; FP8 by default (see "Research"), it holds about twice the tokens
4--max-num-seqs--max-running-requestshow many requests run at once
5--max-num-batched-tokens--chunked-prefill-sizehow many prompt tokens one step takes; higher helps time to first token, lower helps a steady token rate
6speculative decoding (--speculative-config)--speculative-algorithma draft model or the model's own extra heads guess tokens; on from the baseline when the model has it, and its length is tuned

The engines' own guides explain every option: vLLM's Optimization and Tuning and Engine Arguments, and SGLang's Hyperparameter Tuning and Server Arguments.

The engine's log says what an option did. vLLM logs the KV cache size in tokens, and warns when it preempts requests for lack of KV cache. SGLang logs max_total_num_tokens and available_gpu_mem before it is ready: 5 to 8 GB left is a good value.

Finish

  1. Commit the chosen settings, redeploy them and run the full benchmark on exactly them, reading the replica's GPU memory every half minute (measuring GPU memory). Commit the run's benchmark_file as it is, at its benchmark_file_path (benchmarks/<YYYY-MM-DD>-<HHMM>Z-llmperfbench.yaml, the UTC date, hour and minute the run started, such as 2026-11-10-0428Z-llmperfbench.yaml, so the runs of one day sort in the order they ran; never replace another run's file, and only when a file of that exact name is already there add a short id of your own before .yaml), and add journal naming the session's entry. The model card shows the newest benchmark on the GPUs the profile is qualified on. The numbers belong to the compose file they are committed with, so measure the final settings, never an earlier round.
  2. Set the model name back to the published one, in ai-deploy.yaml and in compose.yaml.
  3. Undeploy the test service.
  4. Publish the draft. The operator then redeploys the production service to run the new options.

Benchmarks on other GPUs

A profile keeps every benchmark as its own file under benchmarks/, so a profile can record how it runs on several GPU products and counts. A benchmark on other GPUs, or by someone else, is a file added beside the others, never a change to an existing one. The format is the schema https://schemas.onprem.ai/ai-deploy-profiles/v1.1.0/benchmark.schema.json; a file written for the earlier https://schemas.onprem.ai/ai-deploy-profiles/v1/benchmark.schema.json still reads. An embedding model's benchmark is named <YYYY-MM-DD>-<HHMM>Z-embedperfbench.yaml and uses the schema https://schemas.onprem.ai/ai-deploy-profiles/v1.0.0/embedding-benchmark.schema.json; the benchmark of a profile that declares model.capabilities.embedding answers such a file. An OCR benchmark is named <YYYY-MM-DD>-<HHMM>Z-ocrperfbench.yaml and uses the schema https://schemas.onprem.ai/ai-deploy-profiles/v1.1.0/ocr-benchmark.schema.json (a file written for .../v1.0.0/ocr-benchmark.schema.json, without a full pass, still reads); the model card shows its seconds for one page alone, its most pages per minute and its olmOCR-Bench score. A decision benchmark is named <YYYY-MM-DD>-<HHMM>Z-decisionperfbench.yaml and uses the schema https://schemas.onprem.ai/ai-deploy-profiles/v1.0.0/decision-benchmark.schema.json; the model card shows its time for one decision alone, its most decisions per second and its share of correct answers. The deploy profile checker warns about a file that does not match its schema.

The journal

Each tuning session is one file in the profile's journal/ directory, named with its date (2026-11-08-kv-cache-sweep.md). Write the GPU model and count, the engine and its image, the precision of the weights, the KV cache and any drafter with the reason for each that is not FP8, how the probe measured, every round (option, value, result, what you saw), and what to try next. Failed rounds belong in it: they explain why a setting is what it is.

Found a mistake, or is something missing? Suggest an improvement to this page on GitHub.

Platform release 5.10.4, . Source of this page at v5.10.4. This page as Markdown.