Archived
Document HYV3 support and add conversion recipes
Add BF16-source W4/W8/block-FP8/MXFP4, native FP8-source and GGUF-to-W4 recipes. Document supported sources, precision/KV limits and unvalidated paths without calibration environment switches or performance claims.
This commit is contained in:
1 parent
e3eab050bd
commit
2d2f638fa8
8 files changed
+197
No files matched your search
@@ -0,0 +1,19 @@
|
||||
# HYV3 from the BF16 checkpoint, with attention, dense/shared projections and routed experts rounded
|
||||
# to block FP8. F32 scale planes are intentional: MoeFP8 format 9 consumes a 128x128 grid with
|
||||
# F32 scales. Activations are dynamically quantized to E4M3 at runtime; the BF16 output head, router,
|
||||
# norms and embeddings stay as stored.
|
||||
#
|
||||
# rad-convert <Hy-Memory-30B-A3B-BF16> \
|
||||
# --recipe data/recipes/hy-memory-30b-a3b-bf16-fp8.recipe -o hy-memory-30b-a3b-fp8.rad
|
||||
|
||||
blk.*.attn_q.weight rtn codes=fp8_e4m3 block=128x128 scale=f32
|
||||
blk.*.attn_k.weight rtn codes=fp8_e4m3 block=128x128 scale=f32
|
||||
blk.*.attn_v.weight rtn codes=fp8_e4m3 block=128x128 scale=f32
|
||||
blk.*.attn_output.weight rtn codes=fp8_e4m3 block=128x128 scale=f32
|
||||
|
||||
blk.0.ffn_gate_up.weight rtn codes=fp8_e4m3 block=128x128 scale=f32
|
||||
blk.0.ffn_down.weight rtn codes=fp8_e4m3 block=128x128 scale=f32
|
||||
blk.*.ffn_gate_up_shexp.weight rtn codes=fp8_e4m3 block=128x128 scale=f32
|
||||
blk.*.ffn_down_shexp.weight rtn codes=fp8_e4m3 block=128x128 scale=f32
|
||||
|
||||
blk.*.ffn_*_exps.*.weight rtn codes=fp8_e4m3 block=128x128 scale=f32
|
||||
@@ -0,0 +1,18 @@
|
||||
# HYV3 from BF16 with OCP MXFP4 weights: e2m1 codes and one e8m0 scale per 32 values of K. Quantize
|
||||
# attention, dense/shared projections and routed experts; router, norms, embeddings and output head
|
||||
# stay BF16. Both the regular linears and MoeFP8's expert format-8 path consume this encoding.
|
||||
#
|
||||
# rad-convert <Hy-Memory-30B-A3B-BF16> \
|
||||
# --recipe data/recipes/hy-memory-30b-a3b-bf16-mxfp4.recipe -o hy-memory-30b-a3b-mxfp4.rad
|
||||
|
||||
blk.*.attn_q.weight rtn codes=fp4_e2m1 group=32 scale=e8m0
|
||||
blk.*.attn_k.weight rtn codes=fp4_e2m1 group=32 scale=e8m0
|
||||
blk.*.attn_v.weight rtn codes=fp4_e2m1 group=32 scale=e8m0
|
||||
blk.*.attn_output.weight rtn codes=fp4_e2m1 group=32 scale=e8m0
|
||||
|
||||
blk.0.ffn_gate_up.weight rtn codes=fp4_e2m1 group=32 scale=e8m0
|
||||
blk.0.ffn_down.weight rtn codes=fp4_e2m1 group=32 scale=e8m0
|
||||
blk.*.ffn_gate_up_shexp.weight rtn codes=fp4_e2m1 group=32 scale=e8m0
|
||||
blk.*.ffn_down_shexp.weight rtn codes=fp4_e2m1 group=32 scale=e8m0
|
||||
|
||||
blk.*.ffn_*_exps.*.weight rtn codes=fp4_e2m1 group=32 scale=e8m0
|
||||
@@ -0,0 +1,22 @@
|
||||
# Hy-Memory-30B-A3B from Tencent's BF16 safetensors checkpoint. Quantize attention projections,
|
||||
# the dense first MLP and routed experts to native INT4. Keep shared MLPs, routers, norms, embeddings
|
||||
# and the output head at BF16. Routed experts use signed INT4 with BF16 group scales; other linears
|
||||
# use asymmetric U4 with F16 scales and U8 zero points. The byte-sized zero points keep TP2 column
|
||||
# shards aligned even when a projection has an odd number of 128-value groups per rank.
|
||||
#
|
||||
# rad-convert <Hy-Memory-30B-A3B-BF16> \
|
||||
# --recipe data/recipes/hy-memory-30b-a3b-bf16-w4.recipe -o hy-memory-30b-a3b-w4.rad
|
||||
#
|
||||
# The W4 GEMMs consume dynamic INT8 activations. Routed/shared outputs are reduced independently at
|
||||
# TP2 then combined in FP32. Use --tp 2 at serve time if one device cannot hold the .rad weights and
|
||||
# KV cache.
|
||||
|
||||
blk.*.attn_q.weight rtn codes=u4 zero=u8 group=128 scale=f16
|
||||
blk.*.attn_k.weight rtn codes=u4 zero=u8 group=128 scale=f16
|
||||
blk.*.attn_v.weight rtn codes=u4 zero=u8 group=128 scale=f16
|
||||
blk.*.attn_output.weight rtn codes=u4 zero=u8 group=128 scale=f16
|
||||
|
||||
blk.0.ffn_gate_up.weight rtn codes=u4 zero=u8 group=128 scale=f16
|
||||
blk.0.ffn_down.weight rtn codes=u4 zero=u8 group=128 scale=f16
|
||||
|
||||
blk.*.ffn_*_exps.*.weight rtn codes=i4 group=128 scale=bf16
|
||||
@@ -0,0 +1,17 @@
|
||||
# HYV3 from BF16 with signed INT8 W8A8 linears. Attention, the dense first MLP, shared MLPs and
|
||||
# output head are quantized on the 128-value K grid. Routed experts stay BF16: the current MoE block
|
||||
# has no INT8 expert kernel, so this recipe does not pretend the expert weights are W8.
|
||||
#
|
||||
# rad-convert <Hy-Memory-30B-A3B-BF16> \
|
||||
# --recipe data/recipes/hy-memory-30b-a3b-bf16-w8.recipe -o hy-memory-30b-a3b-w8.rad
|
||||
|
||||
blk.*.attn_q.weight rtn codes=i8 group=128 scale=bf16 clamp=sym
|
||||
blk.*.attn_k.weight rtn codes=i8 group=128 scale=bf16 clamp=sym
|
||||
blk.*.attn_v.weight rtn codes=i8 group=128 scale=bf16 clamp=sym
|
||||
blk.*.attn_output.weight rtn codes=i8 group=128 scale=bf16 clamp=sym
|
||||
|
||||
blk.0.ffn_gate_up.weight rtn codes=i8 group=128 scale=bf16 clamp=sym
|
||||
blk.0.ffn_down.weight rtn codes=i8 group=128 scale=bf16 clamp=sym
|
||||
blk.*.ffn_gate_up_shexp.weight rtn codes=i8 group=128 scale=bf16 clamp=sym
|
||||
blk.*.ffn_down_shexp.weight rtn codes=i8 group=128 scale=bf16 clamp=sym
|
||||
output.weight rtn codes=i8 group=128 scale=bf16 clamp=sym
|
||||
@@ -0,0 +1,34 @@
|
||||
# hy-memory-30b-a3b-fp8.recipe -- Tencent's Hy-Memory-30B-A3B-FP8 release.
|
||||
#
|
||||
# rad-convert <Hy-Memory-30B-A3B-FP8 checkpoint directory> \
|
||||
# --recipe data/recipes/hy-memory-30b-a3b-fp8.recipe --kv-cache-dtype fp8 \
|
||||
# -o hy-memory-30b-a3b-fp8.rad
|
||||
#
|
||||
# The checkpoint stores E4M3 projection codes with one F32 weight scale per tensor. Import keeps
|
||||
# those codes and expands each scalar to the 128x128 F32 scale grid read by Radiance's FP8 GEMMs.
|
||||
# Runtime activation quantization is dynamic; source `.input_scale` calibration scalars are ignored.
|
||||
# The attention/MLP norms and router projection are widened to F32 (exact for BF16 source values),
|
||||
# as required by their RMSNorm and FP32 sigmoid-router kernels. Embeddings, lm_head, and the model's
|
||||
# BF16 activations remain BF16; expert correction biases are already F32.
|
||||
#
|
||||
# The indexed kv_cache_scales.safetensors tensors are carried into model metadata during import.
|
||||
# The plugin can use those per-layer K/V descales for an E4M3 KV cache (`--kv-cache-dtype fp8`),
|
||||
# or use a BF16 cache for higher precision.
|
||||
|
||||
blk.*.attn_q.weight import block=128x128 scale=f32
|
||||
blk.*.attn_k.weight import block=128x128 scale=f32
|
||||
blk.*.attn_v.weight import block=128x128 scale=f32
|
||||
blk.*.attn_output.weight import block=128x128 scale=f32
|
||||
blk.0.ffn_gate_up.weight import block=128x128 scale=f32
|
||||
blk.0.ffn_down.weight import block=128x128 scale=f32
|
||||
blk.*.ffn_gate_up_exps.*.weight import block=128x128 scale=f32
|
||||
blk.*.ffn_down_exps.*.weight import block=128x128 scale=f32
|
||||
blk.*.ffn_gate_up_shexp.weight import block=128x128 scale=f32
|
||||
blk.*.ffn_down_shexp.weight import block=128x128 scale=f32
|
||||
|
||||
blk.*.attn_norm.weight cast dtype=f32
|
||||
blk.*.attn_q_norm.weight cast dtype=f32
|
||||
blk.*.attn_k_norm.weight cast dtype=f32
|
||||
blk.*.ffn_norm.weight cast dtype=f32
|
||||
blk.*.glm_router.weight cast dtype=f32
|
||||
output_norm.weight cast dtype=f32
|
||||
@@ -0,0 +1,30 @@
|
||||
# Convert the local llama.cpp Hy-Memory Q4_K_M GGUF into native Radiance encodings. Q4_K/Q6_K
|
||||
# source blocks are decoded to f32, then the attention, dense-first MLP and routed experts are
|
||||
# requantized to Radiance W4; embeddings, output head, routers, norms and shared MLPs are cast to
|
||||
# BF16. This adds loss to an already-quantized source; for best quality, quantize the BF16
|
||||
# safetensors checkpoint with hy-memory-30b-a3b-bf16-w4.recipe instead.
|
||||
#
|
||||
# rad-convert Hy-Memory-30B-A3B-Q4_K_M.gguf \
|
||||
# --tokenizer <Hy-Memory-30B-A3B-BF16>/tokenizer.json \
|
||||
# --recipe data/recipes/hy-memory-30b-a3b-gguf-q4k-to-w4.recipe -o hy-memory-30b-a3b-gguf-w4.rad
|
||||
|
||||
# The model matrices have 120832 rows while the GGUF tokenizer lists 120818 strings.
|
||||
token_embd.weight cast dtype=bf16
|
||||
output.weight cast dtype=bf16
|
||||
|
||||
blk.*.attn_norm.weight cast dtype=bf16
|
||||
blk.*.attn_q_norm.weight cast dtype=bf16
|
||||
blk.*.attn_k_norm.weight cast dtype=bf16
|
||||
blk.*.ffn_norm.weight cast dtype=bf16
|
||||
blk.*.ffn_gate_up_shexp.weight cast dtype=bf16
|
||||
blk.*.ffn_down_shexp.weight cast dtype=bf16
|
||||
|
||||
blk.*.attn_q.weight rtn codes=u4 zero=u8 group=128 scale=f16
|
||||
blk.*.attn_k.weight rtn codes=u4 zero=u8 group=128 scale=f16
|
||||
blk.*.attn_v.weight rtn codes=u4 zero=u8 group=128 scale=f16
|
||||
blk.*.attn_output.weight rtn codes=u4 zero=u8 group=128 scale=f16
|
||||
|
||||
blk.0.ffn_gate_up.weight rtn codes=u4 zero=u8 group=128 scale=f16
|
||||
blk.0.ffn_down.weight rtn codes=u4 zero=u8 group=128 scale=f16
|
||||
|
||||
blk.*.ffn_*_exps.*.weight rtn codes=i4 group=128 scale=bf16
|
||||
Reference in new issue
Block a user