random_models / gemma4-random-model /CONFIG_DECISION.md
shibatch's picture
Upload folder using huggingface_hub
cf9609e verified
|
Raw
History Blame Contribute Delete
3.49 kB

Gemma 4 tiny fixture configuration decision

Status

The text-only tiny configuration is fixed and generated under artifacts/gemma4-v0/gemma4-random-model as a BF16 Hugging Face package and a Q4_0 GGUF fixture.

The fixed Hugging Face implementation is Transformers 5.14.1 Gemma4ForCausalLM with Gemma4TextConfig. Its constructed trainable parameter count is 1,519,168.

The local source file identifies itself as general.architecture = gemma4. Repository and revision provenance are not inferable from the local directory and remain intentionally unset.

Source observations

The 12B GGUF v3 header uses alignment 32 and contains 667 tensors. Its core geometry is:

  • 48 layers arranged as eight repetitions of five sliding-window layers followed by one global layer.
  • Hidden width 3840 and FFN width 15360.
  • 16 query heads.
  • Local layers: 8 KV heads and head width 256.
  • Global layers: 1 KV head and head width 512.
  • Global layers omit a separate attn_v.weight; this is part of the schema and must not be filled in by a generic Llama tensor template.
  • Sliding window 1024, context 262144.
  • Global/local RoPE bases 1000000/10000.
  • Global/local RoPE dimensions 512/256.
  • Final logit softcap 30 and RMS epsilon 1e-6.
  • Tied token/output embedding; the official tensor inventory has no independent output.weight.

The separate projector file identifies itself as general.architecture = clip and general.type = mmproj. It is not included in the first text-only fixture.

Tiny geometry

The selected geometry is defined in configs/gemma4-tiny-v0.json:

  • 6 layers: one complete five-local/one-global schedule.
  • Hidden width 128 and FFN width 512.
  • 4 query heads.
  • Local layers: 2 KV heads, head width 32.
  • Global layer: 1 KV head, head width 64, no independent V projection.
  • Context 128 and sliding window 64.
  • Vocabulary 128 with PAD/EOS/BOS/UNK/MASK IDs 0/1/2/3/4.

This is a constrained scale-down rather than independently selected fields. It preserves the official layer schedule, the 2:1 global/local head-width ratio, the 2:1 query/local-KV head ratio, the single global KV head, FFN ratio 4, separate RoPE regimes, softcap, tied embeddings, and global shared-KV tensor inventory.

All matrix dimensions are multiples of 32. This is required so that a direct F32 GGUF can subsequently be quantized through the pinned Q4_0 path without changing model geometry merely to satisfy quantization blocks.

Expected GGUF tensor dimensions

GGUF dimensions are listed in reader order.

Role Local layers 0-4 Global layer 5
attn_q.weight [128, 128] [128, 256]
attn_k.weight [128, 64] [128, 64]
attn_v.weight [128, 64] absent
attn_output.weight [128, 128] [256, 128]
attn_q_norm.weight [32] [64]
attn_k_norm.weight [32] [64]

Every layer also has FFN gate/up [128, 512], FFN down [512, 128], hidden-width norms, and one scalar layer-output scale.

Generation gates

Fixture generation is accepted only when:

  • the direct writer emits general.architecture = gemma4 and the exact tensor role schedule above;
  • a second generation is byte-identical;
  • the F32 GGUF loads in the pinned llama.cpp revision;
  • direct-token prefill and cached decode are finite and reproducible;
  • the Q4_0 conversion retains the same geometry and loads successfully;
  • F32 outputs are compared with an independently generated matched reference.