Measure the GPU memory a model really holds and set its two bookings: check the profile, make sure it states an engine booking, load it, benchmark it, read its peak memory and the engine's start-up log, work out the parts (weights, drafters, CUDA graphs, overhead, KV cache and its tokens), compare the peak with the hardware booking, and write runtime.engine_memory_booking_bytes_per_device and runtime.measured_gpu_memory_bytes_per_device. Use when the operator asks where a model's GPU memory g...
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Measure Gpu Memory?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/onprem-ai-measure-gpu-memory)
---
name: measure-gpu-memory
description: >-
Measure the GPU memory a model really holds and set its two bookings: check the
profile, make sure it states an engine booking, load it, benchmark it, read its peak
memory and the engine's start-up log, work out the parts (weights, drafters, CUDA
graphs, overhead, KV cache and its tokens), compare the peak with the hardware
booking, and write runtime.engine_memory_booking_bytes_per_device and
runtime.measured_gpu_memory_bytes_per_device. Use when the operator asks where a
model's GPU memory goes, whether its booking is right, what its KV cache holds, or
when the profile check hints that the measurement or the engine booking is missing,
or warns about the engine's memory.
---
What each part means, the two bookings, where the engines print the numbers and how to
work them out is in docs:guides/measuring-gpu-memory.md; the benchmark's workloads and
figures are in docs:guides/tuning-model-performance.md. Read both before you start.
Before you call an operation the first time, read its arguments with
`describe_operation`.
## 1. Check the profile, and agree on the plan
- Check the profile first (`model_catalog_read`, operation `deploy_profiles_check`) and
read every finding about memory: they say what is missing or wrong before you
measure. The checker is your feedback all along: check again after every change you
write, and before you report.
- Find the profile and its catalog (`model_catalog_read`, operation `catalogs_files_read`):
its `ai-deploy.yaml` (the hardware booking in `hardware.gpu.memory_bytes_per_device`,
the engine booking in `runtime.engine_memory_booking_bytes_per_device`, the engine in
`runtime.engine`) and its latest `journal/` entries.
- **The engine booking decides what the engine is told.** For vLLM and PyTorch engines
the deploy writes the engine's memory share (`--gpu-memory-utilization`,
`per_process_memory_fraction`) from the engine booking and the GPU's memory; the value
in `compose.yaml` is replaced. Keep that setting in `compose.yaml`, set to the value
the hint `engine.gpu-memory-share-written` names when it appears: never remove it. The
deploy replaces only a setting that is there; without one the engine has no limit (the
warning `engine.gpu-memory-limit`). A profile **without** an engine booking tells the engine
the whole hardware booking: the engine's overshoot under load then goes above the
hardware booking. So before you measure, the profile needs an engine booking below the
hardware booking. When it has none, propose one: the amount the engine ran with so far
(the `Desired GPU memory utilization is (…, … GiB)` line of an earlier deployment log,
or the journal's figure), and keep the hardware booking. Write it, with `$schema` at
the version that defines it, into the draft or copy you measure, so the measurement is
of the profile as it will run. SGLang's `--mem-fraction-static` is used as written:
there the engine booking is checked against it (`replica.engine-gpu-memory`).
- The measurement needs a replica of exactly this profile that no client uses while it
is benchmarked. Propose a test service to the operator: the draft or copy, its own
model name (so the API gateway sends it no client's request), its GPUs (the product
and count `hardware.gpu` names), and what must move to free them. Wait for the
confirmation. Never change the production service without it, and never publish.
## 2. Load and benchmark
- Deploy the test service (`inference_services_change`, operation `deploy`) and wait
until its replica is ready (`wait_seconds` between checks); note the loading time.
- Choose the load, and say which in the plan:
- **Memory only**, when only the bookings change (an engine booking set, a hardware
booking checked): `replicas_benchmark_start` with `workloads`
`["max-decode/1.1.0"]`. Many long answers at once drive the peak; the other
workloads add nothing to it. Stop the run (`inference_services_change`, operation
`replicas_benchmark_cancel`) once its level has reached concurrency 32 or the
profile's highest (`--max-num-seqs`, `--max-running-requests`), whichever is lower,
and the peak has not grown for 2 minutes after that; at the latest after 15
minutes. The engine keeps memory it took, so the peak does not fall back.
- **Benchmark and memory**, when the model card's figures change too (the compose
file changed, or the operator asks for a benchmark): leave `workloads` out, so every
workload runs, and let it end on its own; it takes minutes to an hour.
- Start it (`inference_services_change`, operation `replicas_benchmark_start`, with
`measure_while_serving_clients` false: the test service serves no client). Read the
run (`inference_services_read`, operation `replicas_benchmark_get`) while it runs:
its finished levels say which concurrency it has reached.
- Read the peak in one call (`time_series_read`, operation `query`), with a window
that covers the run: `max_over_time(sum by (inference_service_replica_id, gpu_uuid)
(onprem_ai_inference_service_replica_gpu_vram_used_bytes{inference_service_replica_id="<id>"})[2h:])`.
The sum is the replica's processes on one GPU at one time (two containers on a GPU
are two processes); never add up each process's own highest value. Only when it
answers no series, sample instead: `inference_services_read`, operation `get`, every
half minute while the run lasts, its GPU allocations' `vram_used_bytes`, and keep the
highest value.
- A run that ends `failed` says why in `failure`; fix the cause and run it again. After
a full run, keep its `benchmark_file` and `benchmark_file_path`: they are written down
with the measurement. A memory-only run that you stopped writes no benchmark file;
write in the journal how it ended (the highest level reached, how long the peak held).
## 3. Find the numbers
- The replica's deployment log: `logs_read`, operation `list`, with its
`inference_service_replica_id`. Read it with operation `read` and a `pattern`, like
grep: start with the words the guide lists for the engine, with `ignore_case` and a
few `context_lines`. When a word finds nothing, try another; engines change their
wording. Read a long log in parts with `after_line_number`, never whole.
- For a drafter the engine counts inside the weights, the drafter's weight files: the
profile's `model.weights` entry for it.
## 4. Compare and work out the block
- Every part in bytes, the parts that do not apply left out, `runtime_overhead` the
peak minus the other parts, as the guide says. The parts add up to the peak.
- The engine's budget from the log (`Desired GPU memory utilization is (…, … GiB)`)
must be the engine booking, within a hundredth of the GPU. When it is not, the
measurement is of another amount: find why (the check names it) before you go on.
- Peak at or below the hardware booking: write the block.
- Peak above it: the hardware booking is too small. Propose raising it above the peak
with a margin, with the numbers, and write the block with the raised booking.
- The engine's budget from the log above the hardware booking: stop and report it. The
engine is told more than the replica may hold.
## 5. Write it
- A catalog that follows an upstream takes no changes: duplicate the profile into a
catalog without an upstream first (`model_catalog_change`, operation
`catalogs_files_duplicate_deploy_profile`), or create a draft
(`model_catalog_change`, operation `catalogs_drafts_create`).
- Write `runtime.engine_memory_booking_bytes_per_device` (when you set it in step 1),
`runtime.measured_gpu_memory_bytes_per_device` and
`runtime.measured_kv_cache_tokens_per_replica` into `ai-deploy.yaml`, with `$schema`
set to the format version that defines them (the guide names it), and a journal
entry (`journal/<date>-gpu-memory.md`): the replica, the engine version, the loading
time, the benchmark's answer, each log line used, the peak, the headroom and the
overshoot. Set the model name back.
- After a full run, write its `benchmark_file` as it is, at its `benchmark_file_path` under the
profile, with one line added at its end: `journal: journal/<date>-gpu-memory.md`. It is
the benchmark the measurement was taken under; the model card reads its figures.
Use `benchmark_file_path` as the run answers it, never a name of your own: it is
`benchmarks/<YYYY-MM-DD>-<HHMM>Z-llmperfbench.yaml`, the UTC date, hour and minute the
run started (`2026-11-10-0428Z-llmperfbench.yaml` for a run started 04:28 UTC), so the
runs of one day sort in the order they ran and the card shows the newest. Never replace
another run's file. Only when a file of that exact name is already there (two runs
started in the same minute) add a short id of your own before `.yaml`.
- Commit the profile file, the journal entry and the benchmark file together, in one
commit (`model_catalog_change`, operation `catalogs_files_commit`, with the
`base_model_catalog_revision_id` that `catalogs_files_list` answered; a 409 means the
catalog moved: read it again and redo the commit on top).
- Check the profile again (`model_catalog_read`, operation `deploy_profiles_check`).
The memory rules must pass: no warning from `runtime.measured-gpu-memory-sum`,
`runtime.engine-memory-booking`, `replica.engine-gpu-memory`,
`engine.gpu-memory-share-computed`, `engine.kv-cache-size-fixed` or
`engine.gpu-memory-limit`, and no hint `engine.gpu-memory-share-written` (when it
appears, set the setting in `compose.yaml` to the value it names). A finding left:
propose the fix to the operator, or report why it stays. A change the operator has
not confirmed is not committed.
- Undeploy the test service (`inference_services_change`, operation `undeploy`;
confirm first: it is destructive), and give back what you moved for it.
- Report to the operator: the parts in GiB, the peak against both bookings, the KV
cache tokens, and the draft to publish or the pull request to open. Publishing is the
operator's decision.