Skip to content
Bitpute

Engineering Center

How Bitpute calculates

Every number on this site comes from a formula documented below, with its assumptions stated and its sources cited. This page is generated from the same registry the calculators read, so it cannot drift out of sync with the code that actually runs.

Engine v0.6.1Reviewed July 202633 tests passing

Formula library

Six formulas power every tool on the site.

Model weight memory

verified
weights_bytes = parameters × effective_bpw ÷ 8

Storing N parameters at b bits each takes N × b ÷ 8 bytes. The only subtlety is that quantized formats store metadata (block scales, zero-points) alongside the quantized values, so the effective bits-per-weight is higher than the nominal bit count.

Assumptions

  • Effective bits-per-weight is used, not nominal — GGUF Q4_K_M is ~4.85 bpw, not 4.0, once block scales are counted.
  • GPTQ and AWQ 4-bit assume group size 128, adding ~0.25 bpw of scale/zero metadata.
  • 1 GB means 1 GiB (1024³ bytes), matching nvidia-smi.

Edge cases

  • Mixed-precision checkpoints (e.g. some layers FP16, some INT8) are approximated by their dominant format.
  • Embedding and LM-head tensors are included in the published parameter count.
llama.cpp projectFrantar et al.Lin et al.IEEE / Google Brain

KV cache memory

verified
kv_bytes = 2 × layers × kv_heads × head_dim × context × batch × bytes_per_element

During generation, the model stores the key and value tensors of every previous token so it need not recompute them. The leading 2 covers K and V. Using kv_heads (not attention_heads) makes this correct for grouped-query attention, where several query heads share one KV head.

Assumptions

  • Grouped-query attention is handled by using the model's kv_heads from its public config.json.
  • bytes_per_element is 2 for an FP16 cache, 1 for an FP8/INT8 cache.
  • Architecture values (layers, kv_heads, head_dim) are read from each model's published config.json.

Edge cases

  • Sliding-window attention (e.g. Mistral) can cap the effective context below the requested length; we compute the full-context upper bound.
  • Paged-attention serving stacks (vLLM, TGI) allocate the cache in blocks, so real usage is slightly lower than this contiguous estimate.
Hugging FaceKwon et al. (vLLM)

Runtime overhead

estimated
overhead_bytes = 0.75 GB × gpus + 0.05 × weights_bytes

The CUDA context, framework buffers, dequantization scratch and allocator fragmentation cannot be derived from first principles. We model them as a fixed per-GPU cost plus a small fraction of the weight footprint, informed by published memory-footprint numbers from llama.cpp and vLLM deployments.

Assumptions

  • 0.75 GB per GPU covers the CUDA context and framework buffers.
  • 5% of weights covers dequantization and activation scratch during inference.
  • This term is an engineering estimate, not exact arithmetic — labeled as such throughout the UI.

Edge cases

  • Training (not just inference) adds optimizer state and gradients that this inference-focused term does not model.
  • Consumer cards driving a display lose a further ~0.4 GB, accounted for separately in the GPU fit check.
NVIDIA

Tensor parallelism

verified
per_gpu = (weights + kv) ÷ N + 0.75 GB + (0.05 × weights) ÷ N + comm ; comm = 0.02 × (weights + kv)

Splitting a model across N GPUs shards the weights and KV cache roughly evenly, so per-GPU memory drops close to 1/N. Each GPU still pays its own fixed context cost, and NCCL communication buffers add a small overhead.

Assumptions

  • Weights and KV cache shard evenly across GPUs.
  • Communication buffers are ~2% of the sharded footprint.
  • per_gpu × N reconciles exactly with the reported total (verified by test).

Edge cases

  • When layer count is not divisible by N, pipeline splits are uneven — the UI warns about this.
  • Real tensor-parallel speed depends on interconnect (NVLink vs PCIe); we model memory, not that speed effect.
Kwon et al. (vLLM)NVIDIA

Inference speed (decode)

estimated
tokens_per_sec ≈ (memory_bandwidth × gpus) ÷ model_bytes × MBU ; realistic MBU band 0.28–0.55

Generating one token requires reading every weight from memory once, so decode speed is bounded by memory bandwidth divided by model size. No kernel hits 100% bandwidth utilisation, and attention plus launch overhead take a larger share on big models, so we report a realistic band that brackets observed llama.cpp and vLLM single-stream numbers rather than the theoretical ceiling.

Assumptions

  • Single-stream, decode-phase (not prefill) throughput.
  • The pure roofline is a ceiling; the reported 0.28–0.55 band is the realistic range.
  • Batching many requests raises aggregate throughput well above this per-stream figure.

Edge cases

  • Very small models on very fast GPUs become compute- or launch-bound, where this memory-bound estimate over-predicts.
  • Multi-GPU speed depends on interconnect bandwidth, folded into the band rather than modelled explicitly.
NVIDIAKwon et al. (vLLM)

Cloud cost & local electricity

estimated
cloud/mo = $/gpu-hr × gpus × 730 ; electricity/mo = (TDP × gpus × util ÷ 1000) × 730 × rate

Cloud rental is the per-GPU hourly rate times GPU count times hours in a month. Local electricity is the board power drawn under load (a fraction of TDP) converted to kilowatt-hours and multiplied by the user's rate. Hardware purchase price is not included.

Assumptions

  • 730 hours per month (24 × 365 ÷ 12).
  • Cloud rates are indicative on-demand market ranges with an explicit 'as of' date; GPU prices move weekly.
  • Utilisation defaults to 70% of TDP; the user can adjust it.

Edge cases

  • Spot/preemptible pricing is far lower than the on-demand range shown.
  • Storage, egress and idle time are not included in the hourly figure.
NVIDIA

Full fine-tuning memory (mixed-precision Adam)

verified
bytes ≈ 16 × trainable_params + activations   (2 fp16 weight + 2 fp16 grad + 4 fp32 master + 4 fp32 m + 4 fp32 v)

Full fine-tuning trains every parameter. Mixed-precision AdamW keeps, for each trainable parameter, an fp16 weight, an fp16 gradient, and three fp32 tensors (master copy, momentum, variance) — sixteen bytes in total. This is why full fine-tuning a 7B model needs well over 100 GB and usually spans multiple GPUs.

Assumptions

  • AdamW optimizer with the standard fp32 master-weight + m + v state.
  • Weights and gradients held in fp16/bf16 (2 bytes each).
  • Activation memory is estimated separately and is the least precise term.

Edge cases

  • 8-bit optimizers (bitsandbytes) cut the 12 bytes of fp32 state substantially.
  • ZeRO/FSDP sharding splits weights, gradients and optimizer state across GPUs, lowering per-GPU memory.
Rajbhandari et al. (Microsoft)Hugging Face

LoRA / QLoRA fine-tuning memory

verified
bytes ≈ base_params × base_bpw/8 + 16 × adapter_params + activations   (QLoRA base_bpw ≈ 4.5)

LoRA freezes the base model (weights only, no gradients or optimizer state) and trains small low-rank adapters — typically well under 1% of the parameters. Only those adapters carry the 16-byte Adam state, so the base weights dominate memory. QLoRA additionally stores the frozen base in 4-bit (NF4 ≈ 4.5 bits/weight), which is what lets a 70B model fine-tune on a single 48 GB GPU.

Assumptions

  • Adapter parameter count approximated from architecture (rank × targeted linear-layer dimensions).
  • Adapters trained in bf16 with fp32 Adam state (16 bytes each).
  • QLoRA base stored at ~4.5 effective bits/weight (NF4 with double quantization).

Edge cases

  • Targeting all linear layers (not just attention) multiplies adapter count several-fold.
  • Intermediate (MLP) size is approximated as 3.5× hidden when it is not in the model record, so the trainable-parameter figure is indicative.
Hu et al. (Microsoft)Dettmers et al.

Data sources

Formulas and constants trace to public documentation, datasheets and peer-reviewed papers.

  • KV cache & attention memory in the Transformers library

    Hugging Face

    documentation
  • Efficient Memory Management for LLM Serving with PagedAttention

    Kwon et al. (vLLM)

    paper
  • Quantization formats and effective bits-per-weight

    llama.cpp project

    documentation
  • GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformers

    Frantar et al.

    paper
  • AWQ: Activation-aware Weight Quantization for LLM Compression

    Lin et al.

    paper
  • GPU product datasheets (memory capacity, bandwidth, TDP)

    NVIDIA

    datasheet
  • IEEE 754 floating-point & bfloat16 storage widths

    IEEE / Google Brain

    spec
  • ZeRO: Memory Optimizations Toward Training Trillion Parameter Models (mixed-precision Adam = 16 bytes/param)

    Rajbhandari et al. (Microsoft)

    paper
  • Model training anatomy — memory breakdown for weights, gradients, optimizer and activations

    Hugging Face

    documentation
  • QLoRA: Efficient Finetuning of Quantized LLMs (4-bit NF4 base + low-rank adapters)

    Dettmers et al.

    paper
  • LoRA: Low-Rank Adaptation of Large Language Models

    Hu et al. (Microsoft)

    paper

Framework support

Which serving and local frameworks support the memory-saving features the tools model. Support reflects each project's public documentation.

FrameworkTypePaged attn.FP8 KVTensor parallel
vLLMserving
Text Generation Inferenceserving
llama.cpplocal
ExLlamaV2local
TensorRT-LLMserving

Validation

The engine is checked against known real-world figures on every build. These are the same assertions the committed test suite enforces.

  • Llama 3.1 8B, Q4_K_M weights

    computed 4.53 GiB · reference ≈4.58 GiB (real HF file)

    within tolerance
  • Llama 3.1 8B, FP16 weights

    computed 14.96 GiB · reference ≈14.9 GiB (real HF file)

    within tolerance
  • Llama 3 70B KV cache @ 128k, FP16

    computed 40.0 GiB · reference 40 GiB (published GQA analysis)

    within tolerance
  • Mistral 7B KV cache @ 32k, FP16

    computed 4.0 GiB · reference 4 GiB (exact)

    within tolerance
  • Tensor-parallel per-GPU × N = total

    computed diff < 0.001 GB · reference exact reconciliation

    within tolerance
  • Full fine-tune 7B (mixed-precision Adam)

    computed ≈109 GiB · reference needs 2× A100-80GB (matches practice)

    within tolerance
  • QLoRA 70B fits a single 48 GB GPU

    computed ≈42 GiB · reference QLoRA paper: 65B on one 48 GB GPU

    within tolerance
  • LoRA r=16 attention adapters on 7B

    computed 0.094% trainable · reference ≈0.1% (typical LoRA)

    within tolerance

Limitations

What these tools do not claim to do.

Estimates, not guarantees. Weight and KV-cache memory are exact arithmetic. Runtime overhead, inference speed and cloud cost are engineering estimates — labeled as such everywhere they appear — because they depend on framework, driver, interconnect and market conditions no formula can pin down exactly.

Inference-focused. The memory model targets inference. Training needs optimizer state and gradients that roughly triple or quadruple the footprint; a dedicated fine-tuning tool is on the roadmap.

Prices move. Cloud rental figures are indicative on-demand ranges gathered on a stated date. Verify the live rate with the provider before committing spend; spot pricing is often far lower.

Single-stream speed. The tokens-per-second band describes one generation stream. Production serving with batching and paged attention achieves much higher aggregate throughput.

Release notes

Calculation-engine changelog.

  1. v0.6.1July 2026
    • Report layer: buildReport() produces one normalized, versioned result object every tool can read.
    • Printable engineering report at /report — memory, speed, cost, analysis, recommendations, confidence, references and provenance, savable as PDF.
    • Result-level confidence roll-up (high / medium / estimated) derived from the per-formula confidence tiers.
    • Per-dataset version stamps (GPU / model / quant / cloud DB) for reproducible reports; shared config module removes constant drift across tools.
    • React error boundary on every tool: malformed links and bad state recover gracefully instead of crashing.
    • Workspace refactored from one 411-line file into a state hook plus presentational input/result columns; remaining local constants moved to shared config.
  2. v0.6.0July 2026
    • Fine-Tuning Calculator: training-memory engine for full, LoRA and QLoRA methods.
    • Models optimizer + gradient state (16 bytes/param mixed-precision Adam), adapter parameter counts, and gradient-checkpointed activations.
    • Verified against known results: full 7B ≈109 GiB, QLoRA 70B fits a single 48 GB GPU, LoRA adapters ≈0.1% trainable.
    • New sources registered (ZeRO, QLoRA, LoRA, HF training anatomy); two fine-tuning formulas added to the library.
    • estimateFineTune exported through the @/core SDK; dedicated Vitest coverage added.
  3. v0.5.0July 2026
    • Core SDK: one @/core import surface for every tool (runFullEstimate composition point).
    • Framework database added (vLLM, TGI, llama.cpp, ExLlamaV2, TensorRT-LLM) with feature-support matrix.
    • Engineering Center: methodology, formula library, sources, validation and changelog, generated from the registry.
    • Committed Vitest suite (33 tests) covering engines, share round-trip and SDK composition.
    • Reusable ResultCard component; Compare migrated onto the SDK.
  4. v0.4.0July 2026
    • Shareable workspace URLs with safe fallback for invalid params.
    • Per-metric confidence tiers (verified vs estimated).
    • Recommended-GPU panel (smallest sufficient card first).
    • Compare page declares an overall weighted winner.
  5. v0.3.0July 2026
    • Live interactive hero workspace.
    • GPU Compare tool added.
    • Speed engine recalibrated to a realistic band (roofline shown as a ceiling).
  6. v0.2.0July 2026
    • AI Infrastructure Workspace: VRAM, speed, cost and electricity in one view.
    • Deterministic analysis engine and explain-why breakdown.
    • Roofline speed engine and dated cloud-cost engine added.
  7. v0.1.0July 2026
    • GPU Memory Calculator with GQA-aware KV cache and 13 quantization formats.
    • Design system, homepage, security headers, full schema coverage.