kvcache-ai-ktransformers/kt-kernel/python/utils
devangpratap 89d30a3d01
Some checks failed
Book-CI / test (push) Has been cancelled
Book-CI / test-1 (push) Has been cancelled
Book-CI / test-2 (push) Has been cancelled
Deploy / deploy (macos-latest) (push) Has been cancelled
Deploy / deploy (ubuntu-latest) (push) Has been cancelled
Deploy / deploy (windows-latest) (push) Has been cancelled
[fix(loader)]: correct off-by-one expert-count guard in load_experts (#2026)
* [fix(loader)]: correct off-by-one expert-count guard in SafeTensorLoader.load_experts

After the discovery loop, max_experts_count is the highest expert index found
(expert count - 1), and is -1 only when the key has no experts. The guard
checked == 0, which falsely rejected single-expert layers and silently returned
empty weight lists for the zero-expert case. Check == -1 instead.

Adds a CPU regression test covering the single-, zero-, and multi-expert cases.

* [test(loader)]: import loader as a top-level module in expert-count guard test

Per review feedback: add python/utils to sys.path and import loader directly
instead of the importlib.util boilerplate. Still bypasses utils/__init__.py
(and the compiled kt_kernel_ext) while keeping the import idiomatic.
2026-06-07 23:41:04 +08:00
..
__init__.py Kt minimax (#1742) 2025-12-24 15:39:44 +08:00
amx.py [feat](kt-kernel): AVX2 MXFP4 MoE MXFP4 dispatch (#2015) 2026-05-30 19:20:16 +08:00
llamafile.py [fix]: fix --numa-nodes handling (#1904) 2026-03-31 17:50:22 +08:00
loader.py [fix(loader)]: correct off-by-one expert-count guard in load_experts (#2026) 2026-06-07 23:41:04 +08:00
moe_kernel.py [fix]: fix --numa-nodes handling (#1904) 2026-03-31 17:50:22 +08:00