diff --git a/data/recipes/gemma4-e4b-bf16-a4-df.recipe b/data/recipes/gemma4-e4b-bf16-a4-df.recipe new file mode 100644 index 00000000..7b8e4b78 --- /dev/null +++ b/data/recipes/gemma4-e4b-bf16-a4-df.recipe @@ -0,0 +1,49 @@ +# gemma4-e4b-bf16-a4-df.recipe -- Gemma 4 E4B (text, vision, NVIDIA's DFlash drafter) from a bf16 checkpoint, +# 4-bit: the feed-forward as asymmetric int4 (u4 codes, a u8 zero point and an f16 scale per [1 x 128]), +# attention and layers 19-23 as int8 with a bf16 scale per [1 x 128] (i8a8). An int8 lm_head, the drafter on +# block FP8, the vision tower bf16. +# +# rad-convert --recipe data/recipes/gemma4-e4b-bf16-a4-df.recipe --draft-model \ +# --set quantization_config.quant_method=compressed-tensors -o gemma4-e4b-a4-df.rad +# +# The int4 linears read the activation quantised to int8 with a scale per (row, 128) above 64 rows +# (w4a8i8_asym) and an f16 copy of it at decode heights (w4a16_asym). Attention and layers 19-23, which +# amplify rounding at single tokens, stay at 8 bits. + +blk.19.attn_qkv.weight rtn codes=i8 group=128 scale=bf16 +blk.19.attn_o.weight rtn codes=i8 group=128 scale=bf16 +blk.19.ffn_gate_up.weight rtn codes=i8 group=128 scale=bf16 +blk.19.ffn_down.weight rtn codes=i8 group=128 scale=bf16 +blk.20.attn_qkv.weight rtn codes=i8 group=128 scale=bf16 +blk.20.attn_o.weight rtn codes=i8 group=128 scale=bf16 +blk.20.ffn_gate_up.weight rtn codes=i8 group=128 scale=bf16 +blk.20.ffn_down.weight rtn codes=i8 group=128 scale=bf16 +blk.21.attn_qkv.weight rtn codes=i8 group=128 scale=bf16 +blk.21.attn_o.weight rtn codes=i8 group=128 scale=bf16 +blk.21.ffn_gate_up.weight rtn codes=i8 group=128 scale=bf16 +blk.21.ffn_down.weight rtn codes=i8 group=128 scale=bf16 +blk.22.attn_qkv.weight rtn codes=i8 group=128 scale=bf16 +blk.22.attn_o.weight rtn codes=i8 group=128 scale=bf16 +blk.22.ffn_gate_up.weight rtn codes=i8 group=128 scale=bf16 +blk.22.ffn_down.weight rtn codes=i8 group=128 scale=bf16 +blk.23.attn_qkv.weight rtn codes=i8 group=128 scale=bf16 +blk.23.attn_o.weight rtn codes=i8 group=128 scale=bf16 +blk.23.ffn_gate_up.weight rtn codes=i8 group=128 scale=bf16 +blk.23.ffn_down.weight rtn codes=i8 group=128 scale=bf16 + +blk.*.attn_qkv.weight rtn codes=i8 group=128 scale=bf16 +blk.*.attn_q.weight rtn codes=i8 group=128 scale=bf16 +blk.*.attn_o.weight rtn codes=i8 group=128 scale=bf16 +blk.*.ffn_down.weight rtn codes=u4 zero=u8 group=128 scale=f16 rule=search +blk.*.ffn_gate_up.weight rtn codes=u4 zero=u8 group=128 scale=f16 rule=search + +output.weight rtn codes=i8 group=128 scale=bf16 clamp=sym + +dflash.fc.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +dflash.blk.*.attn_q.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +dflash.blk.*.attn_k.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +dflash.blk.*.attn_v.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +dflash.blk.*.attn_output.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +dflash.blk.*.ffn_gate_up.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +dflash.blk.*.ffn_down.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +dflash.draft_head.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16