Multi-GPU Deployment for Large Multimodal Models: VRAM Budgeting and Rollout Steps
A practical guide to deploying a large multimodal model of about 320 billion parameters on four 32 GiB accelerators. It covers model components, runtime and branch selection, quantization and weight-size estimation, VRAM and KV-cache planning, pipeline versus tensor parallelism, validation, and rollback checks.
1. Background and Goals
Calling cloud APIs is the fastest way to access large models. However, local deployment is more suitable when data cannot be sent externally, offline operation is required, or custom inference parameters are needed. The cost of local deployment is hardware investment and engineering complexity, and both increase with model size.
Large multimodal models bring three types of challenges.
- Large weight size. Even after quantization, weights may fill all VRAM on a single node.
- More complex structure. In addition to the language backbone, a vision encoder and a projection module are required, and the two must be used together.
- A still-maturing inference ecosystem. New architectures are often supported first in development branches, while mainline release compatibility lags.
This article uses a multimodal model with about 320 billion parameters as an example, deployed on four 32 GiB accelerator cards. After reading, you should be able to independently complete a pre-deployment VRAM budget and know how to verify deployment results.
The scope of this article is text question answering and image understanding. Video input depends on frame sampling and temporal modeling, and most local inference pipelines do not yet fully support it, so it is outside the test scope. If the business must process video, you can first extract a small number of key frames and perform approximate question answering by treating them as multi-image input. This cannot guarantee that temporal information is used correctly, and the results need separate evaluation.
2. Anatomy of a Multimodal Model
A multimodal model usually consists of three parts.
The language backbone handles instruction understanding, reasoning, and text generation, and is the main source of VRAM usage.
The vision encoder splits an image into tiles and extracts features.
The projection module maps visual features into the embedding space of the language backbone so that they can be read by the language backbone like text tokens.
At deployment time, the language backbone and projection module are usually stored in two separate files. The projection module has few parameters and is often saved in FP16 (half-precision floating point). This type of module is sensitive to numerical error, and image understanding quality tends to degrade after quantization, so it is recommended to keep FP16 precision. It occupies only about 1 GiB, so the benefit of compression is small.
Both files must come from the same training artifact. When versions do not match, the model may output gibberish or completely ignore the image. The following table can be used for troubleshooting.
| Symptom | Common cause | Check method |
|---|---|---|
| Gibberish or meaningless text output | Projection module and language backbone versions are inconsistent | Check the source and hashes of both files |
| Answer unrelated to image content | Projection module not loaded correctly, or image preprocessing parameters differ | Check load logs for missing weight warnings and verify image tile size |
| Text-only requests work, image requests fail | Vision branch not enabled at runtime | Check launch parameters and the framework’s support notes for multimodal input |
3. Runtime and Branch Selection
When selecting a runtime, compare the following dimensions.
| Dimension | Focus |
|---|---|
| Architecture support | Whether the model structure is implemented; whether to use mainline release or development branch |
| Hardware backend | Whether the compute backend for the target accelerator vendor is supported |
| Multimodal capability | Whether the visual projection pipeline is integrated and which input types are supported |
| Quantization ecosystem | Supported bit widths and whether mixed-precision weights are supported |
| Reproducibility | Whether code version and commit record can be pinned |
There are two practical lessons.
First, support for new models often appears first in development branches. If the mainline release reports that the architecture is unsupported, read the development branch notes first before deciding whether to adopt it.
Second, development branches change frequently. Before deployment, you must record the exact commit ID and keep rollback-capable build artifacts.
After deployment, verify item by item with the following checklist.
- Load logs: Confirm that the architecture is correctly recognized and that there are no missing weights or shape mismatch errors. Record load time and per-card VRAM usage.
- Version record: Save the code commit ID, the hash of the language backbone file (for example, SHA-256), and the hash of the projection module file.
- Text smoke test: Use a fixed question, such as “Explain what a hash table is in one sentence,” and confirm that the answer is fluent and as expected.
- Image smoke test: Use an image with a known answer and ask about the color and number of objects in the image. Then use a completely unrelated image and ask again, confirming that the two answers differ. This step detects whether the vision branch is actually active.
- Stress test: Send requests continuously for a period at the target context length and concurrency, and observe whether peak VRAM remains stable.
A rollback path must be prepared in advance. Keep the previous working build artifacts, launch configuration, and model file list. If a new version has OOM (an out-of-memory process crash) or abnormal image capability, stop the service, switch back to the previous version, and compare the load logs of both versions. Do not overwrite old files directly in production.
4. Quantization Strategy and Weight Size
Quantization is the process of representing weights with fewer bits. Weight size can be estimated with the following formula.
Weight bytes ≈ parameter count × average bits per parameter ÷ 8
This article uses two unit systems, so they must be distinguished first.
- GB is a decimal unit: 1 GB = 10^9 bytes. Most vendor nominal capacities and file-size tools use this convention.
- GiB is a binary unit: 1 GiB = 2^30 bytes, approximately 1.0737 GB. The VRAM budget and KV-cache formula in this article use GiB.
Taking 100B parameters as an example, the theoretical sizes are as follows.
| Precision | Bits per parameter | Theoretical size (GB) | Theoretical size (GiB) |
|---|---|---|---|
| FP16 | 16 | 200 | about 186.3 |
| 8-bit | 8 | 100 | about 93.1 |
| 4-bit | 4 | 50 | about 46.6 |
| 2-bit | 2 | 25 | about 23.3 |
Actual quantized files also include scale factors, group metadata, and some layers retained at higher precision, so the average bits per parameter is higher than the nominal value. Budget based on actual file size; theoretical values are only for initial screening.
Dynamic quantization is a common approach. It allocates different bit widths according to each layer’s sensitivity to precision. Key layers such as attention and embeddings retain higher precision, while more redundant feed-forward layers use lower precision. The 2-bit setting offers the highest compression ratio but also the most obvious accuracy loss, and it must be evaluated on your own tasks before deciding whether to use it.
In the example in this article, the model with about 320 billion parameters uses dynamic quantization at an average of about 2.7 bits. This assumes that the average already includes the overhead of scale factors and retained layers. At this point, the weights are about 108 GB, or about 100.6 GiB. The projection module is about 1.13 GB, or about 1.05 GiB. The total is about 101.6 GiB. These numbers come from the configuration assumed in this article; actual projects should use the file size output by the quantization tool.
5. VRAM Capacity Planning
Weights are only part of VRAM usage. Complete VRAM usage consists of the following parts.
- Model weights
- KV cache, which grows with context length and concurrency
- Activations and intermediate computation buffers
- Framework and driver runtime overhead
- VRAM fragmentation
In the example, each card has 32 GiB, and four cards total 128 GiB. After deducting the weights and projection module, about 26.4 GiB remains. This space must simultaneously hold the KV cache, intermediate results, and runtime overhead. Actual available capacity must also deduct driver and framework usage, so the headroom is not generous. The final judgment should be based on measurements after deployment.
If the card specification is labeled “32 GB,” convert it from decimal first. 32 GB is approximately 29.8 GiB, and four cards total about 119.2 GiB. After deducting the weights, about 17.6 GiB remains. Only one unit system can be used in the budget; otherwise the result will be off by about 7%.
The KV-cache estimation code is as follows. Parameters must be read from the target model’s configuration file (usually config.json).
def estimate_kv_cache_gib(num_layers: int, # Number of attention layers, corresponding to num_hidden_layersnum_kv_heads: int, # Number of KV heads, corresponding to num_key_value_headshead_dim: int, # Dimension of a single attention headcontext_len: int, # Context length (number of tokens)concurrency: int, # Number of simultaneously processed requestsbytes_per_elem: int, # Bytes per cache element: 2 for FP16, 1 for FP8) -> float:# The factor 2 corresponds to the two caches for Key and Valuetotal_bytes = (2 * num_layers * num_kv_heads * head_dim* context_len * concurrency * bytes_per_elem)return total_bytes / (1024 ** 3)
Several notes follow.
- If head_dim is not directly provided in the configuration, it can be approximated by dividing hidden_size by num_attention_heads. However, confirm whether the model has a special design.
- Grouped-query attention (GQA) lets multiple query heads share a set of KV heads, so num_kv_heads is much smaller than the attention head count, and the KV cache is significantly reduced. Multi-query attention (MQA) is the extreme case where num_kv_heads is 1.
- Cache precision also affects the result. Changing the KV cache from FP16 to FP8 halves the cache size, but you must confirm whether the inference framework supports it and evaluate accuracy changes.
Assume a model with 64 layers, 8 KV heads, head_dim of 128, context length of 8192, concurrency of 4, and FP16 cache. Substituting into the formula gives about 8.0 GiB. This is a hypothetical value set to illustrate the calculation process and does not represent the real configuration of the model in this article.
Planning can follow this order.
- Determine the weight size and projection module size, using GiB consistently.
- Determine the target context length and concurrency, and calculate the KV cache.
- Reserve runtime and fragmentation headroom for each card. A common starting point is to reserve 5% to 10% of total VRAM; the exact ratio depends on the framework and concurrency and should be adjusted based on stress-test data. At 10%, four cards reserve about 12.8 GiB in total.
- If the result exceeds capacity, consider reducing context length, reducing concurrency, using lower bit width, or adding cards.
In the example in this article, the available space after reservation is about 26.4 minus 12.8, or about 13.6 GiB. The hypothetical 8 GiB KV cache can fit, but the headroom is small. If concurrency increases to 8, the KV cache doubles to about 16 GiB, which exceeds the budget.
6. Multi-GPU Parallelism
Two common splitting methods are used in multi-GPU deployment.
Pipeline parallelism splits the model by layer. Each card handles a contiguous set of layers, and data is passed sequentially between cards. It has lower requirements for interconnect bandwidth and is suitable for scenarios where a single card cannot fit the model but inter-card connections are weak. The cost is that a single request must pass through each card in sequence, so throughput improvement is limited and inter-card transfer also adds latency.
Tensor parallelism splits matrix operations within a single layer across multiple cards for simultaneous execution. It can use multi-GPU parallel computation, but each layer requires synchronization, so it has high requirements for inter-card bandwidth and latency.
| Comparison item | Pipeline parallelism | Tensor parallelism |
|---|---|---|
| Split object | Contiguous layers | Matrices within a single layer |
| Bandwidth requirement | Lower | Higher |
| Latency impact | Transfer overhead at each stage | Synchronization required for each layer |
| Single-request throughput | Limited improvement | Usually better, depending on interconnect |
| Common use case | Weak inter-card links, or capacity priority | High-speed inter-card interconnect, low latency target |
The decision can be made in two steps. First, determine whether the inter-card interconnect is a high-speed link. If not, prioritize pipeline parallelism. If it is, decide whether to use tensor parallelism based on the latency target. The two can also be combined, for example, four cards divided into two groups, with tensor parallelism within each group and pipeline parallelism between groups.
Regardless of the method, splitting must follow these constraints.
First, the tensor parallel degree must evenly divide the attention head count and KV head count. Otherwise, some heads cannot be evenly distributed and deployment will fail directly.
Second, for pipeline splitting, the number of layers per card should be as equal as possible, with a difference of no more than 1 layer. If model layers vary in size, allocate layers by actual bytes used per card, not just by layer count.
Third, the vision encoder and projection module are usually placed on one card. Confirm the remaining space on that card to avoid it experiencing OOM before the other cards.
Fourth, the product of parallel degrees should equal the actual number of cards used. For example, four cards can be configured as 2×2 or 4×1. If configured as 3×1, one card will be idle.
After splitting, if OOM occurs, troubleshoot in the following order.
- Use vendor tools to check per-card peak VRAM and identify which card fills first.
- Check whether a preallocation strategy is occupying too much VRAM. Some frameworks reserve a fixed percentage at startup.
- Reduce context length or concurrency and observe changes in the peak.
- Check whether the requested image resolution or tile count exceeds expectations. Image tokens also consume KV cache.
- If it is still unstable after adjustments, recalculate using the formula in Section 5 and follow the rollback path in Section 3 to switch back to the previous version.
7. Pre-Deployment Checklist
- All VRAM budgets use GiB, and the basis for converting card specifications is recorded.
- Weight and projection module sizes come from actual files, not theoretical values.
- KV cache is calculated for the target context and concurrency, and all parameters are confirmed to come from the target model’s configuration file.
- The reserve for each card has been determined based on stress-test data, and the remaining space is greater than the estimated KV cache and activations.
- The parallel degree satisfies divisibility constraints, and VRAM usage across cards is close.
- The code commit ID, model file hashes, and rollback artifacts have all been saved.
- Text and image smoke tests pass, and the unrelated-image control test returns a different answer.
