Skip to content

Commit e69c677

Browse files
authored
[refactor] fix third_party issue (#1632)
* [refactor]: relocate third_party directory * [fix]: fix custom_flashinfer for kt-sft
1 parent 46af8fc commit e69c677

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+27
-86
lines changed

.gitmodules

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
[submodule "kt-kernel/third_party/llama.cpp"]
2-
path = kt-kernel/third_party/llama.cpp
1+
[submodule "third_party/llama.cpp"]
2+
path = third_party/llama.cpp
33
url = https://github.com/ggerganov/llama.cpp.git
4-
[submodule "kt-kernel/third_party/pybind11"]
5-
path = kt-kernel/third_party/pybind11
4+
[submodule "third_party/pybind11"]
5+
path = third_party/pybind11
66
url = https://github.com/pybind/pybind11.git
7+
[submodule "third_party/custom_flashinfer"]
8+
path = third_party/custom_flashinfer
9+
url = https://github.com/kvcache-ai/custom_flashinfer.git
10+
branch = fix-precision-mla-merge-main

kt-kernel/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,10 @@ message(STATUS "ARCH_FLAGS: ${ARCH_FLAGS}")
387387
add_compile_options("$<$<COMPILE_LANGUAGE:CXX>:${ARCH_FLAGS}>")
388388
add_compile_options("$<$<COMPILE_LANGUAGE:C>:${ARCH_FLAGS}>")
389389

390-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/pybind11 ${CMAKE_CURRENT_BINARY_DIR}/third_party/pybind11)
391-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/llama.cpp ${CMAKE_CURRENT_BINARY_DIR}/third_party/llama.cpp)
390+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../third_party/pybind11 ${CMAKE_CURRENT_BINARY_DIR}/third_party/pybind11)
391+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../third_party/llama.cpp ${CMAKE_CURRENT_BINARY_DIR}/third_party/llama.cpp)
392392

393-
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party)
393+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../third_party)
394394
if(KTRANSFORMERS_USE_CUDA)
395395
include(CheckLanguage)
396396
check_language(CUDA)
@@ -438,7 +438,7 @@ endif()
438438
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_DIR1)
439439
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/cpu_backend SOURCE_DIR2)
440440
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/operators/llamafile SOURCE_DIR3)
441-
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/third_party/llamafile SOURCE_DIR4)
441+
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/../third_party/llamafile SOURCE_DIR4)
442442
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/operators/kvcache SOURCE_DIR5)
443443
# message(STATUS "SOURCE_DIR3: ${SOURCE_DIR3}")
444444

kt-kernel/README.md

Lines changed: 1 addition & 1 deletion

kt-kernel/install.sh

Lines changed: 7 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,6 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
install_dependencies() {
5-
echo "Checking and installing system dependencies..."
6-
7-
# Determine if we need to use sudo
8-
SUDO=""
9-
if [ "$EUID" -ne 0 ]; then
10-
if command -v sudo &> /dev/null; then
11-
SUDO="sudo"
12-
else
13-
echo "Warning: Not running as root and sudo not found. Package installation may fail."
14-
echo "Please run as root or install sudo."
15-
fi
16-
fi
17-
18-
if command -v conda &> /dev/null; then
19-
echo "Installing cmake via conda..."
20-
conda install -y cmake
21-
else
22-
echo "Warning: conda not found. Skipping cmake installation via conda."
23-
echo "Please install conda or manually install cmake."
24-
fi
25-
26-
# Detect OS type
27-
if [ -f /etc/os-release ]; then
28-
. /etc/os-release
29-
OS=$ID
30-
elif [ -f /etc/debian_version ]; then
31-
OS="debian"
32-
elif [ -f /etc/redhat-release ]; then
33-
OS="rhel"
34-
else
35-
echo "Warning: Unable to detect OS type. Skipping dependency installation."
36-
return 0
37-
fi
38-
39-
# Install dependencies based on OS
40-
case "$OS" in
41-
debian|ubuntu|linuxmint|pop)
42-
echo "Detected Debian-based system. Installing libhwloc-dev and pkg-config..."
43-
$SUDO apt update
44-
$SUDO apt install -y libhwloc-dev pkg-config
45-
;;
46-
fedora|rhel|centos|rocky|almalinux)
47-
echo "Detected Red Hat-based system. Installing hwloc-devel and pkgconfig..."
48-
$SUDO dnf install -y hwloc-devel pkgconfig || $SUDO yum install -y hwloc-devel pkgconfig
49-
;;
50-
arch|manjaro)
51-
echo "Detected Arch-based system. Installing hwloc and pkgconf..."
52-
$SUDO pacman -S --noconfirm hwloc pkgconf
53-
;;
54-
opensuse*|sles)
55-
echo "Detected openSUSE-based system. Installing hwloc-devel and pkg-config..."
56-
$SUDO zypper install -y hwloc-devel pkg-config
57-
;;
58-
*)
59-
echo "Warning: Unsupported OS '$OS'. Please manually install libhwloc-dev and pkg-config."
60-
;;
61-
esac
62-
}
63-
64-
install_dependencies
65-
664
usage() {
675
cat <<EOF
686
Usage: $0 [SUBCOMMAND] [BUILD_OPTIONS]
@@ -78,7 +16,6 @@ SUBCOMMANDS:
7816
BUILD_OPTIONS (for "build" or "all"):
7917
(none) Auto-detect CPU and configure automatically (recommended)
8018
--manual Skip auto-detection, use manual configuration (see below)
81-
--skip-deps Skip deps step even with subcommand "all"
8219
--no-clean Do not delete local build/ before building (default cleans)
8320
8421
AUTO-DETECTION (Default):
@@ -90,7 +27,7 @@ MANUAL CONFIGURATION:
9027
Use --manual flag and set these environment variables before running:
9128
9229
CPUINFER_CPU_INSTRUCT - CPU instruction set
93-
Options: NATIVE, AVX512, AVX2
30+
Options: NATIVE, AVX512, AVX2, FANCY
9431
CPUINFER_ENABLE_AMX - Enable Intel AMX support
9532
Options: ON, OFF
9633
@@ -107,7 +44,7 @@ Manual configuration examples:
10744
Example manual build:
10845
export CPUINFER_CPU_INSTRUCT=AVX512
10946
export CPUINFER_ENABLE_AMX=OFF
110-
$0 --manual
47+
$0 build --manual
11148
11249
Advanced option (for binary distribution):
11350
FANCY - AVX512 with full extensions for Ice Lake+/Zen 4+
@@ -206,7 +143,6 @@ build_step() {
206143
while [[ $# -gt 0 ]]; do
207144
case "$1" in
208145
--manual) MANUAL_MODE=1; shift ;;
209-
--skip-deps) shift ;; # ignore here
210146
--no-clean) CLEAN_BUILD=0; shift ;;
211147
-h|--help) usage ;;
212148
*) break ;;
@@ -241,9 +177,9 @@ build_step() {
241177
echo " Configuration: NATIVE + AMX=ON (best performance)"
242178
echo ""
243179
echo " ⚠️ Note: If you plan to use LLAMAFILE backend, use manual mode:"
244-
echo " export CPUINFER_CPU_INSTRUCT=AVX512(AVX2/FANCY)"
180+
echo " export CPUINFER_CPU_INSTRUCT=AVX512 # or AVX2/FANCY"
245181
echo " export CPUINFER_ENABLE_AMX=OFF"
246-
echo " ./install.sh --manual"
182+
echo " ./install.sh build --manual"
247183
else
248184
echo "ℹ AMX instructions not detected"
249185
export CPUINFER_CPU_INSTRUCT=NATIVE
@@ -252,7 +188,7 @@ build_step() {
252188
fi
253189

254190
echo ""
255-
echo "To use manual configuration instead, run: $0 --manual"
191+
echo "To use manual configuration instead, run: $0 build --manual"
256192
echo ""
257193
else
258194
# Manual mode - validate user configuration (no exports)
@@ -336,11 +272,7 @@ case "$SUBCMD" in
336272
build_step "$@"
337273
;;
338274
all)
339-
if [[ " ${*:-} " == *" --skip-deps "* ]]; then
340-
build_step "$@"
341-
else
342-
install_dependencies
343-
build_step "$@"
344-
fi
275+
install_dependencies
276+
build_step "$@"
345277
;;
346278
esac

kt-kernel/operators/amx/test/mmq-test.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2376,7 +2376,9 @@ bool ggml_compute_forward_mul_mat_use_amx(struct ggml_tensor* dst) {
23762376
static thread_local bool is_first_time = true;
23772377
if (is_first_time) {
23782378
#pragma omp single
2379-
{ ggml_amx_init(); }
2379+
{
2380+
ggml_amx_init();
2381+
}
23802382

23812383
// load tile config
23822384
ggml_tile_config_init();

kt-kernel/operators/amx/test/mmq.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2372,7 +2372,9 @@ bool ggml_compute_forward_mul_mat_use_amx(struct ggml_tensor* dst) {
23722372
static thread_local bool is_first_time = true;
23732373
if (is_first_time) {
23742374
#pragma omp single
2375-
{ ggml_amx_init(); }
2375+
{
2376+
ggml_amx_init();
2377+
}
23762378

23772379
// load tile config
23782380
ggml_tile_config_init();

kt-sft/install.sh

100644100755
File mode changed.

third_party/custom_flashinfer

Submodule custom_flashinfer added at fd94393

0 commit comments

Comments
 (0)