1358 Commits

Author SHA1 Message Date
yyj 7fbbc20d31 [docs](sft): prepare DeepSeek V4 Flash 0.7.2 quickstart (#2247)
* docs(sft): add DeepSeek V4 Flash release quickstart

* docs(release): validate DeepSeek V4 Flash SFT quickstart

* Update README.md
2026-10-15 16:43:20 +08:00
losewayy a02efe36b5 [feat](kt-kernel): add AVX2 RAWINT4 routed-expert LoRA SFT backend (#2243)
* [feat](kt-kernel): add AVX2 RAWINT4 routed-expert LoRA SFT backend

* [fix](kt-kernel): fix RAWINT4 SFT wrapper and clamp gradients

Allow the RAWINT4 production wrapper on AVX2 runtimes and reject shared backward pools before construction. Preserve FP32 clamp decisions across BF16 caches, remove unused configuration state, and cover rectangular dimensions, multiblock dX, clamp boundaries, and production wrapper tasks with tighter LoRA gradient checks.

* [fix](kt-kernel): plumb swiglu_limit through the RAWINT4 SFT python path

The production wrapper hard-zeroed swiglu_limit for every format except MXFP4, and both SFT python gates rejected non-zero values for RAWINT4 even though MOESFTConfig carries the field and the AVX2 kernel implements the clamp in forward plus the gradient mask in backward. RAWINT4_SFT now accepts a finite non-negative swiglu_limit end to end, while the AMX K2 part (which computes plain SiLU) fails fast instead of silently dropping the clamp. The production-wrapper contract test is parametrized over swiglu_limit 0 and 2, a model-config plumb test covers plain and nested text_config shapes, the __main__ entry exercises both limits, and bench_rawint4_sft.py gains --swiglu-limit.
v0.7.2
2026-10-12 19:30:24 +08:00
Max 156016c4ef [fix](kt-kernel): size per-NUMA thread counters by physical NUMA id (#2228)
* fix(kt-kernel): size per-NUMA thread counters by physical NUMA id

WorkerPool::init() and NumaJobDistributor::init() indexed the per-NUMA
worker counter by the *physical* NUMA ID while sizing it by the number
of subpools. A subpool mapped to a NUMA node whose ID is >= the subpool
count (e.g. --kt-threadpool-count 1 --kt-numa-nodes 1) therefore read
and wrote out of bounds, shifting the per-node core offset and logging
"Core ... not found" (or corrupting the heap and aborting).

Size the counter vector to cover every NUMA ID present in the subpool
map. Add a CPU regression test that builds two subpools on a
high-numbered NUMA node and verifies the worker thread offsets.

* test(kt-kernel): add single-subpool regression case for #2221

The existing fixture always builds two subpools, so on a dual-socket host
(NUMA IDs [0, 1]) the two-element counter stays in bounds and the old code
passes there. Add a single subpool mapped to a nonzero NUMA node: the size-1
counter is then indexed at an ID >= 1, reproducing #2221 on any multi-NUMA
host. Verified that this case fails/aborts on the unpatched code and passes
with the fix.

Suggested by @f-wunderlich in review.
2026-10-12 12:56:12 +08:00
Pratik Gandhi 6d836359a5 [docs]: fix links to moved injection and Kimi-K2 native tutorials (#2223) 2026-10-12 12:45:01 +08:00
Mohammad Hijjawi 44fbb184d5 [fix](cli): fill in the model name and path in kt model remove/edit warnings (#2220) 2026-10-12 12:44:24 +08:00
yyj 5d048e5165 [fix]: retain mmap owners for AVX2 RAWINT4 (#2225)
* fix: retain mmap owners for AVX2 RAWINT4

* test: remove RAWINT4 mmap lifetime regression file
2026-10-10 16:16:45 +08:00
Peilin Li 6160538c81 docs: restore single-column Figure 2 in KT-FT paper
Co-authored-by: Peilin Li <177450066+JimmyPeilinLi@users.noreply.github.com>
paper-ktft-v1.1
2026-10-10 12:11:10 +08:00
AY_novel cde34b75f3 [perf](kt-kernel): set up the llamafile forward_many buffers only for the experts in use (#2233)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 11:49:10 +08:00
yyj c76ff29b2a [perf](kt-kernel): fuse CPU BF16 gradient norm reduction (#2234) 2026-10-10 11:10:38 +08:00
Peilin Li 2ac8cf9c88 docs: publish KTransformers-FineTune author preprint
Co-authored-by: Peilin Li <177450066+JimmyPeilinLi@users.noreply.github.com>
paper-ktft-v1
2026-10-08 12:10:37 +08:00
yyj a5d7ad9047 feat(sft) Deepseek v4 flash LoRA (#2216)
* feat(sft): add native MXFP4 routed-expert LoRA kernels

* test(sft): validate DeepSeek V4 MXFP4 routed experts

* feat(sft): AVX2 tier for MXFP4 routed-expert LoRA SFT

MXFP4_SFT_MOE on non-AVX512 builds, same Python contract as the AMX /
AVX512-BF16 kernel from #2185 (KTMoEWrapper(method="MXFP4_SFT")), for
AVX2+FMA+F16C hosts (Zen 2/3 EPYC, older Xeons).

* operators/avx2/sft_mxfp4-moe.hpp: AVX2_SFT_MXFP4_MOE_TP part on top of
  AVX2_MXFP4_MOE_TP (frozen packed E2M1/UE8M0 base, LoRA gate/up/down,
  V4 swiglu clamp, transpose-free packed-weight dX, authoritative LoRA grads).
* operators/moe-sft-tp.hpp: AVX2 result merge; AVX-512 merge loops and the
  block-FP8 staging guarded so the wrapper builds without AVX-512.
* ext_bindings.cpp: bind MXFP4_SFT_MOE -> TP_MOE_SFT<AVX2_SFT_MXFP4_MOE_TP>
  when USE_AMX_AVX_KERNEL is off; MOESFTBindings no longer AMX-only.
* python/sft/backend.py: runtime reports cpu_variant=avx2, kernel avx2-mxfp4-g32.
* test_mxfp4_sft_numerical.py: inference regression uses AVX2MXFP4_MOE when
  AMXFP4_KGroup_MOE is absent.

Validated on 2x EPYC 7452 (AVX2, no AVX-512): test_mxfp4_sft_numerical.py
TP1/TP2 all stages rel-L2 <= 0.4% (limits 3-5%); validate_dsv4_mxfp4_sft_layer.py
on DeepSeek-V4-Flash-0731 layer 3, TP1 and TP2: passed, forward/grad_input/
LoRA grads rel-L2 0.10-0.29%, base weights unchanged.

Note: the build uses -ffast-math, so exp() past the float range is undefined;
the scalar sigmoid tails clamp the argument like the vector path.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Mgsduzz2fx1gSvfHbR8RZ

* fix(sft): clamp MXFP4 scalar-tail sigmoid exponent

* feat(sft): integrate native V4 experts with LoRA training and export

Wrap only routed experts while preserving V4 routing and shared branches. Validate native checkpoint provenance and stream a BF16 non-expert cache without dequantizing routed experts.

Add audited static SGLang export and reproducible training, resume and generation acceptance helpers. CPU retain/GPU recompute GAS1/GAS4 smoke and 265 KT regression tests pass; long-run quality and resume acceptance remain in progress.

* fix(sft): retain async inference buffers until CUDA work completes

* test(sft): isolate V4 adapter effects with matched-kernel controls

Allow baseline and non-expert-only exports to retain a zero-B expert adapter so all ablations execute the same native forward kernel. Add paired held-out generation reporting with explicitly diagnostic lexical metrics.

* test(sft): compare PEFT targets semantically during V4 resume audits

* test(sft): cancel queued V4 inference checks after a failed request

* test(sft): preserve raw V4 responses before finite-output validation

* feat: prepare V4 cache atomically and package static adapter export

* build: preserve accepted CUDA carriers across Python ABIs

* test: retain FP8 loading contracts after V4 wrapper integration

* test: exclude historical concatenated-sample smoke from delivery

* test(sft): audit unpacked batches and single-GPU resume state

* docs(sft): align April V4 recipe with approved unpacked delivery

* test: keep frozen-parameter audit indices exact for large tensors

* test: record the loaded native backend in acceptance evidence

* test: timestamp training audit events for startup measurements

* docs: pin V4 serving dependencies and account for reserved token slots

* [refactor](sft): keep V4 follow-up focused on runtime integration

---------

Co-authored-by: 05yuki <ceu.azul.samu@gmail.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-30 21:29:43 +08:00
Tai An c40722bf04 fix(kt-kernel): cap compressed-tensors below the torch>=2.10 releases (#2116)
Signed-off-by: Anai-Guo <antai12232931@outlook.com>
2026-09-23 13:07:33 +08:00
github-actions[bot] f7607c0f66 [build]: sync sglang submodule to 541ddc37cbc92c60dc748db5ff1a2aad0b069a80 (#2166)
Co-authored-by: ovowei <80044717+ovowei@users.noreply.github.com>
2026-09-19 11:06:54 +08:00
AY_novel 105359b4bf [perf](kt-kernel): keep the pre-permuted MXFP4 activations for prefill-sized inputs only (#2209)
Co-authored-by: yuki <ceu.azul.samu@gmail.com>
2026-09-17 22:46:19 +08:00
AY_novel 4bf0974553 [fix](kt-kernel): honour physical_to_logical_map in the BF16 TP loader (#2210)
Co-authored-by: yuki <ceu.azul.samu@gmail.com>
2026-09-17 22:44:33 +08:00
yyj 0b954fe4ca [docs]: add English Kimi K2.5 LoRA tutorial (#2211) 2026-09-16 19:14:29 +08:00
yyj 0dce4c9b09 [docs] Add Kimi install guidance and python 3.11 wheel(#2207)
* [build](release): add immutable CPython wheel supplementation

* [docs]: document Python 3.11 and 3.12 Kimi installation

* [docs]: clarify supplementary release availability

* [docs]: publish Python 3.11 installation instructions

* [docs]: simplify Kimi guide and remove supplement tooling

Preserve LF/PEFT/TRL packaging notes and validated installation commands. Remove the one-off wheel supplement script, its tests, and release instructions.
v0.7.1
2026-09-14 22:56:13 +08:00
AY_novel f312728aa9 [perf](kt-kernel): permute MXFP4 activations once per expert, not per weight slice (#2205) 2026-09-14 14:00:38 +08:00
yyj 4882505c9a docs: add Kimi K2.5 PyPI LoRA guide (#2206)
* [docs]: add reproducible Kimi K2.5 PyPI LoRA tutorial

* [docs]: highlight Kimi K2.5 and K2.6 LoRA support

* Update README to simplify LoRA fine-tuning entry

* Add updates section to README.md

* [docs]: clarify clean Kimi setup and held-out evaluation

* [docs]: explain pinned model downloads on offline training hosts

* [docs]: isolate Kimi caches in the tutorial work directory

* [docs]: simplify Kimi LoRA installation and training tutorial
2026-09-13 21:52:06 +08:00
yyj 105cee4bd1 fix(release): preserve native payload layout in candidate wheels (#2204) 2026-09-13 17:51:54 +08:00
yyj 440df94802 [script]: add Kimi LoRA script (#2202)
* [docs]: add Kimi LoRA tutorial

* Delete .github/release/examples/kimi-k25/TUTORIAL_zh.md

* Delete .github/release/examples/kimi-k25/README.md
2026-09-11 11:26:18 +08:00
yyj 27b04cef5c ci: promote manually validated wheels without exporting PyPI credentials (#2199) 2026-09-11 02:04:16 +08:00
yyj 0eb060c583 fix(ci): preserve setup-python shared library path during release (#2198) 2026-09-11 01:17:50 +08:00
yyj 5632f7197e release: align post4 stack and allow CI artifact-only builds (#2197) v0.7.0.post4 2026-09-11 01:11:26 +08:00
yyj a3695f1a83 ci(release): gate four-main PyPI publishing on immutable wheels and model E2E (#2194)
* ci(release): prepare source builds from four main snapshots

* docs(release): add verified Kimi RAWINT4 LoRA smoke configs

* ci(release): gate four-main PyPI promotion on immutable wheels and model E2E
2026-09-11 00:52:24 +08:00
yyj 7c35863f62 ci: add model E2E acceptance for community PRs and PyPI releases (#2195)
* ci: add isolated model E2E acceptance for PR wheels and PyPI

* ci: recheck GPU occupancy before each model starts

* ci: disable inherited container healthchecks during acceptance

* ci: wait for free GPUs before native import validation

* docs: record qj5090 acceptance infrastructure validation

* ci: add immutable candidate and public PyPI release acceptance gates
2026-09-11 00:50:36 +08:00
yyj 61cb5cded5 fix(kt-kernel): restore MXFP4 decode fallback without AVX512 BF16 (#2196)
* fix(kt-kernel): restore MXFP4 decode fallback without AVX512 BF16

* Delete kt-kernel/test/per_commit/test_mxfp4_decode_bf16_guard.py
2026-09-10 23:14:05 +08:00
yyj aa2cd3072f [feat] Add native RAWINT4 routed-expert LoRA SFT for Kimi K2.5/K2.6 (#2186)
* [feat](sft): add K2 MoE SFT backend

* [feat](sft): enable packed KGroup backward for K2 SFT

* [feat](serving): add KT LoRA to SGLang adapter converter

* [test]: cover KT SFT and composite LoRA serving paths

* [perf](bench): add reusable KT E2E benchmark harness

* [test](sft): add K2 MoE AMX and real Kimi load smoke cases

* [perf](bench): add K2 SFT packed backward profile harness

* [test](sglang): cover Qwen3.5 LoRA shape filters

* [perf](sft): add K2 forward profiling logs

* [docs](sft): clarify K2 packed backward flow

* [docs](sft): number K2 backward comment steps

* chore: mirror sap4 loader baseline

* Add K2 SFT profiling ranges

* Add backward NVTX ranges for K2 SFT profiling

* perf(sft): add rank8 LoRA backward vector paths

* perf(sft): reuse down LoRA bprop cache

* [perf]: add K2 RAWINT4 prefill mat-mat dispatch

* [perf] Refactor K2 RAWINT4 prefill accumulation

* [perf]: add blocked RAWINT4 prefill backend

Cherry-picked from be40f8e with local amx.py conflict resolution.

* Optimize blocked RAWINT4 decode vecmul

* perf(sft): checkpoint qj5090 packed backward baseline

* perf(sft): batch expert LoRA backward as matmul

* perf(sft): align K2 base backward with BF16 matmul

* Optimize K2 SFT backward workspace path

* docs(sft): hand off RAWINT4 KGroup build and Kimi configs

* [feat](kt-kernel): add Kimi RAWINT4 LoRA SFT kernels

* [feat](kt-kernel): integrate Kimi RAWINT4 LoRA SFT

* [fix](sft): preserve input gradients through frozen routers

Build the routing graph when either activations or router parameters require gradients, while respecting the ambient grad mode. Keep frozen router parameters frozen and reject detached routing weights whenever gradients are needed.

Correct the existing frozen-router expectation and cover input-gradient equivalence for linear, DeepSeek/Kimi and GLM routing, checkpoint reuse, grad modes and detached-output failures.

Validated 62 routing/shared-expert/checkpoint tests on PyTorch 2.9.1 and a two-step Kimi K2.5 RAWINT4 four-GPU S512 LoRA smoke with per-rank routing-input gradient audits.

* [perf](kt-kernel): accelerate RAWINT4 prefill and backward

Reuse decoded weight columns across prefill rows and prepack BF16 backward coefficients into bounded per-worker panels. Use AMX BF16 tiles when available, retaining the AVX512-BF16 path and frozen base weights.

Balance expert work, parallelize cache copies and router reductions, and correct the signed INT4 -8 dot-product boundary. Add a CPU replay benchmark and forward/backward panel regressions.

Validated on sap4 with Kimi K2.5, TP1/TP2 replay, AMX and AVX-512 multi-GPU training, gradient windows, and saved LoRA artifacts. User-facing clean builds and AMD hardware remain separate validation work.

* [fix](sft): limit default OpenMP pools to the CPU owner

Keep the affinity-visible physical-core budget on rank 0 and default non-owner distributed ranks to one thread. Preserve explicit generic and KT-specific thread overrides, including intentional single-thread settings.

Cover single-process behavior, non-owner ranks, repeated configuration, and explicit overrides. The 109 configuration, activation-policy, and backend-dispatch tests pass.

---------

Co-authored-by: yyj <yyj@qj5090.local>
Co-authored-by: djh <jd4136@columbia.edu>
2026-09-10 17:05:16 +08:00
yyj 9b0da97c91 [feat](docker): add docker image and API guide (#2191) 2026-09-09 18:57:11 +08:00
Huang Wensen 6d460cc107 [feat](kt-kernel): packed-int4-resident AVX-VNNI-256 GPTQ INT4 backend (#2187) 2026-09-07 20:20:04 +08:00
yyj 308200c940 perf(sft): defer backward repack wait to CPU consumer (#2188) 2026-09-07 17:39:26 +08:00
Pan-Boyi 31985f40bc [docs](kt-kernel): DeepSeek-V4-Flash single-NPU deployment tutorial for Ascend (#2159) 2026-09-01 20:11:02 +08:00
Pan-Boyi 040a4980ec [feat](kt-kernel): Ascend NPU backend for single-card DeepSeek-V4-Flash offload (#2157) 2026-09-01 20:10:24 +08:00
yyj 3a19fd6d88 [perf](kt-kernel): make AVX512 MXFP4 decode memory-bound (#2181) 2026-09-01 11:45:25 +08:00
AY_novel 7c17c96503 [feat](kt-kernel): NVFP4 routed experts on the AVX2 FP4 backend (#2176) 2026-09-01 11:44:36 +08:00
yyj 21095b9912 [build] sync SGLang for KT LoRA serving (#2182)
Advance third_party/sglang to main@3424f35d, including all-target KT MoE adapter serving, the MXFP4 routed-scaling fix, and the GLM-5.3 MTP metadata fix.
2026-08-31 17:19:23 +08:00
AY_novel 948129159a [perf](kt-kernel): AVX2 MXFP4 grouped fast path for decode and prefill (#2175)
The AVX2 MXFP4 MoE kernel decoded FP4 weights with 128-bit SSSE3 PSHUFB
and converted the BF16 activations per row, costing roughly 28
shuffle-port uops per 32 weights. On Zen 2, whose two shuffle pipes are
the binding resource here, that left the kernel compute-bound at about
39-45 GB/s per socket, well under the 83.6 GB/s STREAM ceiling of the
same socket.

Add a fast path for the common group_size == 32 layout:

- decode a whole 32-value k-group with one 256-bit VPSHUFB pair,
- fuse the BF16->FP32 widen and shift into unpack(zero, u16), which is a
  single shuffle,
- drop the reordering shuffles entirely by converting each activation
  row once into the decoder's natural in-lane emission order
  ({0,2,4,6,1,3,5,7,...} per 32-group) instead of permuting the weights,
- process tokens in blocks of 4 so each decoded group is amortized over
  4 accumulators, with a single-row remainder loop that also serves
  decode (m == 1).

This is about 9 shuffle uops per 32 weights, which makes the kernel
memory-bound. Large per-expert batches fall back to the generic path so
the per-thread FP32 staging buffer stays bounded.

Measured on 2x EPYC 7452 (AVX2, 2x30 threads) with DeepSeek-V4-Flash
MXFP4:

- microbench per layer-token: m=1 989 -> 440 us (2.25x),
  m=4 1713 -> 1002 us, m=16 6567 -> 3829 us, m=64 25651 -> 19361 us
- end-to-end 512-token decode: 18.4 -> 29.5 tok/s at 65K context, and
  18.3 -> 32.3 tok/s on a 1M-context serving profile
- NUMA pool scaling verified unchanged (1937 us 1 pool -> 968 us 2 pools)

Output stays coherent in generation smoke tests on both profiles.

Co-authored-by: 05yuki <ceu.azul.samu@gmail.com>
2026-08-28 14:48:22 +08:00
yyj 063500785b build: sync GLM-5.3 config compatibility fix (#2177) 2026-08-27 22:24:50 +08:00
yyj 41613064c7 feat(GLM): add native GLM-5.3-flash support (#2173)
* feat: support SwiGLU limit for block FP8 experts

* perf(fp8): add native layerwise batch transport

* feat(fp8): support layerwise transport for TP1/2/4/8

* release: prepare GLM-5.3-flash support

* docs(glm): refine GLM-5.3-flash documentation

* docs(glm): simplify release announcement
v0.7.0.post1
2026-08-26 22:45:12 +08:00
Peilin Li c40d37c63c docs: add fine-tuning milestones to README updates (#2171)
Co-authored-by: JimmyPeilinLi <lipeilin@mail.nwpu.edu.cn>
2026-08-25 01:48:41 +08:00
Peilin Li 62d7b69e75 [docs]: add English fine-tuning cookbook (#2170)
Co-authored-by: JimmyPeilinLi <lipeilin@mail.nwpu.edu.cn>
2026-08-25 01:35:14 +08:00
Peilin Li 902ab98d46 [docs]: add easy-to-use fine-tuning cookbook (#2169)
Co-authored-by: JimmyPeilinLi <lipeilin@mail.nwpu.edu.cn>
2026-08-25 01:13:41 +08:00
Octopus 95009ea685 Add MiniMax-M3 and MiniMax-M2.7 to the kt-cli model registry (#2112) 2026-08-21 17:53:58 +08:00
liyuemathematician 41e54fd44c [docs]: use official LlamaFactory repository in VLM guide (#2165) 2026-08-18 20:10:50 +08:00
yyj 517e7a4368 fix(build): keep AVX2 wheel free of AVX512 flags (#2164) 2026-08-18 17:28:00 +08:00
yyj d406efc848 ci: run release jobs on self-hosted runner (#2163) 2026-08-18 17:15:40 +08:00
yyj ea81f4e9e5 ci: automate coordinated KT PyPI releases (#2162) 2026-08-18 17:09:59 +08:00
yyj e80614fc2d [feat](kt-sft): Activation reuse & Int8 kernel refactor & native block-FP8 LoRA SFT (#2141)
* feat(sft): support distributed activation reuse policies

* feat(sft): add frozen-base INT8 LoRA training

* fix(sft): make INT8 expert LoRA rank-zero authoritative

* fix(sft): preserve DeepSeek router LoRA routing

* feat(sft): enable persistent INT8 LoRA training

* perf(sft): accelerate INT8 VNNI with oneDNN BRGEMM

* perf(int8): fuse oneDNN compensation into backward repack

* [feat]: support BF16 expert LoRA training

* [fix]: honor forwarded activation policy in SFT workers

* feat(sft): add native block-FP8 routed expert LoRA

* feat(sft): expose explicit expert placeholder ownership

* fix(sft): publish fused adapter artifacts atomically

* feat(sft): own artifact and adapter lifecycle contracts

* fix(sft): harden artifact and rank-local contracts

* fix(sft): auto-adapt owner before adapter restore

* style(sft): keep lifecycle comments concise

* fix(sft): require fused adapter manifests

* test(sft): use spawn for distributed workers

* fix(sft): preserve runtime checkpoint metadata

* fix(sft): validate wrapped runtime configuration

* fix(sft): preserve expert format provenance

* fix(sft): own routed experts during device dispatch

* test(sft): lock explicit quantization conflict

* fix(cpu): make shared memory buffers lifetime-safe

* release: prepare v0.7.0
v0.7.0
2026-08-17 16:25:14 +08:00
liyuemathematician 168f581676 [feat](sft): support Qwen VLM MoE fine-tuning (#2156) 2026-08-17 10:51:55 +08:00
github-actions[bot] eb9b70c411 [build]: sync sglang submodule (#2069) 2026-08-08 18:45:46 +08:00