
======================================================================
 tb_gguf_audit  ->  Qwen3.5-9B-UD-Q3_K_XL.gguf
======================================================================

GGUF version : 3
Architecture : qwen35
Tensor count : 427
KV entries   : 46
Data offset  : 0xa75ce0

-- Section 1: KV parameters
  n_layers                         32
  hidden_dim                       4096
  ffn_dim                          12288
  n_heads                          16
  n_kv_heads                       4
  head_dim                         256
  n_experts                        NOT FOUND
  n_experts_per_tok                NOT FOUND
  rope_base                        10000000.0
  norm_eps                         9.999999974752427e-07
  full_attention_interval          4
  bos_id                           NOT FOUND
  eos_id                           248046

-- Section 2: GQA sanity
  OK GQA(ratio=4)  n_heads=16  n_kv_heads=4

-- Section 3: RoPE
  rope_scaling_type: not set (standard RoPE assumed)
  rope_base=10000000.0

-- Section 4: Tensor name coverage
  HIT=371  FALLBACK=32  MISS=0  (of 403 lookups against 427 tensors)

  FALLBACK  blk.0.ffn_norm.weight
            -> found as: blk.0.post_attention_norm.weight
  FALLBACK  (pattern 'blk.N.ffn_norm.weight' occurs on all 32 layers -- suppressing)

-- Section 5: Quant type inventory
  F32        (type= 0):  177 tensors
  F16        (type= 1):   48 tensors
  Q3_K       (type=11):   56 tensors
  Q4_K       (type=12):   58 tensors
  Q5_K       (type=13):   13 tensors
  Q6_K       (type=14):   27 tensors
  IQ3_S      (type=21):   10 tensors
  IQ4_XS     (type=23):   38 tensors

-- Section 6: Block size sanity (first tensor per quant type)
  OK  Q6_K      tensor=output.weight  n_elems=1017118720  blocks=3973120
  OK  Q4_K      tensor=token_embd.weight  n_elems=1017118720  blocks=3973120
  OK  IQ4_XS    tensor=blk.0.attn_gate.weight  n_elems=16777216  blocks=65536
  OK  Q5_K      tensor=blk.0.ffn_down.weight  n_elems=50331648  blocks=196608
  OK  Q3_K      tensor=blk.0.ffn_gate.weight  n_elems=50331648  blocks=196608
  OK  IQ3_S     tensor=blk.1.ffn_gate.weight  n_elems=50331648  blocks=196608

-- Section 7: Dequant self-test (first block of each quant type)
  F16       : OK  L2=0.1385  bad=0
  F32       : OK  L2=11.7901  bad=0
  IQ3_S     : SKIP (no Python ref for type 21)
  IQ4_XS    : SKIP (no Python ref for type 23)
  Q3_K      : OK  L2=0.2637  zeros=43/256  tensor=blk.0.ffn_gate.weight
  Q4_K      : OK  L2=0.1913  zeros=0/256  tensor=token_embd.weight
  Q5_K      : OK  L2=0.2350  zeros=0/256  tensor=blk.0.ffn_down.weight
  Q6_K      : OK  L2=0.2708  zeros=4/256  tensor=output.weight

-- Section 8: Dequant-zeroing risk (tensor found, but C engine will zero it)
  IQ4_XS (38 tensors): C engine hits 'default: memset(out,0)' branch!
    blk.0.attn_gate.weight
    blk.1.attn_gate.weight
    blk.10.attn_gate.weight
    blk.12.attn_gate.weight
    ... and 34 more

-- Section 9: Architecture-specific checks
  FAIL: Q-head mismatch  GGUF KV n_heads=16 but blk.3.attn_q.weight rows -> 32 heads
        Engine NH=16 -> only 16/32 Q-heads computed for global layers
  FAIL: n_kv_heads correction in tb_gguf.c reads LOCAL blk.0.attn_qkv.weight
        derives n_kv_heads=8 (wrong: local DeltaNet QKV layout)
        actual global K weight: n_kv_heads=4
        KV cache allocated for 8 heads, attention computed with 4
  FAIL: Partial RoPE  rope.dimension_count=64 < head_dim=256
        Engine rotates all 128 pairs; should rotate only 32 pairs
        rope.dimension_sections=[11, 11, 10, 0] (frequency band partitioning -- NOT IMPLEMENTED)
  OK  qwen35.full_attention_interval=4 found
      C engine uses strstr('full_attention_interval') -> matches correctly
      Hybrid layout: every 4th layer is global softmax, rest are DeltaNet

-- Summary
  Tensor misses (silent passthrough):          0
  Tensor fallbacks (alias resolved OK):        32
  Tensors dequant-zeroed in C engine:          38  <- SILENT WRONG OUTPUT
  Dequant self-test failures (implemented types): 0
  OVERALL: ISSUES FOUND -- IQ4_XS zeroing (38 tensors)
  See Sections 8 and 9 for architecture-specific bugs

