Running a 405B Model on a 4GB GPU: Calculate Inference Time First
Running a 405-billion-parameter model with just 4GB of GPU memory does not necessarily make it practical for interactive use. This article explains how weight transfers, effective bandwidth, cache hit rates, and output length determine inference time, and provides a four-step evaluation process covering latency, throughput, memory usage, quality, and stability.
When a headline claims that a “405B-parameter model runs with 4GB of VRAM,” the most useful question is not simply whether the number is genuine. It is what kind of end-to-end experience that number represents.
Peak GPU memory is only one constraint on whether a model can run. It does not establish acceptable time to first token, sufficient generation throughput, or freedom from bottlenecks in system memory, storage bandwidth, power, and cooling.
Confusing “can run” with “is usable” is one of the most common mistakes in discussions of local inference for very large models.
1. Peak GPU Memory Is Only One Constraint
A 405-billion-parameter model requires approximately 810GB to store its weights in FP16. Even at 4-bit precision, its weights remain on the order of 200GB.
A 4GB GPU clearly cannot hold all those weights simultaneously. Low-VRAM inference therefore typically relies on techniques such as layer-by-layer loading, weight offloading, quantization, sparse activation, or expert routing. Only the layers, experts, or caches needed for the current computation remain in GPU memory. Other weights reside in system RAM or slower storage and are transferred as needed.
These approaches are technically feasible, but they shift the bottleneck from memory capacity to data movement.
Autoregressive decoding is sequential. Generating each token may require reloading some weights or activating the relevant experts. End-to-end time can be roughly decomposed as:
T_total ≈ T_prefill + N_out × T_decode + T_schedule + T_io
Here:
T_prefillis the time spent processing the input prompt.T_decodeis the per-token decoding computation time.N_outis the number of output tokens.T_scheduleis scheduling overhead.T_iois the overhead of moving weights and the KV cache between GPU memory, system memory, and storage.
Reducing peak GPU memory often increases T_io. If effective bandwidth is insufficient, decoding becomes I/O-bound rather than compute-bound.
2. Six Metrics Beyond Peak VRAM
A low-VRAM inference approach should be evaluated against at least six categories of metrics, not just its peak GPU memory footprint.
Peak GPU and system memory usage
Low VRAM usage may simply transfer the burden to host RAM. Insufficient system memory can trigger paging and further increase latency.Storage capacity and random-read performance
When weights reside on slower storage, both sequential bandwidth and random-read latency affect loading efficiency.Time to first token
Interactive usability begins with how long the user waits for the first token. Prefill and initial weight loading often account for a substantial share of that wait.Decoding throughput
Tokens generated per second directly determine how long a complete response takes.P99 latency and stability
Average latency may look acceptable while cache misses, thermal throttling, or background tasks produce substantial tail-latency spikes.Quality regression, power, and cooling
Quantization, offloading, and cache strategies need to be checked for numerical stability. Sustained laptop workloads can also trigger throttling.
Throughput and latency must be treated separately. Batching can amortize weight-transfer costs and improve offline throughput. Interactive workloads, however, often involve individual requests, low concurrency, and strict latency requirements, leaving less room for batching benefits.
Using offline throughput to demonstrate interactive usability is another form of metric mismatch.
3. The Core Calculation: Bytes Transferred per Token × Output Length
Let r be the fraction of model parameters activated for a token and b the quantization bit width. The approximate volume of weights participating in computation per token is:
bytes_active ≈ params × r × b / 8
If the cache hit rate is h, the bytes that must be transferred from a slower memory or storage tier per token can be approximated as:
bytes_per_token ≈ bytes_active × (1 - h)
The total transfer volume is then:
total_bytes ≈ bytes_per_token × N_out
Dividing by effective bandwidth gives an estimate of the I/O time floor:
T_io ≈ total_bytes / BW_effective
This explains a critical point: a model can occupy only a few gigabytes of GPU memory while transferring tens—or even hundreds—of terabytes of weights over the course of a 500-word response.
At an effective bandwidth of only a few gigabytes per second, generation can take hours or even tens of hours. Words and tokens are not interchangeable, so the calculation must use the actual output token count.
The original discussion contrasted one approach that reduced VRAM usage to a few gigabytes but reportedly needed tens of hours to generate 500 words with another that completed the task in tens of minutes on similar hardware. That comparison is fundamentally about effective bandwidth, cache hits, and scheduling—not just GPU memory usage.
The following pseudocode illustrates the estimate. All inputs must be replaced with measured values; the result should not be presented as a product performance claim.
function estimate_time(params, active_ratio, bits, output_tokens,cache_hit, effective_bw, compute_tps):bytes_active = params * active_ratio * bits / 8bytes_per_token = bytes_active * (1 - cache_hit)total_bytes = bytes_per_token * output_tokenst_io = total_bytes / effective_bwt_compute = output_tokens / compute_tpsreturn max(t_io, t_compute), t_io, t_compute
The maximum of I/O time and compute time is a simplified lower-bound estimate, not a complete end-to-end prediction.
Start by measuring effective_bw under sequential reads, random reads, cache hits, and cache misses. Then measure compute_tps. Finally, run end-to-end tests using realistic output lengths.
Substituting theoretical bandwidth for measured effective bandwidth can substantially overstate usability.
4. Why Low-VRAM Inference Can Be Feasible but Impractical
The engineering value of low-VRAM inference is that it lowers the hardware barrier to loading very large models. It can suit offline tasks, low-QPS batch workloads, and privacy-sensitive applications that tolerate long delays. Quantization, sparse expert activation, and layered offloading can also reduce resident resource requirements.
Interactive use is less forgiving. The sequential nature of autoregressive decoding amplifies I/O bottlenecks. GPU memory bandwidth is typically much higher than host-memory or external-bus bandwidth. When weights must repeatedly move between memory tiers, compute units wait for data.
Laptops also face power and cooling limits. Sustained workloads may cause throttling, further extending tail latency.
These are three distinct levels of capability:
- The model can load.
- The model can generate output.
- The model can support interactive use.
Each requires separate validation.
5. A Four-Step Engineering Evaluation
Step 1: Define the SLOs
Specify time to first token, total time for a 500-word response, P99 latency, concurrency, and the quality baseline.
Step 2: Build a Byte Budget
Account for parameter count, active parameter fraction, quantization bit width, KV cache requirements, and cache hit rate.
Step 3: Measure Bandwidth and Decoding Throughput
Test cold starts, warm caches, long contexts, and low-battery or high-load conditions. Measure effective bandwidth and actual token-generation throughput rather than relying on hardware specifications.
Step 4: Test Quality and Stability
Run quality regression tests and sustained-load tests while keeping the model version, quantization configuration, and runtime environment fixed.
6. Choose the Inference Path for the Workload
For local interactive use, prioritize a model size that can remain resident in GPU memory or high-bandwidth memory. Where appropriate, use distillation, routing to smaller models, and cache warming to reduce latency.
For offline batch processing, layered offloading and batching may be acceptable because throughput matters more than immediate response time.
For elastic cloud workloads, resource scheduling can combine container-platform scaling, object storage for model weights, and monitoring and alerts for end-to-end latency and resource utilization. These general service categories are also relevant when evaluating Baidu AI Cloud; specific interfaces, pricing, and regional availability should be verified in the official documentation.
A hybrid architecture is another option: perform preprocessing and lightweight inference locally, and send heavier workloads to elastic resources. This avoids forcing a low-VRAM device to support an interactive workload it cannot handle efficiently.
Conclusion
Running a very large model with little GPU memory is not inherently misleading. Treating peak VRAM as proof of usability is.
The real inference-time budget depends on bytes transferred per token, effective bandwidth, cache hit rate, output length, and sustained thermal performance. Developers should evaluate peak VRAM, time to first token, decoding throughput, P99 latency, and quality regression together—not let a single memory figure determine the conclusion.
