From cfb9d4b754616ca47d165fa1ff8a7a80c30847e3 Mon Sep 17 00:00:00 2001 From: Pascal Date: Thu, 12 Nov 2026 12:15:28 +0100 Subject: [PATCH] mtmd: require an F32 position embedding for HunyuanVL (#32131) HunyuanVL resamples its position embedding on the host into a float buffer sized for F32, then reads ggml_nbytes() of the tensor into it. The graph never uses the tensor, so any type loads, and an F64 tensor overflows the buffer at the first image request. Require the position embedding to be present and F32 when loading the HunyuanVL tensors. --- tools/mtmd/mtmd-model.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/mtmd/mtmd-model.cpp b/tools/mtmd/mtmd-model.cpp index b6727a493..da74ed383 100644 --- a/tools/mtmd/mtmd-model.cpp +++ b/tools/mtmd/mtmd-model.cpp @@ -3000,6 +3000,10 @@ struct mtmd_model_loader { model.mm_img_end = get_tensor(TN_MM_IMG_END); model.image_newline = get_tensor(TN_IMAGE_NEWLINE); model.view_seperator = get_tensor(TN_IMAGE_SEPERATOR, false); + // the position embedding is resampled on the host as F32 + if (!model.position_embeddings || model.position_embeddings->type != GGML_TYPE_F32) { + throw std::runtime_error(mtmd_format("%s: HunyuanVL requires an F32 %s\n", __func__, mtmd_format(TN_POS_EMBD, prefix).c_str())); + } } break; case PROJECTOR_TYPE_JANUS_PRO: {