Budgeting for Local LLM Deployment: VRAM Requirements and Break-Even Analysis

    This article provides a comprehensive guide to calculating the budget for locally deploying large language models. It details VRAM requirements, KV cache calculations, and hardware configurations across three performance tiers. By comparing local deployment costs with cloud API pricing, the article establishes a break-even analysis and includes a Python script to automate these calculations, helping developers and engineers make informed hardware purchasing decisions.

    1. Defining Goals and Assumptions

    The budget is determined by your target performance tier. Higher targets demand greater VRAM capacity, memory bandwidth, and interconnect bandwidth, which naturally increases the number of GPUs required and the overall cost. This article defines three tiers:

    1. Functional (Can run): The model can be loaded and outputs normally with no strict speed requirements. Suitable for functional verification and offline batch processing.
    2. Single-user 25 tokens/s: When a single user interacts, the output speed reaches 25 tokens/s.
    3. 10 Concurrency at 25 tokens/s: 10 users use the system simultaneously, with a total throughput of approximately 250 tokens/s.

    The following calculations are based on a set of example assumptions. Before purchasing, replace the “assumption” values with your actual configurations and the “placeholder” values with supplier quotes.

    Parameter Example Value Description
    Total Parameters 2800B (2.8T) B stands for billion parameters; determines the VRAM lower limit
    Active Parameters 40B Determines the computation and memory access per token
    Quantization Format 4-bit elements, sharing one 8-bit scale factor per 32 elements Effective bit width: 4.25 bit
    Layers / KV Heads / Head Dim 60 / 8 / 128 Determines KV cache size
    Hidden Dimension 8192 Determines tensor parallel communication volume
    KV Cache Precision 2 bytes (BF16 or FP16) Counted in bytes
    VRAM per Card / Usable Rate 80 GB / 90% Reserves 10% for fragmentation and communication buffers
    Bandwidth per Card / Derating Factor 2000 GB/s / 0.5 Derating factor must be based on benchmark results
    Power per Card / Avg Utilization 700 W / 60% Card only, excludes other server components
    Comm Delay 20 μs / all-reduce Placeholder; replace with communication test results
    PUE 1.3 Placeholder; replace with actual datacenter value
    Electricity Price $0.8 / kWh Placeholder, not market price
    Total HW Price / Depreciation / Monthly Ops $2,000,000 / 36 months / $10,000 Placeholder, includes server
    Cloud API Price $30 / Million tokens Placeholder, based on total tokens

    Unit convention used in this article: GB refers to decimal 10^9 bytes, which differs from GiB.

    2. VRAM, KV Cache, and Concurrency

    2.1 VRAM Calculated by Total Parameters

    Mixture of Experts (MoE) models have a large total parameter count, but only activate a small fraction of experts per token. While compute depends only on active parameters, VRAM must be calculated based on total parameters, as routing might call any expert at any time. CPU memory, NVMe, and expert sharding (offloading) can hold some weights, but cache misses will read from slower media, making this approach suitable only for offline batch processing, not latency-sensitive interactive scenarios.

    Effective bit width = 4 + 8 ÷ 32 = 4.25 bit. Weight volume = 2800 × 4.25 ÷ 8 = 1487.5 GB. Adding a 20% overhead for non-quantized tensors, metadata, memory alignment, and runtime workspace, the base VRAM is 1785.0 GB. The 20% overhead is an empirical value. After loading an actual model, you should calibrate this factor using framework VRAM statistics or nvidia-smi.

    2.2 KV Cache

    KV cache bytes = 2 × Layers × KV Heads × Head Dim × Bytes × Context Length × Concurrency. Using the table parameters, the KV cache per token is 2 × 60 × 8 × 128 × 2 = 245,760 bytes (~0.25 MB). For an 8192 token context per user, the KV cache is 2.01 GB; for 10 users, it totals 20.13 GB.

    Note: Compressed attention structures like MLA cannot use this formula directly and must be recalculated based on their actual architecture.

    2.3 Card Count and Communication

    Minimum cards = ceil(Total VRAM ÷ (VRAM per Card × Usable Rate)). At concurrency 1, total VRAM is 1787.01 GB, requiring at least 25 cards. At concurrency 10, total VRAM is 1805.13 GB, requiring at least 26 cards. Rounding up to 8 cards per server, both scenarios require 32 cards (4 servers).

    Tensor parallelism performs two all-reduces per layer. Communication per token is 2 × 8192 × 2 bytes × 2 times × 60 layers ≈ 1.97 MB. This figure only represents data volume; actual communication time depends on interconnect bandwidth and per-call latency, which must be tested physically.

    2.4 Speed Limits

    During decoding, each token requires reading the weights corresponding to the active parameters: 40 × 4.25 ÷ 8 = 21.25 GB. Single-step time consists of two parts: VRAM read time, and communication latency (60 layers × 2 times × 20 μs = 2.4 ms).

    Example calculation results:

    • Batch 1: Single step ~3.064 ms, theoretical per-stream max ~326.4 tokens/s.
    • Batch 10: Single step ~9.041 ms, per-stream ~110.6 tokens/s, total ~1106.1 tokens/s.

    These are theoretical maximums, not measured values. Under these assumptions, the speed targets are met on paper, but actual gaps must be confirmed via benchmarking.

    3. Power Consumption and Three-Tier Scenarios

    All three tiers use the same 32-card hardware. This is because the VRAM lower limit determines the card count, and all tiers fall between 25 and 26 cards. The target tier mainly affects concurrency scheduling and whether bandwidth is sufficient, not the raw card count.

    Power calculated per card: 32 cards × 700 W × 60% = 13.44 kW. Over 720 hours, monthly power consumption is 9676.8 kWh. Multiplied by a PUE of 1.3, this becomes 12,579.84 kWh. At $0.8 / kWh, the electricity cost is approximately $10,063.87 / month.

    Local fixed monthly costs are as follows:

    • Depreciation: $2,000,000 ÷ 36 months = $55,555.56 / month
    • Operations: $10,000.00 / month
    • Electricity: $10,063.87 / month
    • Total: $75,619.43 / month

    Note: Electricity is calculated as a fixed cost based on average utilization. If actual load fluctuates significantly, recalculate based on actual power draw.

    Monthly usage and costs for the three tiers. Cloud costs are calculated as monthly total tokens multiplied by $30 / million tokens:

    • Functional (Offline batch, 100M tokens/month): Cloud $3,000.00, Local $75,619.43.
    • Single-user 25 tokens/s (8 hrs/workday, 22 days/month): Monthly usage ~15.84M tokens, Cloud $475.20, Local $75,619.43.
    • 10 Concurrency at 25 tokens/s (8 hrs/workday full load): Monthly usage ~158.4M tokens, Cloud $4,752.00, Local $75,619.43.

    4. Break-Even Analysis and Sensitivity

    Break-even monthly usage = Local fixed monthly cost ÷ Cloud API price × 10^6. Plugging in the numbers: 75,619.43 ÷ 30 × 10^6 ≈ 2.521 billion tokens/month. This equates to a sustained average throughput of ~972.5 tokens/s.

    Only by sustaining close to this throughput long-term can local deployment be cheaper than the cloud. Below this usage volume, the cloud is more cost-effective.

    Sensitivity results (in billions of tokens/month):

    Variable Value Break-Even Usage
    Total HW Price $1,000,000 15.95
    Total HW Price $2,000,000 (Baseline) 25.21
    Total HW Price $3,000,000 34.47
    Cloud API Price $20 / Million tokens 37.81
    Cloud API Price $30 / Million tokens (Baseline) 25.21
    Cloud API Price $45 / Million tokens 16.80

    Depreciation accounts for about 73% of local monthly costs, making hardware quotes and depreciation periods the most sensitive inputs. Before purchasing, obtain real quotes and recalculate this table.

    5. Complete Code and Validation Checklist

    The following code relies only on the Python standard library and can be run directly. The speeds and costs use placeholder values from this article; the output is only for validating the formulas and does not represent any real device performance or quotes.

    1. import math
    2. GB = 1e9 # Decimal GB, 1 GB = 10^9 bytes
    3. HOURS_PER_MONTH = 720 # 30 days * 24 hours
    4. NODE_CARDS = 8 # 8 cards per server
    5. def effective_bits(elem_bits=4, scale_bits=8, block_size=32):
    6. """Average bit width per element (including scale factor)."""
    7. if block_size <= 0:
    8. raise ValueError("block_size must be a positive number")
    9. return elem_bits + scale_bits / block_size
    10. def weight_gb(total_params_b, bits):
    11. """Weight volume (GB). total_params_b unit is billion parameters."""
    12. return total_params_b * bits / 8
    13. def base_memory_gb(weights_gb, overhead_ratio=0.2):
    14. """Base VRAM including non-quantized tensors, metadata, etc."""
    15. return weights_gb * (1 + overhead_ratio)
    16. def kv_cache_gb(layers, kv_heads, head_dim, kv_bytes, context_len, concurrency):
    17. per_token = 2 * layers * kv_heads * head_dim * kv_bytes
    18. return per_token * context_len * concurrency / GB
    19. def min_cards(total_gb, card_gb=80, usable=0.9):
    20. return math.ceil(total_gb / (card_gb * usable))
    21. def round_to_node(cards):
    22. return math.ceil(cards / NODE_CARDS) * NODE_CARDS
    23. def decode_step_ms(active_params_b, bits, cards, bw_gbs, bw_factor,
    24. batch, layers, allreduce_us):
    25. mem_ms = batch * active_params_b * bits / 8 / (cards * bw_gbs * bw_factor) * 1000
    26. comm_ms = layers * 2 * allreduce_us / 1000
    27. return mem_ms + comm_ms
    28. def monthly_local_cost(hw_wan, depr_months, ops, cards, card_w, util, pue, power_price):
    29. depr = hw_wan * 1e4 / depr_months
    30. kwh = cards * card_w * util / 1000 * HOURS_PER_MONTH * pue
    31. power = kwh * power_price
    32. return depr + ops + power, depr, power
    33. def breakeven_tokens(monthly_fixed, cloud_price_per_m):
    34. return monthly_fixed / cloud_price_per_m * 1e6
    35. def main():
    36. total_b, active_b = 2800, 40
    37. layers, kv_heads, head_dim, ctx = 60, 8, 128, 8192
    38. card_gb, usable, bw_gbs, bw_factor = 80, 0.9, 2000, 0.5
    39. card_w, util, pue, power_price = 700, 0.6, 1.3, 0.8
    40. hw_wan, depr_months, ops = 200, 36, 10000
    41. cloud_price = 30
    42. deploy_cards = 32
    43. # Input validation
    44. assert 0 < util <= 1 and 0 < usable <= 1
    45. assert total_b >= active_b, "Active parameters cannot be greater than total parameters"
    46. # VRAM and Concurrency
    47. bits = effective_bits()
    48. w = weight_gb(total_b, bits)
    49. base = base_memory_gb(w)
    50. print(f"Effective bits: {bits:.2f} bit")
    51. print(f"Weight volume: {w:.1f} GB")
    52. print(f"Base VRAM: {base:.1f} GB")
    53. assert abs(w - 1487.5) < 1e-6 # Validate example values
    54. for conc in (1, 10):
    55. kv = kv_cache_gb(layers, kv_heads, head_dim, 2, ctx, conc)
    56. total = base + kv
    57. cards = min_cards(total, card_gb, usable)
    58. print(f"Concurrency {conc}: KV {kv:.2f} GB, Total VRAM {total:.2f} GB, "
    59. f"Min {cards} cards, Rounded {round_to_node(cards)} cards")
    60. # Speed limits (theoretical, replace with benchmark)
    61. for batch in (1, 10):
    62. step = decode_step_ms(active_b, bits, deploy_cards, bw_gbs, bw_factor,
    63. batch, layers, allreduce_us=20)
    64. per_user = 1000 / step
    65. print(f"batch {batch}: Single step {step:.3f} ms, Per-stream {per_user:.1f} tok/s, "
    66. f"Total {per_user * batch:.1f} tok/s")
    67. # Cost and Break-even
    68. fixed, depr, power = monthly_local_cost(
    69. hw_wan, depr_months, ops, deploy_cards, card_w, util, pue, power_price)
    70. print(f"Depreciation {depr:.2f} / month, Ops {ops:.2f} / month, Power {power:.2f} / month")
    71. print(f"Total Local Fixed Cost: {fixed:.2f} / month")
    72. be = breakeven_tokens(fixed, cloud_price)
    73. print(f"Break-even monthly usage: {be / 1e8:.2f} billion tokens")
    74. print(f"Equivalent sustained throughput: {be / (HOURS_PER_MONTH * 3600):.1f} tok/s")
    75. scenarios = [
    76. ("Offline batch (100M tokens/month)", 1e8),
    77. ("Single-user 25 tok/s (8 hrs/workday, 22 days)", 25 * 3600 * 8 * 22),
    78. ("10 Concurrency x25 tok/s (8 hrs/workday full load)", 250 * 3600 * 8 * 22),
    79. ]
    80. for name, tokens in scenarios:
    81. cloud = tokens / 1e6 * cloud_price
    82. print(f"{name}: Cloud {cloud:.2f}, Local {fixed:.2f}")
    83. # Sensitivity (Unit: billion tokens/month)
    84. print("Sensitivity (billion tokens/month)")
    85. for hw in (100, 200, 300):
    86. f, _, _ = monthly_local_cost(
    87. hw, depr_months, ops, deploy_cards, card_w, util, pue, power_price)
    88. print(f"Hardware ${hw}00,000: {breakeven_tokens(f, cloud_price) / 1e8:.2f}")
    89. for price in (20, 30, 45):
    90. print(f"Cloud ${price} / Million tokens: {breakeven_tokens(fixed, price) / 1e8:.2f}")
    91. if __name__ == "__main__":
    92. main()

    Example output after running:

    1. Effective bits: 4.25 bit
    2. Weight volume: 1487.5 GB
    3. Base VRAM: 1785.0 GB
    4. Concurrency 1: KV 2.01 GB, Total VRAM 1787.01 GB, Min 25 cards, Rounded 32 cards
    5. Concurrency 10: KV 20.13 GB, Total VRAM 1805.13 GB, Min 26 cards, Rounded 32 cards
    6. batch 1: Single step 3.064 ms, Per-stream 326.4 tok/s, Total 326.4 tok/s
    7. batch 10: Single step 9.041 ms, Per-stream 110.6 tok/s, Total 1106.1 tok/s
    8. Depreciation 55555.56 / month, Ops 10000.00 / month, Power 10063.87 / month
    9. Total Local Fixed Cost: 75619.43 / month
    10. Break-even monthly usage: 25.21 billion tokens
    11. Equivalent sustained throughput: 972.5 tok/s
    12. Offline batch (100M tokens/month): Cloud 3000.00, Local 75619.43
    13. Single-user 25 tok/s (8 hrs/workday, 22 days): Cloud 475.20, Local 75619.43
    14. 10 Concurrency x25 tok/s (8 hrs/workday full load): Cloud 4752.00, Local 75619.43
    15. Sensitivity (billion tokens/month)
    16. Hardware $1000,000: 15.95
    17. Hardware $2000,000: 25.21
    18. Hardware $3000,000: 34.47
    19. Cloud $20 / Million tokens: 37.81
    20. Cloud $30 / Million tokens: 25.21
    21. Cloud $45 / Million tokens: 16.80

    6. Pre-Purchase Checklist

    1. Load the actual model once and measure true VRAM using framework stats or nvidia-smi to calibrate the 20% overhead factor.
    2. Replace the 0.5 bandwidth derating factor with benchmark results, and measure actual communication latency to replace the 20 μs placeholder.
    3. Request formal tax-inclusive or exclusive quotes from suppliers, noting the quote date and region.
    4. Ensure PUE and electricity prices are taken from actual datacenter billing.
    5. Estimate monthly token volume using real business logs and plug them into the break-even table instead of using example loads.
    6. Confirm the selected model uses standard MHA or GQA architecture. If it uses MLA or similar, recalculate the KV cache.

    All prices, power, and performance figures in this article are examples. They must be replaced with measured values and quotes before making any procurement decisions.