📱 Ginigen Edge AI News

On-device AI, quantization and offline LLMs in practice

GigaChat 4 37B-A4B GGUF on Your Own Device: Only 8 of 32 Layers Grow the KV Cache, So Which Quant Fits 24, 32 and 48 GB

2026-11-28 · Ginigen AI

aiopensourceedgeaillm

GigaChat 4 37B-A4B GGUF on Your Own Device: Only 8 of 32 Layers Grow the KV Cache, So Which Quant Fits 24, 32 and 48 GB

TL;DR - GigaChat 4 37B-A4B (ai-sage) ships as GGUF in four formats: Q4_K_M 21.66 GiB, Q6_K 29.32 GiB, Q8_0 37.94 GiB, BF16 71.32 GiB. Only 4B of its 37B parameters run per token, so decode touches roughly 2.5 GB of weights per token at Q4_K_M. - Only 8 of its 32 layers keep a growing KV cache; the other 24 are Gated DeltaNet layers with a fixed-size state. Our arithmetic from config.json: about 9 KiB per token in fp16 if the latent cache is stored compressed, which is 0.281 GiB at 32K and 9.000 GiB at the full 1M window. - The model card's own server recipe (-c 32768 -np 4, q8_0 KV) lands at about 22.00 GiB for Q4_K_M before compute buffers, so a 24 GB card is tight and a 32 GB card is comfortable. - The card reports MTP speculative decoding gains of 1.42x on 8 H100s and 1.49x on a dual-EPYC CPU box for Q4_K_M. We show how to read those numbers.

GigaChat 4 GGUF file sizes

What is GigaChat 4 37B-A4B, and why does it suit local hardware?

GigaChat 4 37B-A4B is an instruction-tuned Mixture-of-Experts model from ai-sage with 37B total and 4B active parameters per token. It mixes two attention types in a 3:1 ratio: 24 Gated DeltaNet (linear attention) layers and 8 sparse-attention layers built on multi-head latent attention with DeepSeek Sparse Attention. The context window is 1,048,576 tokens, and one model serves both instant and reasoning modes, selected per request.

For edge and workstation use, three properties matter more than the headline parameter count:

  1. Active parameters set the speed. Decode speed is bound by how many weight bytes move per token, and only 8 of 192 routed experts plus one shared expert fire per layer.
  2. Total parameters set the RAM. All 192 experts must be resident (or memory-mapped), so the file size is the floor.
  3. The attention mix sets the context cost. With 24 of 32 layers using a fixed-size recurrent state, long context grows memory far more slowly than in a model where every layer keeps a KV cache.

This article does the byte math for each, using the published GGUF sizes and config.json, so you can decide which file to download before you spend an hour on it.

Which GGUF quant of GigaChat 4 fits my machine?

The Hugging Face API reports these exact file sizes for ai-sage/GigaChat4-37B-A4B-GGUF:

Format Bytes GiB Effective bits per weight (37B total)
Q4_K_M 23,253,070,016 21.66 5.03
Q6_K 31,483,633,856 29.32 6.81
Q8_0 40,737,835,200 37.94 8.81
BF16 (two shards) 76,581,194,144 71.32 16.56

Bits per weight here is file bytes times 8 divided by 37 billion, so it is approximate; the card does not give an exact parameter count and a few tensors sit at higher precision. Use it for ranking, not for citation.

Rules of thumb that follow from the table:

  • 24 GB single GPU: Q4_K_M weights alone take 21.66 GiB. It can work with a short context and expert offload to system RAM, but there is little headroom.
  • 32 GB GPU or Apple Silicon with 32 GB unified memory: Q4_K_M fits with room for several thousand tokens of cache. Leave some memory for the OS on unified-memory machines.
  • 48 to 64 GB: Q6_K or Q8_0 become practical. Q8_0 at 37.94 GiB plus cache fits a 48 GB card.
  • CPU-only with 64 GB RAM: Q4_K_M and Q6_K both fit, and memory bandwidth, not capacity, becomes the limit (see below).

How big is the KV cache when only 8 of 32 layers have one?

Linear-attention layers do not store a per-token cache. They keep one fixed-size state per sequence. Only the 8 full-attention layers listed in config.json (full_attention_layers: 3, 7, 11, 15, 19, 23, 27, 31) grow with context.

Those 8 layers use multi-head latent attention. The config gives kv_lora_rank 512 and qk_rope_head_dim 64. If the runtime caches the compressed latent plus the rotary key, that is 576 values per token per layer:

layers, latent = 8, 512 + 64            # from config.json
fp16 = layers * latent * 2              # bytes per token
q8   = layers * latent * (34 / 32)      # q8_0 = 34 bytes per 32 values
print(fp16, q8)                         # 9216, 4896
for ctx in (8192, 32768, 131072, 1048576):
    print(ctx, round(ctx * fp16 / 2**30, 3), "GiB fp16", round(ctx * q8 / 2**30, 3), "GiB q8_0")
Context fp16 latent cache q8_0 latent cache
8K 0.070 GiB 0.037 GiB
32K 0.281 GiB 0.149 GiB
128K 1.125 GiB 0.598 GiB
1M 9.000 GiB 4.781 GiB

KV cache by context

Two honest caveats. First, this assumes the llama.cpp implementation stores the compressed latent, which we have not confirmed in the support pull request. If a build instead expands keys and values per head (32 heads, 192 plus 128 dimensions), the same 8 layers cost about 160 KiB per token, or 5 GiB at 32K. Check your build's startup log, which prints the KV buffer size, and trust that number over ours. Second, the sparse-attention indexer adds its own small tensors that we have not counted.

The state of the 24 linear layers is constant. With 32 value heads of 128 by 128 per layer, one sequence needs about 48 MiB if the state is kept in fp32 (illustrative; the real layout may differ), and slots multiply it: four slots is about 0.19 GiB. That is why a long context on this model costs so little compared with an all-attention model of similar size.

What does the full memory budget look like for the model card's server recipe?

The card's GPU example runs llama-server with -c 32768 -np 4 -ctk q8_0 -ctv q8_0 -fa on. The context is shared across the four slots. For Q4_K_M:

Component GiB
Q4_K_M weights 21.66
q8_0 latent cache, 32K total 0.149
4 linear-attention states (fp32, illustrative) 0.19
Subtotal before compute buffers 22.00

Memory stack for the card's server recipe

Compute buffers and the CUDA context add a further one to a few GiB depending on batch size. So the budget is roughly 24 to 26 GiB: comfortable on a 32 GB card, and on a 24 GB card you would reduce slots, shrink context, or keep some expert tensors in system RAM.

You can check any of this on your own machine in under a minute:

hf download ai-sage/GigaChat4-37B-A4B-GGUF \
  --include "GigaChat4-37B-A4B-Q4_K_M/*.gguf" --local-dir ./gguf
./build/bin/llama-server -m ./gguf/GigaChat4-37B-A4B-Q4_K_M/GigaChat4-37B-A4B-Q4_K_M.gguf \
  -c 32768 -np 1 -ctk q8_0 -ctv q8_0 -fa on --jinja 2>&1 | grep -i -E "KV|buffer"

The model card says GigaChat 4 support lives in llama.cpp pull request 32767 and pins a specific commit for its benchmarks, so build that revision rather than an arbitrary release.

How fast will it decode, and what do the model card's numbers mean?

Decode is bandwidth bound. Per token you read the active weights once:

bpw = 23_253_070_016 * 8 / 37e9        # about 5.03 for Q4_K_M
active_bytes = 4e9 * bpw / 8           # about 2.5 GB per token
for bw in (50, 100, 273, 800):         # GB/s: dual-channel DDR5, fast DDR5, Pro-class unified, high-end unified
    print(bw, round(bw * 1e9 / active_bytes, 1), "tok/s ceiling")

That gives a ceiling near 20 tok/s at 50 GB/s and near 40 tok/s at 100 GB/s, before routing overhead and cache effects. Treat these as upper bounds, not forecasts.

The model card publishes measured single-stream numbers for Q4_K_M with greedy decoding on a 1,024-token prompt:

Hardware MTP off MTP-3 Speedup Draft acceptance
8 x H100 80 GB 150.4 tok/s 213.3 tok/s 1.42x 0.612
2 x EPYC 9474F, CPU only 16.8 tok/s 25.0 tok/s 1.49x 0.596

On the CPU box, 16.8 tok/s at about 2.5 GB per token implies roughly 42 GB/s of weight traffic, a sensible fraction of what that platform can deliver once routing and attention work are included. It also shows why speculative decoding helps there: when each verification step costs the same weight read, accepting about three tokens per step amortizes it.

Batch size changes the story. The card's own batch table shows MTP-3 at 217.5 tok/s versus 149.3 tok/s off for one request, and 635.2 versus 676.6 at batch 16. Speculative decoding pays off for a single interactive user, which is exactly the local-assistant case, while a shared server at high batch is better run without it.

Which quality results should I look at when choosing a quant?

The card reports the same 200-example set with drafting off and on, Q4_K_M, temperature 1.0:

Task Mode Accuracy, MTP off Accuracy, MTP-3
GSM8K Reasoning 0.950 0.940
GSM8K Instant 0.920 0.920
MMLU Reasoning 0.890 0.895
MMLU Instant 0.845 0.835

Differences of one point on 200 examples are inside sampling noise, so the practical reading is that MTP changes speed, not the quality class. For the model itself, the card lists SWE-bench Verified 70.80 in instant mode, AIME 2026 mean@8 of 92 in reasoning mode, and JSONSchemaBench 96 in reasoning mode, which is relevant if you plan to use it for structured tool output on-device. These are the publisher's own measurements.

Before you ship it, run your own task set on the exact GGUF you intend to deploy. Quantization changes are easy to test: same prompts, same sampler, compare Q4_K_M against Q6_K on 100 of your real inputs.

A pre-download checklist

  1. Pick the format by file size plus cache: Q4_K_M for 32 GB, Q6_K or Q8_0 for 48 GB and above.
  2. Build the llama.cpp revision named on the model card.
  3. Start with -np 1 and -ctk q8_0 -ctv q8_0, read the KV line in the log, and compare it with the table above.
  4. Enable the MTP drafter for single-user use; disable it for batch serving.
  5. Read the license. The card lists a noncommercial license for individuals, so confirm it fits your use before building a product on it.

FAQ

How much RAM does GigaChat 4 37B-A4B need? The Q4_K_M file is 21.66 GiB, and the card's server recipe adds roughly 0.35 GiB of cache and state, so plan for about 24 to 26 GiB including compute buffers.

Why is the KV cache so small for a model with a 1M-token window? Only 8 of 32 layers keep a growing cache, and those use latent attention. The other 24 layers hold a fixed-size state. Under our assumptions the full 1M window costs about 9.000 GiB in fp16, versus tens of GiB for an all-attention model.

Can I run it on CPU only? Yes. The card reports 16.8 tok/s for Q4_K_M on a dual-EPYC server and 25.0 tok/s with MTP-3. Consumer machines have less memory bandwidth, so use the bandwidth ceiling formula above to set expectations.

Is Q4_K_M good enough, or should I pick Q6_K? Choose Q4_K_M if memory is the constraint. Move to Q6_K (29.32 GiB) when you have the room and your own test set shows a difference.

Should I turn on speculative decoding? For one interactive user, yes: the card shows 1.42x to 1.54x across formats. For a busy multi-user server, measure first, since the card's batch-16 row is slightly lower with it on.

File sizes and benchmark figures come from the Hugging Face model card and API on 2026-11-28. KV and state sizes are our own arithmetic from config.json and are labeled where they rely on assumptions.