convert : fix FP8 qwen4exp checkpoints (n-gram table scale, block-scaled FP8) (#32476)

* convert : fix FP8 n-gram table export for qwen4exp

* convert : dequantize block-scaled FP8 weight_scale_inv in ModelOpt checkpoints
This commit is contained in:
Aman Gupta authored and GitHub committed 2026-11-17 22:25:01 +08:00
1 parent 7f106b5459
commit d3064fddce
6 files changed
+160 -8

No files matched your search

+5
View File
@@ -215,6 +215,8 @@ void llama_model_qwen4exp::load_arch_tensors(llama_model_loader & ml) {
per_layer_tok_embd = create_tensor(tn(LLM_TENSOR_PER_LAYER_TOKEN_EMBD, "weight"),
{ hparams.ple_head_dim, ple_rows }, TENSOR_READ_LAZY);
// an FP8 table keeps its checkpoint bytes, so its per-tensor scale is applied after the gather
per_layer_tok_embd_s = create_tensor(tn(LLM_TENSOR_PER_LAYER_TOKEN_EMBD, "scale"), { 1 }, TENSOR_NOT_REQUIRED);
}
auto load_block = [&](int il, int flags) {
@@ -1408,6 +1410,9 @@ ggml_tensor * llama_model_qwen4exp::graph::build_inp_ple(
// gather then flatten the heads: get_rows lays the head dimension out slowest, as the reference does
ggml_tensor * emb = ggml_get_rows(ctx0, model.per_layer_tok_embd, rows);
if (model.per_layer_tok_embd_s) {
emb = ggml_mul(ctx0, emb, model.per_layer_tok_embd_s);
}
emb = ggml_reshape_2d(ctx0, emb, hparams.ple_head_dim * n_heads, n_tokens);
cb(emb, "ple_embd", -1);