mirror of
https://github.com/kvcache-ai/ktransformers.git
synced 2026-11-05 01:07:28 +00:00
[GH-ISSUE #2113] MiniMax M2.7: AttributeError: 'LlamafileMoEWrapper' object has no attribute 'submit_write_weight_scale_to_buffer' #1281
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/ktransformers#1281
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 @mrgaolei on GitHub (Jul 31, 2026).
Original GitHub issue: https://github.com/kvcache-ai/ktransformers/issues/2113
Reminder
System Info
AMD 7k62 with avx2
DDR4 256G
4090 48G *2
Ubuntu 24.04
miniconda
kt 0.6.4
Reproduction
@ebarkhordar commented on GitHub (Jul 31, 2026):
@mrgaolei sorry, that was written for the maintainers. Here it is in plain terms.
Nothing is wrong with your setup. The crash is a gap in the code. The option you turned on needs a function that exists on only one of the three CPU backends, and the backend you are running does not have it. The commit history shows that function being added to one backend and never added to the other two, so it looks like something that was never built rather than something deliberately left out. No maintainer has labelled it a bug or a known limitation yet, so I cannot tell you which of the two it will be called.
It is also not really about AVX2. Choosing the AMX backend on an AMX machine hits the same crash, so different hardware, or a different sglang version, would not help.
Whether AVX2 can run MiniMax or DeepSeek V4-Flash from GGUF at all, I cannot answer. I have no machine like yours and no copy of those weights, so I never ran either model. That part is a question for the maintainers.
One thing to try: drop the
--kt-gpu-prefill-token-threshold 500flag. That flag is what switches on the code path that crashes, and it is off by default. I have not tested it, so treat it as a suggestion rather than a fix.The rest below is the detail for the maintainers.
Tree: ktransformers
a8062bfwith thethird_party/sglangsubmodule at its pinned1e098a7, which is the checkout your line numbers land in:kt_ep_wrapper.py:1171iswrapper.submit_write_weight_scale_to_buffer(and:1678isself._prepare_weight_fp8(wrapper, None, gpu_experts_mask,. None of it was run end to end here (no AVX2-only host with 2x4090 and no M2.7 weights), so everything below is read from source rather than run.The method exists on exactly one wrapper. Parsing the class bodies with
ast, own methods plus everything reachable through the bases:submit_write_weight_scale_to_bufferNativeMoEWrapper(kt-kernel/python/utils/amx.py:549)AMXMoEWrapper(kt-kernel/python/utils/amx.py:248)LlamafileMoEWrapper(kt-kernel/python/utils/llamafile.py:21)BaseMoEWrapper(kt-kernel/python/experts_base.py:227)None of those modules defines
__getattr__or sets the attribute dynamically, so attribute resolution is what the class bodies say.KTMoEWrapperpicks the backend atkt-kernel/python/experts.py:340-354:AMXINT4/AMXINT8giveAMXMoEWrapper,LLAMAFILEgivesLlamafileMoEWrapper, and onlyRAWINT4,FP8,BF16,FP8_PERCHANNEL,GPTQ_INT4,SYCL_GPTQ_INT4,MXFP4,MXFP8giveNativeMoEWrapper.So this reads as a
--kt-methodlimitation rather than an AVX2 one, which matters for your question at the end.--kt-method AMXINT4on an AMX-capable CPU would hit the sameAttributeErroron this path, becauseAMXMoEWrapperis missing the same two methods. Changing sglang version alone is unlikely to move it.It is also not specific to the fp8 branch you landed in.
SharedFullContext.load()dispatches atkt_ep_wrapper.py:1662-1688, and all four concrete preparers callsubmit_write_weight_scale_to_buffer:_prepare_weight_int4at:1004,_prepare_weight_fp8at:1171,_prepare_weight_fp8_channelat:1419,_prepare_weight_bf16at:1571. The mxfp4 and mxfp8 branches delegate into_prepare_weight_fp8at:1247and:1284. Every branch of that method needs the Native-only API.Possible workaround, untested here. The entry gate is the flag you set:
self.gpu_prefill_token_threshold = kt_config.gpu_prefill_token_threshold or 0(:2514), and_build_full_contextis reached only whenself.gpu_prefill_token_threshold > 0 and num_tokens >= self.gpu_prefill_token_threshold(:2955-2956).server_args.kt_gpu_prefill_token_thresholddefaults toNone(server_args.py:732), so dropping--kt-gpu-prefill-token-threshold 500should keep you off this path entirely. I have not run it, so treat it as a suggestion.History, in case it helps decide whether this is an oversight or an intended limit. On an unshallowed clone,
git log -G 'submit_write_weight_scale_to_buffer'across the whole repo returns exactly one commit:fcf8882(#1656, "Add avx-based kimi-k2 support"). It added both methods toutils/amx.pyand touchedexperts.py, and it did not touchutils/llamafile.py. Nothing since removes them from anywhere. That reads as an API built for the Native path and never extended to the other two wrappers, rather than one deliberately withheld from them, though a maintainer would know better than the log does.If that reading is right, rejecting a non-Native
--kt-methodcombined with--kt-gpu-prefill-token-threshold > 0at startup would turn this into an immediate message instead of a crash partway through weight loading. Whether that guard or implementing the two methods on the other wrappers is the better fix is your call.@mrgaolei commented on GitHub (Aug 1, 2026):
I apologize, your reply was too technical for me to understand. I would like to ask if avx2 can run MiniMax and DeepSeek V4-Flash via gguf? Is this a bug, or a known unsupported feature?
@youyoulyz commented on GitHub (Aug 5, 2026):
We reproduced this end-to-end and have findings that may help close it.
Environment: 2× RTX 3080 20GB, Qwen3-30B-A3B,
--kt-method LLAMAFILE(Q4_K_M GGUF via--kt-weight-path), kt 0.6.4.Reproduction: the first request with ≥
--kt-gpu-prefill-token-thresholdtokens crashes the scheduler with the sameAttributeErrorin_prepare_weight_bf16→submit_write_expert→wrapper.submit_write_weight_scale_to_buffer. The crash reproduces with or without--kt-enable-dynamic-expert-update— the threshold flag alone is sufficient; the dynamic-update flag only gates the promote step after the fallback compute.Still present on latest main: verified end-to-end on ktransformers
e03cf1c+ sglang submoduled164eea75(2026-08-05). The capability gate_full_gpu_fallback_supportedstill checks only layer attributes (w13_weight/w13_weight_packed/_v4_tk_path), never the wrapper's capability, so a bf16/LLAMAFILE layer passes the gate and hits the missing method.On PR #2111: we applied the BaseMoEWrapper move locally and re-ran. The error changes from
AttributeErrortoNotImplementedError: write_weight_scale_to_buffer_taskand the scheduler still SIGQUITs. The compiledkt_kernel_ext.moe.MOEin the wheel does not exposewrite_weight_scale_to_buffer_taskfor the LLAMAFILE backend (hasattr(MOE, "write_weight_scale_to_buffer_task")is False), so relocating the Python method is not sufficient for LLAMAFILE — the fix needs either the C++-side task on the llamafile backend or an explicit startup-time gate rejecting non-Native--kt-methodcombined with--kt-gpu-prefill-token-threshold > 0.Happy to share the full traceback set and the minimal repro script if useful.