Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion python/freetoken/models/gemma4/gguf.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ def g(key: str):
num_layers = int(g("block_count"))
hidden = int(g("embedding_length"))
num_qo_heads = int(g("attention.head_count"))
kv_per_layer = g("attention.head_count_kv") # per-layer list
# llama.cpp writes head_count_kv as a SCALAR when every layer shares a KV head
# count, and only as a per-layer array when they differ (e.g. gemma-4-E2B: 1).
_kv = g("attention.head_count_kv")
kv_per_layer = [int(x) for x in _kv] if hasattr(_kv, "__len__") else [int(_kv)] * num_layers
# True -> sliding-window (SWA) layer, False -> full attention.
swa_pattern = [bool(x) for x in g("attention.sliding_window_pattern")]
assert len(swa_pattern) == num_layers, "sliding_window_pattern length != block_count"
Expand Down