mirror of
https://github.com/kvcache-ai/ktransformers.git
synced 2026-11-05 01:07:28 +00:00
[GH-ISSUE #1861] BF16 backend cannot parse gpt-oss packed/fused expert weight format #1158
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/ktransformers#1158
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @vshortt73 on GitHub (Feb 22, 2026).
Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/1861
Reminder
System Info
main@16a8b98main@ 45095bac7Reproduction
Repository: kvcache-ai/ktransformers (could tie to #1655)
Summary
The BF16SafeTensorLoader defaults to DeepSeek MoE weight format and cannot parse gpt-oss's packed fused expert tensors. This is a separate failure mode from the GGUF/MXFP4 type 39 issue already documented in #1655.
Details
Weight format mismatch
The BF16SafeTensorLoader expects DeepSeek-style per-expert weight keys:
gpt-oss uses packed fused tensors with MXFP4 block/scale format:
All 128 experts are packed into single tensors per layer (fused gate+up projection), with separate block quantization scales. There is no per-expert dimension in the key naming.
Observed behavior
The loader (
kt-kernel/python/utils/loader.pyline 463) fails to match gpt-oss's key pattern and falls back to DeepSeek format, which then fails to load the weights correctly.Three confirmed failure paths for gpt-oss on KTransformers
For completeness, here are all three integration paths attempted and their failure modes:
ValueError: 39 is not a valid GGMLQuantizationTypeSuggestion
To support gpt-oss (and likely future models using packed/fused MoE formats):
gate_up_proj_blocks/scalesinto individual expert weightsNote on successful llama.cpp baseline
For reference, gpt-oss-120b runs successfully on the same hardware via llama.cpp with
--override-tensorexpert offloading at 37.95 t/s (15 of 36 layers' experts on GPU, remainder on CPU via DDR5). The model architecture is functional — it's specifically the KTransformers integration paths that need gpt-oss format support.Others
No response
@vshortt73 commented on GitHub (Feb 22, 2026):
Update: Standard quant GGUFs (Q4_K_M) also blocked by type 39
Following up on the original report — I attempted the LLAMAFILE backend with bartowski's Q4_K_M quantization of gpt-oss-120B (
bartowski/openai_gpt-oss-120b-GGUF), expecting standard quant types would bypass the MXFP4 issue.Same failure:
File "/venv/kt-slang/lib/python3.11/site-packages/gguf/gguf_reader.py", line 325, in _build_tensors
ggml_type = GGMLQuantizationType(raw_dtype[0])
ValueError: np.uint32(39) is not a valid GGMLQuantizationType
The Q4_K_M GGUF contains mixed quantization types — the expert FFN weights are Q4_K_M, but the original model's non-expert tensors (attention, router, embeddings, lm_head) were trained in MXFP4 and appear to retain type 39 in the GGUF. The Python
ggufreader (0.17.1, latest) fails on the first type 39 tensor it encounters, before it reaches any Q4_K_M data.This means every gpt-oss GGUF variant is blocked — not just the native MXFP4. Q2_K through BF16 from bartowski will all contain at least some type 39 tensors and hit the same wall.
The fix needs to happen upstream in the
ggufPython package (adding type 39 / MXFP4 toGGMLQuantizationType). Until then, gpt-oss is incompatible with the LLAMAFILE backend regardless of quantization choice.For reference, llama.cpp's C implementation handles type 39 natively — the same MXFP4 GGUF runs fine via
llama-serverat 37.95 t/s with--override-tensorexpert offloading. The gap is specifically in the Python gguf library.@ErvinXie commented on GitHub (Feb 28, 2026):
We currently do not support FP4 quantization formats, including NVFP4 and MXFP4. This means models using these formats (such as gpt-oss-120b with MXFP4 packed weights) are not compatible with KTransformers at this time.
We do have plans to add FP4 format support in future releases. Please stay tuned for updates.
This reply was generated by an AI agent and reviewed by a human.