kvcache-ai-ktransformers/kt-kernel/examples
Jiaqi Liao fcf8882075
Some checks are pending
Book-CI / test-2 (push) Waiting to run
Book-CI / test (push) Waiting to run
Book-CI / test-1 (push) Waiting to run
Deploy / deploy (macos-latest) (push) Waiting to run
Deploy / deploy (ubuntu-latest) (push) Waiting to run
Deploy / deploy (windows-latest) (push) Waiting to run
[Feature] Add avx-based kimi-k2 support (#1656)
* support Kimi-K2-Thinking original weight
fix amx kernel bug

* update k2 avx kernel.

* feat: add CPUInfer write buffer task

* [feat]: add kimi k2 cpu write buffer support

- Implement write_weights_to_buffer function in k2-moe.hpp for extracting GPU expert weights
- Fix down (w2) weight column-wise slicing for different TP configurations
- Support three TP scenarios: cpu_tp == gpu_tp, cpu_tp > gpu_tp, cpu_tp < gpu_tp
- Add comprehensive test cases for weight extraction validation
- Ensure compatibility with Kimi model's MoE architecture

* [fix]: correct write_weight_scale_to_buffer expert offset calculation

Fixed the bug in write_weight_scale_to_buffer_task where expert offsets in GPU buffers were incorrectly calculated. Changed from using per_expert_gpu sizes to using full gpu_tp sizes, ensuring correct memory layout for multi-expert scenarios.

Also added benchmark scripts for k2 moe and write buffer operations, and cleaned up debug output in test files.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* [feat]: add write buffer wrapper

* [fix] fix comment

---------

Co-authored-by: ouqingliang <1692110604@qq.com>
Co-authored-by: Claude <noreply@anthropic.com>
2025-12-02 16:01:07 +08:00
..
.gitignore add kt-kernel 2025-10-12 05:13:00 +00:00
configuration_deepseek_v3.py add kt-kernel 2025-10-12 05:13:00 +00:00
modeling_deepseek_v3.py add kt-kernel 2025-10-12 05:13:00 +00:00
repro_llamafile_re.py fix kt-kernel installation issue (#1603) 2025-11-12 15:56:02 +08:00
test-debug.py update kt-kernel 2025-11-03 15:19:52 +08:00
test_apply_rope.py add kt-kernel 2025-10-12 05:13:00 +00:00
test_attention.py update kt-kernel 2025-11-03 15:19:52 +08:00
test_awq_moe_amx.py update kt-kernel 2025-11-03 15:19:52 +08:00
test_deepseekv3.py update kt-kernel 2025-11-03 15:19:52 +08:00
test_deepseekv3_prefill.py update kt-kernel 2025-11-03 15:19:52 +08:00
test_deepseekv3_prefill_speed.py update kt-kernel 2025-11-03 15:19:52 +08:00
test_gate.py update kt-kernel 2025-11-03 15:19:52 +08:00
test_k2_moe_amx.py [Feature] Add avx-based kimi-k2 support (#1656) 2025-12-02 16:01:07 +08:00
test_k2_write_buffer.py [Feature] Add avx-based kimi-k2 support (#1656) 2025-12-02 16:01:07 +08:00
test_linear.py update kt-kernel 2025-11-03 15:19:52 +08:00
test_mla.py update kt-kernel 2025-11-03 15:19:52 +08:00
test_mla_qlen.py update kt-kernel 2025-11-03 15:19:52 +08:00
test_mla_quant.py update kt-kernel 2025-11-03 15:19:52 +08:00
test_mla_simple.py add kt-kernel 2025-10-12 05:13:00 +00:00
test_mla_torch.py update kt-kernel 2025-11-03 15:19:52 +08:00
test_mlp.py update kt-kernel 2025-11-03 15:19:52 +08:00
test_moe.py update kt-kernel 2025-11-03 15:19:52 +08:00
test_moe_amx.py update kt-kernel 2025-11-03 15:19:52 +08:00
test_moe_kernel.py update kt-kernel 2025-11-03 15:19:52 +08:00
test_moe_kml.py update kt-kernel 2025-11-03 15:19:52 +08:00
test_rope.cpp add kt-kernel 2025-10-12 05:13:00 +00:00
test_rope.py add kt-kernel 2025-10-12 05:13:00 +00:00
test_softmax.py add kt-kernel 2025-10-12 05:13:00 +00:00
torch_attention.py add kt-kernel 2025-10-12 05:13:00 +00:00