mirror of
https://github.com/kvcache-ai/ktransformers.git
synced 2026-11-05 01:07:28 +00:00
[GH-ISSUE #1860] # MXFP4 quantization allocates GPU weights for all experts regardless of KTransformers --kt-num-gpu-experts #1155
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/ktransformers#1155
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/1860
Reminder
System Info
main@ 45095bac7main@16a8b98Reproduction
Repository: sgl-project/sglang
Summary
When using KTransformers expert offloading with an MXFP4-quantized model, the MXFP4 weight creation in
mxfp4.pyallocates GPU memory for all experts (e.g., 128) instead of respecting thenum_expertsparameter passed fromkt_ep_wrapper.py. Setting--kt-num-gpu-experts 0still causes full GPU allocation and OOM.Error
This occurs even with
--kt-num-gpu-experts 0. Non-expert parameters (attention, embeddings, lm_head) total only ~3.7 GB, but PyTorch reports 29.6 GB allocated.Root Cause
In
sglang/srt/layers/quantization/mxfp4.pyaround line 360, thecreate_weightsmethod useslayer.num_local_expertsto size the weight tensors:The call from
kt_ep_wrapper.py(line 207) passesnum_experts=self.num_gpu_experts(which could be 0), butmxfp4.pyignores this and reads from the layer attribute instead.Expected Behavior
When
num_experts=0is passed tocreate_weights(), no GPU expert weight buffers should be allocated. Thenum_expertsparameter should control the tensor dimensions, notlayer.num_local_experts.Impact
This prevents KTransformers expert offloading from working with any MXFP4-quantized MoE model, regardless of how many GPU experts are requested. It's not specific to gpt-oss — it would affect any MXFP4 MoE model using the KT integration path.
Steps to Reproduce
Others
No response
@ErvinXie commented on GitHub (Feb 28, 2026):
As mentioned in #1861, MXFP4 format is not currently supported in KTransformers. This allocation issue is a consequence of that — the MXFP4 code path was not designed to work with KTransformers's expert offloading.
FP4 support is on our roadmap. This issue will be addressed as part of that effort.
This reply was generated by an AI agent and reviewed by a human.