[Kimi-K3] Migrate FlashKDA to PyTorch stable ABI (#50818)

Signed-off-by: Thien Tran <gau.nernst@yahoo.com.sg>
Co-authored-by: Shengqi Chen <harry-chen@outlook.com>
This commit is contained in:
Thien Tran
2026-08-03 17:18:08 -07:00
committed by GitHub
co-authored by Shengqi Chen
parent 41ba11b841
commit 11f88260a2
3 changed files with 19 additions and 7 deletions
+12 -5
View File
@@ -1,17 +1,24 @@
#include "core/registration.h"
#include "flash_kda.h"
TORCH_LIBRARY(_flashkda_C, m) {
m.def("get_workspace_size(int T_total, int H, int N=1) -> int",
&get_workspace_size);
#include <torch/csrc/stable/library.h>
STABLE_TORCH_LIBRARY(_flashkda_C, m) {
m.def("get_workspace_size(int T_total, int H, int N=1) -> int");
m.def(
"fwd(Tensor q, Tensor k, Tensor v, Tensor g, Tensor beta, float scale, "
"Tensor(a!) out, Tensor workspace, Tensor A_log, Tensor dt_bias, "
"Tensor(a!) out, Tensor(c!) workspace, Tensor A_log, Tensor dt_bias, "
"float lower_bound, "
"Tensor? initial_state=None, Tensor(b!)? final_state=None, "
"Tensor? cu_seqlens=None) -> ()");
}
TORCH_LIBRARY_IMPL(_flashkda_C, CUDA, m) { m.impl("fwd", &fwd); }
STABLE_TORCH_LIBRARY_IMPL(_flashkda_C, CompositeExplicitAutograd, m) {
m.impl("get_workspace_size", TORCH_BOX(&get_workspace_size));
}
STABLE_TORCH_LIBRARY_IMPL(_flashkda_C, CUDA, m) {
m.impl("fwd", TORCH_BOX(&fwd));
}
REGISTER_EXTENSION(_flashkda_C)