diff --git a/data/recipes/gemma4-26b-a4b-df-bf16x.recipe b/data/recipes/gemma4-26b-a4b-df-bf16x.recipe new file mode 100644 index 00000000..204ae3bb --- /dev/null +++ b/data/recipes/gemma4-26b-a4b-df-bf16x.recipe @@ -0,0 +1,17 @@ +# gemma4-26b-a4b-df-bf16x.recipe -- gemma-4-26B-A4B-it with z-lab's DFlash drafter and the routed +# experts left bf16, as arch/gemma4 serves it. +# +# rad-convert --draft-model \ +# --recipe data/recipes/gemma4-26b-a4b-df-bf16x.recipe -o gemma4-26b-a4b-df-bf16x.rad +# +# The trunk exactly as the checkpoint holds it -- the bf16 reference the fp8-expert containers are +# measured against (radiance --kld-record) -- with only the drafter quantised. + +# The DFlash drafter's six linears: block fp8 (the drafter only proposes; the trunk verifies). +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 diff --git a/data/recipes/gemma4-26b-a4b-df-pad768.recipe b/data/recipes/gemma4-26b-a4b-df-pad768.recipe new file mode 100644 index 00000000..f88c1dee --- /dev/null +++ b/data/recipes/gemma4-26b-a4b-df-pad768.recipe @@ -0,0 +1,25 @@ +# gemma4-26b-a4b-df-pad768.recipe -- gemma-4-26B-A4B-it with its experts PADDED TO 768 wide, and +# z-lab's DFlash drafter, as arch/gemma4 serves it. +# +# rad-convert --draft-model \ +# --recipe data/recipes/gemma4-26b-a4b-df-pad768.recipe -o gemma4-26b-a4b-df-pad768.rad +# +# The padding happens BEFORE conversion, outside the engine: each expert's gate and up gain 64 +# zero rows (704 -> 768) and its down 64 zero columns, and moe_intermediate_size becomes 768. It is +# exact -- gelu(0) * 0 = 0 in the added intermediate columns, which meet zero columns of down -- so +# the padded model computes the original's function. 768 is six whole 128-blocks, which the fp8 +# grouped GEMM needs for down's K, and gate and up each start on a block boundary. +# +# Both expert projections block fp8. Everything else as gemma4-26b-a4b-df.recipe says. + +blk.*.ffn_gate_up_exps.*.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 +blk.*.ffn_down_exps.*.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 + +# The DFlash drafter's six linears: block fp8 (the drafter only proposes; the trunk verifies). +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 diff --git a/data/recipes/gemma4-26b-a4b-df.recipe b/data/recipes/gemma4-26b-a4b-df.recipe new file mode 100644 index 00000000..35bd4a3f --- /dev/null +++ b/data/recipes/gemma4-26b-a4b-df.recipe @@ -0,0 +1,27 @@ +# gemma4-26b-a4b-df.recipe -- gemma-4-26B-A4B-it with z-lab's DFlash drafter, from the bf16 +# checkpoint as Google ships it, as arch/gemma4 serves it. +# +# rad-convert --draft-model \ +# --recipe data/recipes/gemma4-26b-a4b-df.recipe -o gemma4-26b-a4b-df.rad +# +# The routed experts are ~90% of the weight bytes and a decode step reads whichever were routed. +# Their gate_up is block fp8: 2 x 704 = 1408 rows are whole 64-row GEMM tiles and eleven 128-row +# scale blocks, and K = 2816 is 22. A third of the expert bytes a decode step reads. +# +# Their down projection stays bf16: K is the expert width, 704, and the fp8 grouped GEMM reads K +# in whole 128-column blocks. gemma4-26b-a4b-df-pad768.recipe makes it fp8 as well, from a +# checkpoint whose experts were padded to 768 first. +# +# The attention, the dense arm, the router, the norms and the tied embedding stay bf16: together +# under a tenth of the bytes, and the dense arm's 2112 is not whole 128-blocks either. + +blk.*.ffn_gate_up_exps.*.weight rtn codes=fp8_e4m3 block=128x128 scale=bf16 + +# The DFlash drafter's six linears: block fp8 (the drafter only proposes; the trunk verifies). +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