This is a great question that highlights the unique memory considerations of Mixture-of-Experts (MoE) models like Llama 4 Scout.
Let's break down the requirements and calculate the necessary quantization:
-
RTX 3090 VRAM: A single RTX 3090 has 24 GB of VRAM.
-
MoE Model Memory Footprint:
- Total Parameters (Storage): Llama 4 Scout has 109 Billion total parameters. Even though only a subset (17B) are active at any given time for computation, all 109B parameters must be loaded into VRAM for the model to function without offloading. The GPU needs access to all experts to route tokens correctly.
- Activated Parameters (Computation/KV Cache): The "17B activated" parameters are more relevant for the computational load and the size of the Key-Value (KV) cache, which scales with the number of active parameters and context length.
- The H100 Clue: "At 4-bit quant it fits on a nvidia h100". An H100 (80GB) fits
109B * 4 bits = 436 Gbits = 54.5 GB. This confirms that the 4-bit quantization refers to the entire 109 Billion parameters.
-
VRAM Allocation:
- Model Weights: This will be the largest chunk, determined by the 109B total parameters.
- KV Cache: This stores attention keys and values for generated tokens. Its size depends on context length, batch size, and the activated model size (closer to 17B equivalent). For a 17B-equivalent model, a reasonable context length (e.g., 2048-4096 tokens) could require anywhere from 2 GB to 4 GB+ for KV cache.
- CUDA Overhead/Activations: A smaller amount, typically 1-2 GB.
Let's reserve at least 4-5 GB for KV cache and other overheads to ensure practical usage (i.e., being able to run a decent context length).
This leaves us with approximately 24 GB - 5 GB = 19 GB for the model weights.
-
Calculate Required Bits Per Weight (BPW):
- Target VRAM for weights: 19 GB
- Total parameters: 109,000,000,000
- Formula:
Memory (bits) = Parameters * BitsPerWeight
Memory (bytes) = (Parameters * BitsPerWeight) / 8
Memory (GB) = (Parameters * BitsPerWeight) / (8 * 1024^3)
Now, solve for BitsPerWeight:
BitsPerWeight = (Memory (GB) * 8 * 1024^3) / Parameters
BitsPerWeight = (19 GB * 8 * 1,073,741,824 bytes/GB) / 109,000,000,000 parameters
BitsPerWeight = (152 * 1,073,741,824) / 109,000,000,000
BitsPerWeight = 163,108,757,248 / 109,000,000,000
BitsPerWeight ≈ 1.496 bits per weight
-
ExL2 Quantization Granularity:
ExL2 quantizes at specific common bitrates (e.g., 1.5, 1.6, 2.0, 2.3, 2.5, 3.0, 3.5, 4.0, 5.0, 6.0, 8.0).
Our calculated 1.496 bpw is just under 1.5 bpw. Let's calculate the memory usage for 1.5 bpw:
Memory at 1.5 bpw = (109,000,000,000 * 1.5) / (8 * 1024^3) = 20.4375 GB
If you quantize the entire 109B model at 1.5 bpw, it would consume ~20.44 GB of VRAM for the weights alone.
- Total VRAM (3090): 24 GB
- VRAM for weights (1.5 bpw): ~20.44 GB
- Remaining VRAM for KV Cache + Overhead: 24 GB - 20.44 GB = ~3.56 GB
Conclusion:
To fit Llama 4 Scout (109B total parameters, 17B activated) on a single 3090 without offloading, you would theoretically need to quantize the model to 1.5 bits per weight (BPW) using exl2.
However, this is extremely tight:
- 1.5 bpw is the absolute lowest supported by exl2. Going lower is not an option with this method.
- 3.56 GB for KV cache and overhead is very aggressive. While it might be enough for very short context lengths and small batch sizes, it would likely be insufficient for typical use cases (e.g., 2048-4096 tokens of context) for a model that behaves computationally like a 17B model. You would likely run into VRAM OOM errors quickly.
- Quality Degradation: Quantizing an MoE model to 1.5 bpw for its entire 109B parameters is an extremely aggressive quantization. It's likely to result in significant performance degradation compared to higher bitrates (like the 4-bit you mentioned fitting on an H100).
In summary, while 1.5 bits per weight is the calculated theoretical minimum to store the 109B parameters on a 3090, it's highly improbable that it would be practical or performant due to the lack of VRAM for KV cache and the extreme quantization level. You would likely need to consider:
- Multi-GPU setup.
- Offloading some layers/experts to CPU memory.
- A smaller MoE model or a dense model.
- More VRAM (e.g., an A6000 with 48GB, or multiple 3090s).