From c313acba87791e798e67cbd517f8dc2994e3afdb Mon Sep 17 00:00:00 2001 From: artlesbol Date: Wed, 4 Mar 2026 14:17:13 +0800 Subject: [PATCH 01/94] =?UTF-8?q?=E6=B5=8B=E8=AF=95Jenkins=20webhook?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test.commit | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test/test.commit diff --git a/test/test.commit b/test/test.commit new file mode 100644 index 00000000..e69de29b -- Gitee From c294e36910c199c2431edfe61b5a557f2a70b468 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Wed, 4 Mar 2026 14:20:24 +0800 Subject: [PATCH 02/94] 1 --- test/test.commit | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test.commit b/test/test.commit index e69de29b..4d280d3f 100644 --- a/test/test.commit +++ b/test/test.commit @@ -0,0 +1 @@ +测试1 \ No newline at end of file -- Gitee From 49af4906abb6c4eaa9f9804a9ed526fc5e1d35ae Mon Sep 17 00:00:00 2001 From: artlesbol Date: Wed, 4 Mar 2026 15:53:48 +0800 Subject: [PATCH 03/94] 2 --- test/test.commit | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test.commit b/test/test.commit index 4d280d3f..98d30256 100644 --- a/test/test.commit +++ b/test/test.commit @@ -1 +1,2 @@ -测试1 \ No newline at end of file +测试1 +测试2 \ No newline at end of file -- Gitee From 6c8c395fc533eb28b0dac86d533db2e0c7819df1 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Wed, 4 Mar 2026 15:56:10 +0800 Subject: [PATCH 04/94] =?UTF-8?q?=E6=B5=8B=E8=AF=953?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/test.commit | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/test.commit b/test/test.commit index 98d30256..06896a6d 100644 --- a/test/test.commit +++ b/test/test.commit @@ -1,2 +1,3 @@ 测试1 -测试2 \ No newline at end of file +测试2 +测试3 \ No newline at end of file -- Gitee From c3af205d6cddb20077288e1ad5781b6d9c9210f5 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Wed, 4 Mar 2026 22:18:56 +0800 Subject: [PATCH 05/94] Jenkinsfile --- Jenkinsfile | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..6b03347d --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,72 @@ +pipeline { + // 1. 指定机器 + agent any + + // 2. 全局环境变量定义 + environment { + UV_CACHE_DIR = "${WORKSPACE}/.uv-cache" + TILELANG_TARGET = "custom_backend" + LOG_LEVEL = "DEBUG" + } + + // 3. 构建生命周期 + stages { + stage('Environment Audit') { + steps { + echo "--- [PRE-CHECK] 检查硬件驱动与环境 ---" + echo "执行命令: custom-gpu-smi (检查驱动是否正常)" + echo "执行命令: python3 --version && uv --version" + } + } + + stage('Lint & Static Check') { + steps { + echo "--- [LINT] 正在进行静态代码检查 ---" + echo "执行命令: uv run pre-commit run --all-files" + echo "执行命令: cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..." + echo "执行命令: run-clang-tidy -p build/ src/" + } + } + + stage('Build & Install') { + steps { + echo "--- [BUILD] 正在编译 C++ 内核并安装 Python 接口 ---" + echo "执行命令: uv pip install -v ." + } + } + + stage('Functional Testing') { + steps { + echo "--- [TEST] 正在执行算子功能验证 (pytest) ---" + echo "执行命令: TILELANG_TARGET=${TILELANG_TARGET} uv run pytest testing/python" + echo "预期:通过对标 CPU 结果验证算子生成正确性" + } + } + + stage('Performance Benchmarking') { + steps { + echo "--- [PERF] 正在执行算子性能压测 ---" + echo "执行命令: uv run python benchmarks/gemm_perf.py" + echo "执行命令: uv run python benchmarks/flash_attn_perf.py" + } + } + } + + // 4. 后置处理逻辑(无论成功失败都会触发) + post { + always { + echo "--- [CLEANUP] 正在清理工作区与 GPU 状态 ---" + echo "操作: 收集 reports/*.xml 到 Jenkins 仪表盘" + echo "操作: 检查是否存在 core.* 文件并归档" + echo "操作: 执行 cleanWs() 清理磁盘" + } + + success { + echo "--- [NOTIFY] 流程成功:通知 Gitee 并标记 PR 为可合并 ---" + } + + failure { + echo "--- [NOTIFY] 流程失败:正在回传报错日志至 Gitee 评论区 ---" + } + } +} \ No newline at end of file -- Gitee From 7ab0ca2bf162c643e04934566394c1d8ee0b1808 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Wed, 4 Mar 2026 22:23:08 +0800 Subject: [PATCH 06/94] =?UTF-8?q?=E6=9B=B4=E6=8D=A2node?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6b03347d..6a85c8df 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,6 @@ pipeline { // 1. 指定机器 - agent any + agent { label 'gpu_node1' } // 2. 全局环境变量定义 environment { -- Gitee From 97e8cc577b4c0fd24506dcd1bae0fe53614e7431 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Fri, 6 Mar 2026 15:43:32 +0800 Subject: [PATCH 07/94] =?UTF-8?q?lint=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6a85c8df..8f09d377 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,9 +22,19 @@ pipeline { stage('Lint & Static Check') { steps { echo "--- [LINT] 正在进行静态代码检查 ---" - echo "执行命令: uv run pre-commit run --all-files" - echo "执行命令: cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..." - echo "执行命令: run-clang-tidy -p build/ src/" + + // Step 1: 用 Python 3.9 检查 tilelang 包的 AST 语法兼容性(对应 CI 中 "Check AST with Python 3.9") + sh ''' + python3.9 -m compileall -q -f tilelang + ''' + + // Step 2: 运行 pre-commit 对全部文件执行 lint(对应 CI 中 "Pre-commit Lint") + sh ''' + if ! pipx run pre-commit run --all-files --color=always --show-diff-on-failure; then + echo "Pre-commit checks failed. Please run 'pre-commit install' and 'pre-commit run --all-files' locally to see the issues." + exit 1 + fi + ''' } } -- Gitee From 4056efa9d4fd43dc5c976f46dba5ff3e16d4b3de Mon Sep 17 00:00:00 2001 From: artlesbol Date: Fri, 6 Mar 2026 15:47:15 +0800 Subject: [PATCH 08/94] =?UTF-8?q?=F0=9F=90=9E=20fix(cicd):=20Lint=20Test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8f09d377..893c9daf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,8 +5,25 @@ pipeline { // 2. 全局环境变量定义 environment { UV_CACHE_DIR = "${WORKSPACE}/.uv-cache" - TILELANG_TARGET = "custom_backend" + TILELANG_TARGET = "metax" LOG_LEVEL = "DEBUG" + // 按优先级查找 Python 3.9:直接命令 → uv → pyenv → conda → 降级 python3 + PY39 = """${sh( + returnStdout: true, + script: ''' + if command -v python3.9 > /dev/null 2>&1; then + echo -n "python3.9" + elif command -v uv > /dev/null 2>&1 && uv python find 3.9 > /dev/null 2>&1; then + uv python find 3.9 | tr -d '\\n' + elif ls ${HOME}/.pyenv/versions/3.9*/bin/python3.9 > /dev/null 2>&1; then + ls ${HOME}/.pyenv/versions/3.9*/bin/python3.9 | head -1 | tr -d '\\n' + elif command -v conda > /dev/null 2>&1; then + conda run -n base python3.9 -c 'import sys; import os; os.write(1, sys.executable.encode())' 2>/dev/null || echo -n "python3" + else + echo -n "python3" + fi + ''' + )}""" } // 3. 构建生命周期 @@ -25,7 +42,9 @@ pipeline { // Step 1: 用 Python 3.9 检查 tilelang 包的 AST 语法兼容性(对应 CI 中 "Check AST with Python 3.9") sh ''' - python3.9 -m compileall -q -f tilelang + echo "Using Python interpreter: ${PY39}" + "${PY39}" --version + "${PY39}" -m compileall -q -f tilelang ''' // Step 2: 运行 pre-commit 对全部文件执行 lint(对应 CI 中 "Pre-commit Lint") -- Gitee From 8d5bb182950295f5711a7e44be4b07192788b8eb Mon Sep 17 00:00:00 2001 From: artlesbol Date: Fri, 6 Mar 2026 15:49:34 +0800 Subject: [PATCH 09/94] =?UTF-8?q?lint=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 56 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 893c9daf..399e8c1d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,8 +5,11 @@ pipeline { // 2. 全局环境变量定义 environment { UV_CACHE_DIR = "${WORKSPACE}/.uv-cache" + // toolkit 格式: [Nightly-]CUDA- | [Nightly-]ROCm- | [Nightly-]MetaX- + // 与 ci.yml matrix.runner.toolkit 保持一致,按实际节点硬件填写 + TOOLKIT = "MetaX-1.0" TILELANG_TARGET = "metax" - LOG_LEVEL = "DEBUG" + LOG_LEVEL = "DEBUG" // 按优先级查找 Python 3.9:直接命令 → uv → pyenv → conda → 降级 python3 PY39 = """${sh( returnStdout: true, @@ -28,11 +31,47 @@ pipeline { // 3. 构建生命周期 stages { - stage('Environment Audit') { + stage('Setup Python & Dependencies') { steps { - echo "--- [PRE-CHECK] 检查硬件驱动与环境 ---" - echo "执行命令: custom-gpu-smi (检查驱动是否正常)" - echo "执行命令: python3 --version && uv --version" + echo "--- [SETUP] 安装 Python 依赖(对应 CI: Setup venv) ---" + sh ''' + set -euo pipefail + + # 升级基础工具(对应 CI: uv pip install --upgrade pip setuptools wheel) + uv pip install --upgrade pip setuptools wheel + + # 若为 Nightly toolkit,预先安装 torch nightly(对应 CI: prerelease torch) + if echo "${TOOLKIT}" | grep -q "^Nightly-"; then + uv pip install --prerelease=allow -v torch + fi + + # 安装通用测试依赖(对应 CI: uv pip install -r requirements-test.txt) + uv pip install -v -r requirements-test.txt + + echo "=== torch version ===" + python3 -c "import torch; print(f'torch: {torch.__version__}')" + + # 按 toolkit 类型安装额外依赖(对应 CI: toolkit-specific requirements) + if echo "${TOOLKIT}" | grep -qi "CUDA"; then + uv pip install --no-build-isolation-package=flash-attn -v -r requirements-test-cuda.txt + python3 -c "import flash_attn; print(f'flash_attn: {flash_attn.__version__}')" + elif echo "${TOOLKIT}" | grep -qi "ROCm"; then + uv pip install -v -r requirements-test-rocm.txt + elif echo "${TOOLKIT}" | grep -qi "Metal"; then + uv pip install -v -r requirements-test-metal.txt + else + echo "Unknown or custom toolkit: ${TOOLKIT}, skipping toolkit-specific deps." + fi + + echo "=== torch.utils.collect_env ===" + python3 -m torch.utils.collect_env || true + ''' + } + post { + failure { + // uv cache 损坏时清理,避免下次构建复用坏缓存(对应 CI: Clear uv cache if setup failed) + sh 'echo "Setup failed, clearing uv cache at ${UV_CACHE_DIR}"; uv cache clean || true' + } } } @@ -59,8 +98,11 @@ pipeline { stage('Build & Install') { steps { - echo "--- [BUILD] 正在编译 C++ 内核并安装 Python 接口 ---" - echo "执行命令: uv pip install -v ." + echo "--- [BUILD] 编译 C++ 内核并以 wheel 形式安装(对应 CI: Install project wheel form) ---" + sh ''' + set -euo pipefail + uv pip install -v . + ''' } } -- Gitee From c11772f3ae769839ba22819497a4ad61a21e5d2d Mon Sep 17 00:00:00 2001 From: artlesbol Date: Fri, 6 Mar 2026 15:52:16 +0800 Subject: [PATCH 10/94] 1 --- Jenkinsfile | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 399e8c1d..115a4324 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,11 +5,26 @@ pipeline { // 2. 全局环境变量定义 environment { UV_CACHE_DIR = "${WORKSPACE}/.uv-cache" - // toolkit 格式: [Nightly-]CUDA- | [Nightly-]ROCm- | [Nightly-]MetaX- - // 与 ci.yml matrix.runner.toolkit 保持一致,按实际节点硬件填写 TOOLKIT = "MetaX-1.0" TILELANG_TARGET = "metax" LOG_LEVEL = "DEBUG" + // 定位 uv:$PATH → ~/.local/bin/uv → ~/.cargo/bin/uv → 自动 pip 安装 + UV_BIN = """${sh( + returnStdout: true, + script: ''' + if command -v uv > /dev/null 2>&1; then + command -v uv | tr -d '\\n' + elif [ -x "${HOME}/.local/bin/uv" ]; then + echo -n "${HOME}/.local/bin/uv" + elif [ -x "${HOME}/.cargo/bin/uv" ]; then + echo -n "${HOME}/.cargo/bin/uv" + else + echo "uv not found, installing via pip..." >&2 + python3 -m pip install --quiet uv + echo -n "python3 -m uv" + fi + ''' + )}""" // 按优先级查找 Python 3.9:直接命令 → uv → pyenv → conda → 降级 python3 PY39 = """${sh( returnStdout: true, @@ -18,6 +33,8 @@ pipeline { echo -n "python3.9" elif command -v uv > /dev/null 2>&1 && uv python find 3.9 > /dev/null 2>&1; then uv python find 3.9 | tr -d '\\n' + elif [ -x "${HOME}/.local/bin/uv" ] && "${HOME}/.local/bin/uv" python find 3.9 > /dev/null 2>&1; then + "${HOME}/.local/bin/uv" python find 3.9 | tr -d '\\n' elif ls ${HOME}/.pyenv/versions/3.9*/bin/python3.9 > /dev/null 2>&1; then ls ${HOME}/.pyenv/versions/3.9*/bin/python3.9 | head -1 | tr -d '\\n' elif command -v conda > /dev/null 2>&1; then @@ -37,28 +54,31 @@ pipeline { sh ''' set -euo pipefail + echo "=== uv location: ${UV_BIN} ===" + ${UV_BIN} --version + # 升级基础工具(对应 CI: uv pip install --upgrade pip setuptools wheel) - uv pip install --upgrade pip setuptools wheel + ${UV_BIN} pip install --upgrade pip setuptools wheel # 若为 Nightly toolkit,预先安装 torch nightly(对应 CI: prerelease torch) if echo "${TOOLKIT}" | grep -q "^Nightly-"; then - uv pip install --prerelease=allow -v torch + ${UV_BIN} pip install --prerelease=allow -v torch fi # 安装通用测试依赖(对应 CI: uv pip install -r requirements-test.txt) - uv pip install -v -r requirements-test.txt + ${UV_BIN} pip install -v -r requirements-test.txt echo "=== torch version ===" python3 -c "import torch; print(f'torch: {torch.__version__}')" # 按 toolkit 类型安装额外依赖(对应 CI: toolkit-specific requirements) if echo "${TOOLKIT}" | grep -qi "CUDA"; then - uv pip install --no-build-isolation-package=flash-attn -v -r requirements-test-cuda.txt + ${UV_BIN} pip install --no-build-isolation-package=flash-attn -v -r requirements-test-cuda.txt python3 -c "import flash_attn; print(f'flash_attn: {flash_attn.__version__}')" elif echo "${TOOLKIT}" | grep -qi "ROCm"; then - uv pip install -v -r requirements-test-rocm.txt + ${UV_BIN} pip install -v -r requirements-test-rocm.txt elif echo "${TOOLKIT}" | grep -qi "Metal"; then - uv pip install -v -r requirements-test-metal.txt + ${UV_BIN} pip install -v -r requirements-test-metal.txt else echo "Unknown or custom toolkit: ${TOOLKIT}, skipping toolkit-specific deps." fi @@ -70,7 +90,7 @@ pipeline { post { failure { // uv cache 损坏时清理,避免下次构建复用坏缓存(对应 CI: Clear uv cache if setup failed) - sh 'echo "Setup failed, clearing uv cache at ${UV_CACHE_DIR}"; uv cache clean || true' + sh 'echo "Setup failed, clearing uv cache at ${UV_CACHE_DIR}"; ${UV_BIN} cache clean || true' } } } @@ -101,7 +121,7 @@ pipeline { echo "--- [BUILD] 编译 C++ 内核并以 wheel 形式安装(对应 CI: Install project wheel form) ---" sh ''' set -euo pipefail - uv pip install -v . + ${UV_BIN} pip install -v . ''' } } -- Gitee From 032ad9cd4e436c05bad9ae750f73e91b6fa86649 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Fri, 6 Mar 2026 15:57:22 +0800 Subject: [PATCH 11/94] 1 --- Jenkinsfile | 226 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 155 insertions(+), 71 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 115a4324..e58658b6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,46 +4,37 @@ pipeline { // 2. 全局环境变量定义 environment { - UV_CACHE_DIR = "${WORKSPACE}/.uv-cache" - TOOLKIT = "MetaX-1.0" - TILELANG_TARGET = "metax" - LOG_LEVEL = "DEBUG" - // 定位 uv:$PATH → ~/.local/bin/uv → ~/.cargo/bin/uv → 自动 pip 安装 - UV_BIN = """${sh( - returnStdout: true, - script: ''' - if command -v uv > /dev/null 2>&1; then - command -v uv | tr -d '\\n' - elif [ -x "${HOME}/.local/bin/uv" ]; then - echo -n "${HOME}/.local/bin/uv" - elif [ -x "${HOME}/.cargo/bin/uv" ]; then - echo -n "${HOME}/.cargo/bin/uv" - else - echo "uv not found, installing via pip..." >&2 - python3 -m pip install --quiet uv - echo -n "python3 -m uv" - fi - ''' - )}""" - // 按优先级查找 Python 3.9:直接命令 → uv → pyenv → conda → 降级 python3 - PY39 = """${sh( - returnStdout: true, - script: ''' - if command -v python3.9 > /dev/null 2>&1; then - echo -n "python3.9" - elif command -v uv > /dev/null 2>&1 && uv python find 3.9 > /dev/null 2>&1; then - uv python find 3.9 | tr -d '\\n' - elif [ -x "${HOME}/.local/bin/uv" ] && "${HOME}/.local/bin/uv" python find 3.9 > /dev/null 2>&1; then - "${HOME}/.local/bin/uv" python find 3.9 | tr -d '\\n' - elif ls ${HOME}/.pyenv/versions/3.9*/bin/python3.9 > /dev/null 2>&1; then - ls ${HOME}/.pyenv/versions/3.9*/bin/python3.9 | head -1 | tr -d '\\n' - elif command -v conda > /dev/null 2>&1; then - conda run -n base python3.9 -c 'import sys; import os; os.write(1, sys.executable.encode())' 2>/dev/null || echo -n "python3" - else - echo -n "python3" - fi - ''' - )}""" + // Python 环境变量(对应 CI 全局 env) + PYTHONDEVMODE = "1" + PYTHONUNBUFFERED = "1" + PYTHONPATH = "" // 显式清空,避免污染 + PIP_USER = "" // 显式清空 + COLUMNS = "100" + FORCE_COLOR = "1" + CLICOLOR_FORCE = "1" + + // uv 配置 + UV_INDEX_STRATEGY = "unsafe-best-match" + UV_HTTP_TIMEOUT = "600" + + // 缓存目录(对应 CI 中 self-hosted runner 使用 tool_cache) + XDG_CACHE_HOME = "${WORKSPACE}/.cache" + PIP_CACHE_DIR = "${WORKSPACE}/.cache/pip" + UV_CACHE_DIR = "${WORKSPACE}/.cache/uv" + PRE_COMMIT_HOME = "${WORKSPACE}/.cache/pip/.pre-commit" + + // uv 可执行路径(安装后由 Setup 阶段写入) + UV_BIN = "${HOME}/.local/bin/uv" + + // Python 3.9 解释器路径(由 Setup 阶段写入,Lint 阶段使用) + PY39 = "" + + // clang-tidy cmake 选项 + CLANG_TIDY_CMAKE_OPTIONS = "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" + + // GPU Toolkit 标识:可选值 CUDA-12.8 / Nightly-ROCm-7.1 / Metal + // 由 gpu_node1 节点实际配置决定,此处以 CUDA 为默认示例 + TILELANG_TARGET = "cuda" } // 3. 构建生命周期 @@ -51,46 +42,138 @@ pipeline { stage('Setup Python & Dependencies') { steps { echo "--- [SETUP] 安装 Python 依赖(对应 CI: Setup venv) ---" + + // ── Step 1: 安装 / 升级 uv(对应 CI: astral-sh/setup-uv) ────────────── sh ''' set -euo pipefail - - echo "=== uv location: ${UV_BIN} ===" - ${UV_BIN} --version - - # 升级基础工具(对应 CI: uv pip install --upgrade pip setuptools wheel) - ${UV_BIN} pip install --upgrade pip setuptools wheel - - # 若为 Nightly toolkit,预先安装 torch nightly(对应 CI: prerelease torch) - if echo "${TOOLKIT}" | grep -q "^Nightly-"; then - ${UV_BIN} pip install --prerelease=allow -v torch + echo "==> [1/6] 安装 uv" + if ! command -v uv &>/dev/null; then + curl -LsSf https://astral.sh/uv/install.sh | sh fi + export PATH="${HOME}/.local/bin:${PATH}" + uv --version + ''' - # 安装通用测试依赖(对应 CI: uv pip install -r requirements-test.txt) - ${UV_BIN} pip install -v -r requirements-test.txt - - echo "=== torch version ===" - python3 -c "import torch; print(f'torch: {torch.__version__}')" - - # 按 toolkit 类型安装额外依赖(对应 CI: toolkit-specific requirements) - if echo "${TOOLKIT}" | grep -qi "CUDA"; then - ${UV_BIN} pip install --no-build-isolation-package=flash-attn -v -r requirements-test-cuda.txt - python3 -c "import flash_attn; print(f'flash_attn: {flash_attn.__version__}')" - elif echo "${TOOLKIT}" | grep -qi "ROCm"; then - ${UV_BIN} pip install -v -r requirements-test-rocm.txt - elif echo "${TOOLKIT}" | grep -qi "Metal"; then - ${UV_BIN} pip install -v -r requirements-test-metal.txt - else - echo "Unknown or custom toolkit: ${TOOLKIT}, skipping toolkit-specific deps." - fi + // ── Step 2: 安装 Python 3.9(用于 Lint 阶段 AST 兼容性检查) ─────────── + sh ''' + set -euo pipefail + export PATH="${HOME}/.local/bin:${PATH}" + echo "==> [2/6] 安装 Python 3.9(AST 兼容性检查用)" + uv python install 3.9 + PY39_PATH="$(uv python find 3.9)" + echo "Python 3.9 路径: ${PY39_PATH}" + "${PY39_PATH}" --version + # 将路径写入 Jenkins 环境,供后续 stage 使用 + echo "PY39=${PY39_PATH}" >> "${WORKSPACE}/.env_vars" + ''' - echo "=== torch.utils.collect_env ===" - python3 -m torch.utils.collect_env || true + // ── Step 3: 安装主工作 Python 3.12 并创建虚拟环境 ───────────────────── + sh ''' + set -euo pipefail + export PATH="${HOME}/.local/bin:${PATH}" + echo "==> [3/6] 安装 Python 3.12 并创建 venv" + uv python install 3.12 + uv venv --python 3.12 .venv + .venv/bin/python --version ''' + + // ── Step 4: 检测 GPU toolkit 并设置 PyTorch 索引 URL ───────────────── + // sh ''' + // set -euo pipefail + // export PATH="${HOME}/.local/bin:${PATH}" + // echo "==> [4/6] 检测 GPU toolkit 并配置 PIP_EXTRA_INDEX_URL" + + // # 通过检测工具链自动判断 CUDA / ROCm / Metal + // if command -v nvcc &>/dev/null || [ -x /usr/local/cuda/bin/nvcc ]; then + // export PATH="/usr/local/cuda/bin:${PATH}" + // export LD_LIBRARY_PATH="/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" + // CUDA_VERSION="$(nvcc --version | grep -oP 'release \\K[0-9]+\\.[0-9]+')" + // CUDA_NODOT="${CUDA_VERSION//./}" + // PIP_EXTRA_INDEX_URL="https://download.pytorch.org/whl/cu${CUDA_NODOT}" + // TOOLKIT="CUDA-${CUDA_VERSION}" + // echo "检测到 CUDA ${CUDA_VERSION}" + // echo "CUDA_VERSION=${CUDA_VERSION}" >> "${WORKSPACE}/.env_vars" + // echo "USE_CUDA=ON" >> "${WORKSPACE}/.env_vars" + // echo "CLANG_TIDY_CMAKE_OPTIONS=${CLANG_TIDY_CMAKE_OPTIONS} -DUSE_CUDA=ON" >> "${WORKSPACE}/.env_vars" + // echo "PATH=${PATH}" >> "${WORKSPACE}/.env_vars" + // echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> "${WORKSPACE}/.env_vars" + // elif command -v hipcc &>/dev/null || [ -x /opt/rocm/bin/hipcc ]; then + // export PATH="/opt/rocm/bin:${PATH}" + // export LD_LIBRARY_PATH="/opt/rocm/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" + // ROCM_VERSION="$(hipcc --version | grep -oP 'HIP version: \\K[0-9]+\\.[0-9]+')" + // PIP_EXTRA_INDEX_URL="https://download.pytorch.org/whl/rocm${ROCM_VERSION}" + // TOOLKIT="ROCm-${ROCM_VERSION}" + // echo "检测到 ROCm ${ROCM_VERSION}" + // echo "ROCM_VERSION=${ROCM_VERSION}" >> "${WORKSPACE}/.env_vars" + // echo "USE_ROCM=ON" >> "${WORKSPACE}/.env_vars" + // echo "CLANG_TIDY_CMAKE_OPTIONS=${CLANG_TIDY_CMAKE_OPTIONS} -DUSE_ROCM=ON" >> "${WORKSPACE}/.env_vars" + // echo "PATH=${PATH}" >> "${WORKSPACE}/.env_vars" + // echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> "${WORKSPACE}/.env_vars" + // elif [[ "$(uname)" == "Darwin" ]]; then + // PIP_EXTRA_INDEX_URL="" + // TOOLKIT="Metal" + // echo "检测到 macOS Metal" + // echo "USE_METAL=ON" >> "${WORKSPACE}/.env_vars" + // echo "CLANG_TIDY_CMAKE_OPTIONS=${CLANG_TIDY_CMAKE_OPTIONS} -DUSE_METAL=ON" >> "${WORKSPACE}/.env_vars" + // else + // echo "ERROR: 未检测到支持的 GPU toolkit (CUDA / ROCm / Metal)" >&2 + // exit 1 + // fi + + // echo "TOOLKIT=${TOOLKIT}" >> "${WORKSPACE}/.env_vars" + // echo "PIP_EXTRA_INDEX_URL=${PIP_EXTRA_INDEX_URL}" >> "${WORKSPACE}/.env_vars" + // echo "UV_INDEX=${PIP_EXTRA_INDEX_URL}" >> "${WORKSPACE}/.env_vars" + // ''' + + // ── Step 5: 升级基础包 pip / setuptools / wheel ─────────────────────── + // sh ''' + // set -euo pipefail + // export PATH="${HOME}/.local/bin:${PATH}" + // # 载入上一步写入的环境变量 + // [ -f "${WORKSPACE}/.env_vars" ] && export $(grep -v '^#' "${WORKSPACE}/.env_vars" | xargs) + // echo "==> [5/6] 升级 pip / setuptools / wheel" + // uv pip install --python .venv/bin/python --upgrade pip setuptools wheel + // ''' + + // ── Step 6: 安装测试依赖(对应 CI: Setup venv)──────────────────────── + // sh ''' + // set -euo pipefail + // export PATH="${HOME}/.local/bin:${PATH}" + // [ -f "${WORKSPACE}/.env_vars" ] && export $(grep -v '^#' "${WORKSPACE}/.env_vars" | xargs) + // echo "==> [6/6] 安装测试依赖 requirements-test.txt" + + // # 如果是 nightly index,允许预发布版 torch + // if echo "${UV_INDEX:-}" | grep -q "/nightly/"; then + // uv pip install --python .venv/bin/python --prerelease=allow -v torch + // fi + + // uv pip install --python .venv/bin/python -v -r requirements-test.txt + + // # 按 toolkit 安装对应的额外依赖 + // if echo "${TOOLKIT:-}" | grep -q "CUDA"; then + // uv pip install --python .venv/bin/python \ + // --no-build-isolation-package=flash-attn \ + // -v -r requirements-test-cuda.txt + // .venv/bin/python -c "import flash_attn; print(f'flash_attn: {flash_attn.__version__}')" + // elif echo "${TOOLKIT:-}" | grep -q "ROCm"; then + // uv pip install --python .venv/bin/python -v -r requirements-test-rocm.txt + // elif echo "${TOOLKIT:-}" | grep -q "Metal"; then + // uv pip install --python .venv/bin/python -v -r requirements-test-metal.txt + // fi + + // # 打印 torch 环境信息 + // .venv/bin/python -c "import torch; print(f'torch: {torch.__version__}')" + // .venv/bin/python -m torch.utils.collect_env || true + // ''' } post { failure { - // uv cache 损坏时清理,避免下次构建复用坏缓存(对应 CI: Clear uv cache if setup failed) - sh 'echo "Setup failed, clearing uv cache at ${UV_CACHE_DIR}"; ${UV_BIN} cache clean || true' + // 失败时清理 uv 缓存,避免脏缓存影响下次构建(对应 CI: Clear uv cache if setup failed) + sh ''' + export PATH="${HOME}/.local/bin:${PATH}" + echo "==> [CLEANUP] Setup 失败,清理 uv 缓存: ${UV_CACHE_DIR}" + uv cache clean || true + ''' } } } @@ -101,6 +184,7 @@ pipeline { // Step 1: 用 Python 3.9 检查 tilelang 包的 AST 语法兼容性(对应 CI 中 "Check AST with Python 3.9") sh ''' + [ -f "${WORKSPACE}/.env_vars" ] && export $(grep -v '^#' "${WORKSPACE}/.env_vars" | xargs) echo "Using Python interpreter: ${PY39}" "${PY39}" --version "${PY39}" -m compileall -q -f tilelang -- Gitee From e49859f5100b4378c85f101556a6873a031945ba Mon Sep 17 00:00:00 2001 From: artlesbol Date: Fri, 6 Mar 2026 16:00:25 +0800 Subject: [PATCH 12/94] 1 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e58658b6..83f9b7bf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -48,7 +48,7 @@ pipeline { set -euo pipefail echo "==> [1/6] 安装 uv" if ! command -v uv &>/dev/null; then - curl -LsSf https://astral.sh/uv/install.sh | sh + pip install --user -U uv -i https://pypi.tuna.tsinghua.edu.cn/simple fi export PATH="${HOME}/.local/bin:${PATH}" uv --version -- Gitee From a3826a77f4c2631a195b64816dd3976fae40f06f Mon Sep 17 00:00:00 2001 From: artlesbol Date: Fri, 6 Mar 2026 16:06:56 +0800 Subject: [PATCH 13/94] 1 --- Jenkinsfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 83f9b7bf..7610f045 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -192,8 +192,8 @@ pipeline { // Step 2: 运行 pre-commit 对全部文件执行 lint(对应 CI 中 "Pre-commit Lint") sh ''' - if ! pipx run pre-commit run --all-files --color=always --show-diff-on-failure; then - echo "Pre-commit checks failed. Please run 'pre-commit install' and 'pre-commit run --all-files' locally to see the issues." + if ! uvx pre-commit run --all-files --color=always --show-diff-on-failure; then + echo "Pre-commit checks failed. Please run 'pre-commit run --all-files' locally to see the issues." exit 1 fi ''' @@ -235,7 +235,7 @@ pipeline { echo "操作: 检查是否存在 core.* 文件并归档" echo "操作: 执行 cleanWs() 清理磁盘" } - + success { echo "--- [NOTIFY] 流程成功:通知 Gitee 并标记 PR 为可合并 ---" } @@ -244,4 +244,4 @@ pipeline { echo "--- [NOTIFY] 流程失败:正在回传报错日志至 Gitee 评论区 ---" } } -} \ No newline at end of file +} -- Gitee From bfd3be1c98c0785044aafa7752df18120fa87946 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Fri, 6 Mar 2026 16:09:43 +0800 Subject: [PATCH 14/94] 1 --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 7610f045..0d120b21 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -73,6 +73,7 @@ pipeline { export PATH="${HOME}/.local/bin:${PATH}" echo "==> [3/6] 安装 Python 3.12 并创建 venv" uv python install 3.12 + rm -rf .venv uv venv --python 3.12 .venv .venv/bin/python --version ''' -- Gitee From 77d152125cbc3039b546fb1062f17d34a9b9af63 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Fri, 6 Mar 2026 16:15:36 +0800 Subject: [PATCH 15/94] 1 --- Jenkinsfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 0d120b21..80ff23ec 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -75,6 +75,8 @@ pipeline { uv python install 3.12 rm -rf .venv uv venv --python 3.12 .venv + uv pip install --python .venv/bin/python -r requirements-lint.txt + uv pip install --python .venv/bin/python --user pipx .venv/bin/python --version ''' -- Gitee From 9c9e9cb4a3d751841e46b50bbb1366ea0cee9175 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Fri, 6 Mar 2026 16:18:13 +0800 Subject: [PATCH 16/94] 1 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 80ff23ec..1308da9a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -76,7 +76,7 @@ pipeline { rm -rf .venv uv venv --python 3.12 .venv uv pip install --python .venv/bin/python -r requirements-lint.txt - uv pip install --python .venv/bin/python --user pipx + uv pip install --python .venv/bin/python pipx .venv/bin/python --version ''' -- Gitee From c4daecadfe1b74d0ab66306c05dbdf75fb69bb82 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Fri, 6 Mar 2026 16:19:30 +0800 Subject: [PATCH 17/94] 2 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1308da9a..12fdb17c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -195,7 +195,7 @@ pipeline { // Step 2: 运行 pre-commit 对全部文件执行 lint(对应 CI 中 "Pre-commit Lint") sh ''' - if ! uvx pre-commit run --all-files --color=always --show-diff-on-failure; then + if ! pipx pre-commit run --all-files --color=always --show-diff-on-failure; then echo "Pre-commit checks failed. Please run 'pre-commit run --all-files' locally to see the issues." exit 1 fi -- Gitee From 2e101fe2f619305c6d9fb853918dae22e8be332d Mon Sep 17 00:00:00 2001 From: artlesbol Date: Fri, 6 Mar 2026 16:25:01 +0800 Subject: [PATCH 18/94] 3 --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 12fdb17c..7dedf747 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -195,6 +195,7 @@ pipeline { // Step 2: 运行 pre-commit 对全部文件执行 lint(对应 CI 中 "Pre-commit Lint") sh ''' + export PATH="${WORKSPACE}/.venv/bin:${HOME}/.local/bin:${PATH}" if ! pipx pre-commit run --all-files --color=always --show-diff-on-failure; then echo "Pre-commit checks failed. Please run 'pre-commit run --all-files' locally to see the issues." exit 1 -- Gitee From 16a09272edb1179d44ea135b0cc01c4b32b27895 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Fri, 6 Mar 2026 16:26:09 +0800 Subject: [PATCH 19/94] 4 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7dedf747..4c20ed32 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -196,7 +196,7 @@ pipeline { // Step 2: 运行 pre-commit 对全部文件执行 lint(对应 CI 中 "Pre-commit Lint") sh ''' export PATH="${WORKSPACE}/.venv/bin:${HOME}/.local/bin:${PATH}" - if ! pipx pre-commit run --all-files --color=always --show-diff-on-failure; then + if ! pipx run pre-commit run --all-files --color=always --show-diff-on-failure; then echo "Pre-commit checks failed. Please run 'pre-commit run --all-files' locally to see the issues." exit 1 fi -- Gitee From 57cc62fe592955e179509c7fd2482ec5c9cc3ace Mon Sep 17 00:00:00 2001 From: artlesbol Date: Fri, 6 Mar 2026 16:28:22 +0800 Subject: [PATCH 20/94] pre-commit --- THIRDPARTYNOTICES.txt | 4 +- docs/get_started/Installation_maca.md | 4 +- .../deepseek_mla/test_example_mla_decode.py | 1 + src/layout/gemm_layouts.cc | 15 +- src/layout/layout.h | 3 +- src/op/gemm.cc | 3 +- src/op/logical.cc | 3 +- src/target/codegen_maca.cc | 21 +- src/target/codegen_maca.h | 3 +- src/target/intrin_rule_maca.cc | 215 ++++++++------ src/target/maca_common.h | 31 +- src/target/maca_device_api.cc | 274 +++++++++--------- src/target/maca_module.cc | 96 +++--- src/target/maca_module.h | 10 +- src/target/maca_target_kind.cc | 26 +- src/target/rt_mod_maca.cc | 9 +- src/target/utils.cc | 3 +- src/target/utils.h | 3 +- src/tl_templates/maca/common.h | 34 ++- src/tl_templates/maca/debug.h | 14 +- src/tl_templates/maca/gemm.h | 24 +- src/tl_templates/maca/reduce.h | 3 +- src/tl_templates/maca/threadblock_swizzle.h | 3 +- src/transform/arg_binder.cc | 4 +- test/test.commit | 2 +- testing/python/conftest.py | 10 +- tilelang/carver/arch/maca.py | 5 +- tilelang/carver/roller/hint.py | 1 + tilelang/contrib/mxcc.py | 3 +- .../intrinsics/maca_mma_macro_generator.py | 4 - tilelang/intrinsics/mfma_macro_generator.py | 1 + tilelang/quantize/lop3_maca.py | 5 +- tilelang/tileop/gemm_sp/__init__.py | 4 +- 33 files changed, 461 insertions(+), 380 deletions(-) diff --git a/THIRDPARTYNOTICES.txt b/THIRDPARTYNOTICES.txt index 4b352b49..6b1b6ef4 100644 --- a/THIRDPARTYNOTICES.txt +++ b/THIRDPARTYNOTICES.txt @@ -58,8 +58,8 @@ The following files are newly added by MetaX Integrated Circuits (Shanghai) Co., added: tilelang/carver/arch/maca.py added: tilelang/quantize/lop3_maca.py -BitBLAS uses third-party material as listed below. The attached notices are -provided for informational purposes only. +BitBLAS uses third-party material as listed below. The attached notices are +provided for informational purposes only. ======= BitBLAS uses third-party material as listed below. The attached notices are provided for informational purposes only. diff --git a/docs/get_started/Installation_maca.md b/docs/get_started/Installation_maca.md index ce742b17..3818c722 100644 --- a/docs/get_started/Installation_maca.md +++ b/docs/get_started/Installation_maca.md @@ -70,7 +70,7 @@ Check out [Installing Docker Engine](https://docs.docker.com/engine/install/ubun Check out [Metax docker](https://sw-download.metax-tech.com/docker) and download pytorch image. ``` bash -docker login --username=cr_temp_user --password=eyJpbnN0YW5jZUlkIjoiY3JpLXpxYTIzejI2YTU5M3R3M2QiLCJ0aW1lIjoiMTc3MDg5NTI0MzAwMCIsInR5cGUiOiJzdWIiLCJ1c2VySWQiOiIyMDcwOTQwMTA1NjYzNDE3OTIifQ:91ecedb8bd5c4af6858745f0329d069263e1bf82 cr.metax-tech.com && docker pull cr.metax-tech.com/public-library/maca-pytorch:3.3.0.4-torch2.6-py310-ubuntu24.04-amd64 +docker login --username=cr_temp_user --password=eyJpbnN0YW5jZUlkIjoiY3JpLXpxYTIzejI2YTU5M3R3M2QiLCJ0aW1lIjoiMTc3MDg5NTI0MzAwMCIsInR5cGUiOiJzdWIiLCJ1c2VySWQiOiIyMDcwOTQwMTA1NjYzNDE3OTIifQ:91ecedb8bd5c4af6858745f0329d069263e1bf82 cr.metax-tech.com && docker pull cr.metax-tech.com/public-library/maca-pytorch:3.3.0.4-torch2.6-py310-ubuntu24.04-amd64 docker run -it --net=host --device=/dev/dri --device=/dev/mxcd --group-add video --name mctilelang cr.metax-tech.com/public-library/maca-pytorch:3.3.0.4-torch2.6-py310-ubuntu24.04-amd64 /bin/bash @@ -124,4 +124,4 @@ export PYTHONPATH=/path/to/mcTileLang:$PYTHONPATH python -c "import tilelang; print(tilelang.__version__)" python path/to/mcTileLang/examples/quickstart.py -``` \ No newline at end of file +``` diff --git a/examples/deepseek_mla/test_example_mla_decode.py b/examples/deepseek_mla/test_example_mla_decode.py index 887f142c..c9b7cb7f 100644 --- a/examples/deepseek_mla/test_example_mla_decode.py +++ b/examples/deepseek_mla/test_example_mla_decode.py @@ -3,6 +3,7 @@ import tilelang.testing import example_mla_decode + def test_example_mla_decode(): example_mla_decode.main() diff --git a/src/layout/gemm_layouts.cc b/src/layout/gemm_layouts.cc index 0193479c..4164b638 100644 --- a/src/layout/gemm_layouts.cc +++ b/src/layout/gemm_layouts.cc @@ -1,4 +1,5 @@ -// 2025 - Modified by MetaX Integrated Circuits (Shanghai) Co., Ltd. All Rights Reserved. +// 2025 - Modified by MetaX Integrated Circuits (Shanghai) Co., Ltd. All Rights +// Reserved. /*! * \file layout/gemm_layouts.cc * \brief Define Layout used in MMA and other operations. @@ -349,7 +350,8 @@ Fragment makeGemmFragmentAMACA(const int block_m, const int block_n, if (transposed) { PrimExpr forward_thread = 16 * FloorDiv(i->var, 4) + j; PrimExpr index = FloorMod(i->var, 4); - auto base_layout = Fragment({i, j}, {index}, forward_thread, rep)->Repeat({1, 1}, false, false); + auto base_layout = Fragment({i, j}, {index}, forward_thread, rep) + ->Repeat({1, 1}, false, false); auto warp_layout = base_layout->Repeat({1, block_m / warp_m}, true, false) ->Replicate(block_n / warp_n); auto block_layout = @@ -358,7 +360,8 @@ Fragment makeGemmFragmentAMACA(const int block_m, const int block_n, } else { PrimExpr forward_thread = 16 * FloorDiv(j->var, 4) + i; PrimExpr index = FloorMod(j->var, 4); - auto base_layout = Fragment({i, j}, {index}, forward_thread, rep)->Repeat({1, 1}, false, false); + auto base_layout = Fragment({i, j}, {index}, forward_thread, rep) + ->Repeat({1, 1}, false, false); auto warp_layout = base_layout->Repeat({block_m / warp_m, 1}, true) ->Replicate(block_n / warp_n); auto block_layout = @@ -993,7 +996,8 @@ Layout makeGemmABLayoutMACA(int mat_stride, int mat_continuous, int continuity, return makeGemmABLayoutPadded(mat_stride, mat_continuous, element_size); } else if (mat_continuous % (vector_size * 8) == 0) { if (mat_stride % 64 == 32) { - return MakeFullBankSwizzleLayout2D(mat_stride, mat_continuous, element_size); + return MakeFullBankSwizzleLayout2D(mat_stride, mat_continuous, + element_size); } Var i = InputPlaceholder(0); Var j = InputPlaceholder(1); @@ -1007,7 +1011,8 @@ Layout makeGemmABLayoutMACA(int mat_stride, int mat_continuous, int continuity, PrimExpr index = vec + (c_swizzle + s * 16) * vector_size; return Layout(Array{mat_stride, mat_continuous}, {tc, ts, index}); } else if (mat_continuous % (vector_size * 4) == 0) { - return MakeHalfBankSwizzleLayout2D(mat_stride, mat_continuous, element_size); + return MakeHalfBankSwizzleLayout2D(mat_stride, mat_continuous, + element_size); } else { ICHECK(0); return makeGemmABLayoutPadded(mat_stride, mat_continuous, element_size); diff --git a/src/layout/layout.h b/src/layout/layout.h index 99b5edee..fa0a9af1 100644 --- a/src/layout/layout.h +++ b/src/layout/layout.h @@ -1,4 +1,5 @@ -// 2025 - Modified by MetaX Integrated Circuits (Shanghai) Co., Ltd. All Rights Reserved. +// 2025 - Modified by MetaX Integrated Circuits (Shanghai) Co., Ltd. All Rights +// Reserved. /*! * \file Layout.h * diff --git a/src/op/gemm.cc b/src/op/gemm.cc index a4887421..71421380 100644 --- a/src/op/gemm.cc +++ b/src/op/gemm.cc @@ -1,4 +1,5 @@ -// 2025 - Modified by MetaX Integrated Circuits (Shanghai) Co., Ltd. All Rights Reserved. +// 2025 - Modified by MetaX Integrated Circuits (Shanghai) Co., Ltd. All Rights +// Reserved. /*! * \file tl/op/gemm.cc * \brief Implementation of General Matrix Multiplication (GEMM) operators diff --git a/src/op/logical.cc b/src/op/logical.cc index e8ac2304..09906d22 100644 --- a/src/op/logical.cc +++ b/src/op/logical.cc @@ -1,4 +1,5 @@ -// 2025 - Modified by MetaX Integrated Circuits (Shanghai) Co., Ltd. All Rights Reserved. +// 2025 - Modified by MetaX Integrated Circuits (Shanghai) Co., Ltd. All Rights +// Reserved. /*! * \file tl/op/logical.cc * \brief Logical operations. diff --git a/src/target/codegen_maca.cc b/src/target/codegen_maca.cc index 6e8ae676..e3b00a00 100644 --- a/src/target/codegen_maca.cc +++ b/src/target/codegen_maca.cc @@ -1,4 +1,5 @@ -// Copyright (c) 2025 MetaX Integrated Circuits (Shanghai) Co., Ltd. All rights reserved. +// Copyright (c) 2025 MetaX Integrated Circuits (Shanghai) Co., Ltd. All rights +// reserved. /*! * \file target/codegen.cc @@ -715,8 +716,8 @@ void CodeGenTileLangMACA::PrintVecElemStore(const std::string &vec, DataType t, } } else if (t.is_bfloat16()) { if (t.lanes() <= 8) { - stream << "((maca_bfloat162*)(&(" << vec << "." << access[i / 2] << ")))->" - << access[i % 2] << " = " << value << ";\n"; + stream << "((maca_bfloat162*)(&(" << vec << "." << access[i / 2] + << ")))->" << access[i % 2] << " = " << value << ";\n"; } else { stream << "(((maca_bfloat162*)(&(" << vec << "." << access[i / 4] << "))) + " << (i / 2 % 2) << ")->" << access[i % 2] << " = " @@ -937,8 +938,8 @@ void CodeGenTileLangMACA::VisitExpr_(const CastNode *op, std::ostream &os) { if (from_ty.is_bfloat16() && target_ty.is_float() && target_ty.bits() == 32) { // Use __bfloat1622float2 for vectorized conversion (bfloat162 -> float2) if (lanes == 2 || lanes == 4 || lanes == 8) { - PrintVectorizedCast("__bfloat1622float2", "__maca_bfloat162", "float2", "", - true, false); + PrintVectorizedCast("__bfloat1622float2", "__maca_bfloat162", "float2", + "", true, false); return; } } @@ -958,9 +959,11 @@ void CodeGenTileLangMACA::VisitExpr_(const CastNode *op, std::ostream &os) { tl::IsCudaVectorizableFP8(target_ty)) { bool target_type_is_e4m3 = target_ty.is_float8_e4m3() || target_ty.is_float8_e4m3fn(); - std::string type_suffix = target_type_is_e4m3 ? "__MACA_E4M3" : "__MACA_E5M2"; + std::string type_suffix = + target_type_is_e4m3 ? "__MACA_E4M3" : "__MACA_E5M2"; - // Use __maca_cvt_float2_to_fp8x2 for vectorized conversion (float2 -> fp8x2) + // Use __maca_cvt_float2_to_fp8x2 for vectorized conversion (float2 -> + // fp8x2) if (lanes == 2 || lanes == 4 || lanes == 8) { std::string extra_args = ", __MACA_SATFINITE, " + type_suffix; PrintVectorizedCast("__maca_cvt_float2_to_fp8x2", "float2", @@ -990,8 +993,8 @@ void CodeGenTileLangMACA::VisitExpr_(const CastNode *op, std::ostream &os) { // bfloat162) if (lanes == 2 || lanes == 4 || lanes == 8) { PrintVectorizedCast("__tl_cvt_e8m0x2_to_bfloat162", - "__maca_fp8x2_storage_t", "__maca_bfloat162", "", true, - false); + "__maca_fp8x2_storage_t", "__maca_bfloat162", "", + true, false); return; } } diff --git a/src/target/codegen_maca.h b/src/target/codegen_maca.h index 7a88a374..72ffeae4 100644 --- a/src/target/codegen_maca.h +++ b/src/target/codegen_maca.h @@ -1,4 +1,5 @@ -// Copyright (c) 2025 MetaX Integrated Circuits (Shanghai) Co., Ltd. All rights reserved. +// Copyright (c) 2025 MetaX Integrated Circuits (Shanghai) Co., Ltd. All rights +// reserved. /*! * \file target/codegen.h diff --git a/src/target/intrin_rule_maca.cc b/src/target/intrin_rule_maca.cc index 37d578a2..ca27d11a 100644 --- a/src/target/intrin_rule_maca.cc +++ b/src/target/intrin_rule_maca.cc @@ -36,32 +36,32 @@ struct MACAMath { std::string operator()(DataType t, std::string name) const { if (t.is_float()) { switch (t.bits()) { - case 64: - return name; - case 32: - return name + 'f'; - case 16: { - if (name == "fabs") { - return "__habs"; - } else if (name == "round") { - return "hrint"; - } else { - return "h" + name; - } + case 64: + return name; + case 32: + return name + 'f'; + case 16: { + if (name == "fabs") { + return "__habs"; + } else if (name == "round") { + return "hrint"; + } else { + return "h" + name; } - default: - return ""; + } + default: + return ""; } } else if (t.is_bfloat16()) { return 'h' + name; } else if (t.is_int() || t.is_uint()) { switch (t.bits()) { - case 32: - return "__" + name; - case 64: - return "__" + name + "ll"; - default: - return ""; + case 32: + return "__" + name; + case 64: + return "__" + name + "ll"; + default: + return ""; } } return ""; @@ -83,16 +83,16 @@ struct MACAFastMathTan : public MACAMath { std::string operator()(DataType t, std::string name) const { if (t.is_float()) { switch (t.bits()) { - case 64: - return name; - // `__tanf` seems to produce some values too deviant from numpy tan version. - // So, let's use just `tanf` instead. - case 32: - return name + 'f'; - case 16: - return 'h' + name; - default: - return ""; + case 64: + return name; + // `__tanf` seems to produce some values too deviant from numpy tan + // version. So, let's use just `tanf` instead. + case 32: + return name + 'f'; + case 16: + return 'h' + name; + default: + return ""; } } return ""; @@ -103,12 +103,12 @@ struct MACAPopcount { std::string operator()(DataType t, std::string name) const { if (t.is_uint()) { switch (t.bits()) { - case 32: - return "__popc"; - case 64: - return "__popcll"; - default: - return ""; + case 32: + return "__popc"; + case 64: + return "__popcll"; + default: + return ""; } } return ""; @@ -116,7 +116,7 @@ struct MACAPopcount { }; struct MACAWarpIntrinsic { - const Op operator()(DataType t, const Op& orig_op) const { + const Op operator()(DataType t, const Op &orig_op) const { if (orig_op.same_as(builtin::tvm_warp_shuffle())) { return Op::Get("tir.maca.__shfl_sync"); } else if (orig_op.same_as(builtin::tvm_warp_shuffle_up())) { @@ -128,117 +128,142 @@ struct MACAWarpIntrinsic { } }; -static PrimExpr DispatchMACAWarpActiveMask(const PrimExpr& e) { - const CallNode* call = e.as(); +static PrimExpr DispatchMACAWarpActiveMask(const PrimExpr &e) { + const CallNode *call = e.as(); return Call(call->dtype, Op::Get("tir.maca.__activemask"), call->args); } -template -static PrimExpr DispatchMACAShuffle(const PrimExpr& e) { - const CallNode* call = e.as(); +template static PrimExpr DispatchMACAShuffle(const PrimExpr &e) { + const CallNode *call = e.as(); ICHECK(call != nullptr); - ICHECK_EQ(call->args.size(), 5); // mask, value, warp_id, width, warp_size - ffi::Array maca_args{{call->args[0], call->args[1], call->args[2], call->args[3]}}; + ICHECK_EQ(call->args.size(), 5); // mask, value, warp_id, width, warp_size + ffi::Array maca_args{ + {call->args[0], call->args[1], call->args[2], call->args[3]}}; return Call(call->dtype, T()(call->dtype, Downcast(call->op)), maca_args); } TVM_REGISTER_OP("tir.clz").set_attr( - "maca.FLowerIntrinsic", DispatchPureExtern); + "maca.FLowerIntrinsic", + DispatchPureExtern); TVM_REGISTER_OP("tir.floor") - .set_attr("maca.FLowerIntrinsic", DispatchPureExtern); + .set_attr("maca.FLowerIntrinsic", + DispatchPureExtern); TVM_REGISTER_OP("tir.ceil") - .set_attr("maca.FLowerIntrinsic", DispatchPureExtern); + .set_attr("maca.FLowerIntrinsic", + DispatchPureExtern); TVM_REGISTER_OP("tir.trunc") - .set_attr("maca.FLowerIntrinsic", DispatchPureExtern); + .set_attr("maca.FLowerIntrinsic", + DispatchPureExtern); TVM_REGISTER_OP("tir.fabs") - .set_attr("maca.FLowerIntrinsic", DispatchPureExtern); + .set_attr("maca.FLowerIntrinsic", + DispatchPureExtern); TVM_REGISTER_OP("tir.round") - .set_attr("maca.FLowerIntrinsic", DispatchPureExtern); + .set_attr("maca.FLowerIntrinsic", + DispatchPureExtern); TVM_REGISTER_OP("tir.nearbyint") - .set_attr("maca.FLowerIntrinsic", DispatchPureExtern); + .set_attr("maca.FLowerIntrinsic", + DispatchPureExtern); -TVM_REGISTER_OP("tir.exp").set_attr("maca.FLowerIntrinsic", - DispatchPureExtern); +TVM_REGISTER_OP("tir.exp").set_attr( + "maca.FLowerIntrinsic", DispatchPureExtern); TVM_REGISTER_OP("tir.exp2") - .set_attr("maca.FLowerIntrinsic", DispatchPureExtern); + .set_attr("maca.FLowerIntrinsic", + DispatchPureExtern); TVM_REGISTER_OP("tir.exp10") - .set_attr("maca.FLowerIntrinsic", DispatchPureExtern); + .set_attr("maca.FLowerIntrinsic", + DispatchPureExtern); -TVM_REGISTER_OP("tir.erf").set_attr("maca.FLowerIntrinsic", - DispatchPureExtern); +TVM_REGISTER_OP("tir.erf").set_attr( + "maca.FLowerIntrinsic", DispatchPureExtern); -TVM_REGISTER_OP("tir.log").set_attr("maca.FLowerIntrinsic", - DispatchPureExtern); +TVM_REGISTER_OP("tir.log").set_attr( + "maca.FLowerIntrinsic", DispatchPureExtern); TVM_REGISTER_OP("tir.log2") - .set_attr("maca.FLowerIntrinsic", DispatchPureExtern); + .set_attr("maca.FLowerIntrinsic", + DispatchPureExtern); TVM_REGISTER_OP("tir.log10") - .set_attr("maca.FLowerIntrinsic", DispatchPureExtern); + .set_attr("maca.FLowerIntrinsic", + DispatchPureExtern); -TVM_REGISTER_OP("tir.tan").set_attr("maca.FLowerIntrinsic", - DispatchPureExtern); +TVM_REGISTER_OP("tir.tan").set_attr( + "maca.FLowerIntrinsic", DispatchPureExtern); -TVM_REGISTER_OP("tir.cos").set_attr("maca.FLowerIntrinsic", - DispatchPureExtern); +TVM_REGISTER_OP("tir.cos").set_attr( + "maca.FLowerIntrinsic", DispatchPureExtern); TVM_REGISTER_OP("tir.cosh") - .set_attr("maca.FLowerIntrinsic", DispatchPureExtern); + .set_attr("maca.FLowerIntrinsic", + DispatchPureExtern); -TVM_REGISTER_OP("tir.sin").set_attr("maca.FLowerIntrinsic", - DispatchPureExtern); +TVM_REGISTER_OP("tir.sin").set_attr( + "maca.FLowerIntrinsic", DispatchPureExtern); TVM_REGISTER_OP("tir.sinh") - .set_attr("maca.FLowerIntrinsic", DispatchPureExtern); + .set_attr("maca.FLowerIntrinsic", + DispatchPureExtern); TVM_REGISTER_OP("tir.atan") - .set_attr("maca.FLowerIntrinsic", DispatchPureExtern); + .set_attr("maca.FLowerIntrinsic", + DispatchPureExtern); TVM_REGISTER_OP("tir.tanh") - .set_attr("maca.FLowerIntrinsic", DispatchPureExtern); + .set_attr("maca.FLowerIntrinsic", + DispatchPureExtern); TVM_REGISTER_OP("tir.sqrt") - .set_attr("maca.FLowerIntrinsic", DispatchPureExtern); + .set_attr("maca.FLowerIntrinsic", + DispatchPureExtern); -TVM_REGISTER_OP("tir.pow").set_attr("maca.FLowerIntrinsic", - DispatchPureExtern); +TVM_REGISTER_OP("tir.pow").set_attr( + "maca.FLowerIntrinsic", DispatchPureExtern); TVM_REGISTER_OP("tir.popcount") - .set_attr("maca.FLowerIntrinsic", DispatchPureExtern); + .set_attr("maca.FLowerIntrinsic", + DispatchPureExtern); TVM_REGISTER_OP("tir.tvm_warp_shuffle") - .set_attr("maca.FLowerIntrinsic", DispatchMACAShuffle); + .set_attr("maca.FLowerIntrinsic", + DispatchMACAShuffle); TVM_REGISTER_OP("tir.tvm_warp_shuffle_up") - .set_attr("maca.FLowerIntrinsic", DispatchMACAShuffle); + .set_attr("maca.FLowerIntrinsic", + DispatchMACAShuffle); TVM_REGISTER_OP("tir.tvm_warp_shuffle_down") - .set_attr("maca.FLowerIntrinsic", DispatchMACAShuffle); + .set_attr("maca.FLowerIntrinsic", + DispatchMACAShuffle); TVM_REGISTER_OP("tir.tvm_warp_activemask") - .set_attr("maca.FLowerIntrinsic", DispatchMACAWarpActiveMask); + .set_attr("maca.FLowerIntrinsic", + DispatchMACAWarpActiveMask); TVM_REGISTER_OP("tir.fmod") - .set_attr("maca.FLowerIntrinsic", DispatchPureExtern); + .set_attr("maca.FLowerIntrinsic", + DispatchPureExtern); // Register low-level builtin ops. -// TODO(tvm-team): consider make MACA its own subfolder and create a file for low-level builtins. +// TODO(tvm-team): consider make MACA its own subfolder and create a file for +// low-level builtins. TVM_REGISTER_OP("tir.maca.__shfl_sync") .set_num_inputs(4) .add_argument("mask", "Expr", "The thread mask.") .add_argument("var", "Expr", "The variable to sync.") .add_argument("lane", "Expr", "The source thread id.") - .add_argument("width", "Expr", "The warp thread width, must be a power of 2.") + .add_argument("width", "Expr", + "The warp thread width, must be a power of 2.") .set_attr("TGlobalSymbol", "__shfl_sync") - .set_attr("TCallEffectKind", Integer(CallEffectKind::kOpaque)) + .set_attr("TCallEffectKind", + Integer(CallEffectKind::kOpaque)) .set_attr("maca.need_warp_shuffle", true); TVM_REGISTER_OP("tir.maca.__shfl_up_sync") @@ -246,27 +271,33 @@ TVM_REGISTER_OP("tir.maca.__shfl_up_sync") .add_argument("mask", "Expr", "The thread mask.") .add_argument("var", "Expr", "The variable to sync.") .add_argument("delta", "Expr", "The source lane id offset to be added.") - .add_argument("width", "Expr", "The warp thread width, must be a power of 2.") + .add_argument("width", "Expr", + "The warp thread width, must be a power of 2.") .set_attr("TGlobalSymbol", "__shfl_up_sync") - .set_attr("TCallEffectKind", Integer(CallEffectKind::kOpaque)) + .set_attr("TCallEffectKind", + Integer(CallEffectKind::kOpaque)) .set_attr("maca.need_warp_shuffle", true); TVM_REGISTER_OP("tir.maca.__shfl_down_sync") .set_num_inputs(4) .add_argument("mask", "Expr", "The thread mask.") .add_argument("var", "Expr", "The variable to sync.") - .add_argument("delta", "Expr", "The source lane id offset to be subtracted.") - .add_argument("width", "Expr", "The warp thread width, must be a power of 2.") + .add_argument("delta", "Expr", + "The source lane id offset to be subtracted.") + .add_argument("width", "Expr", + "The warp thread width, must be a power of 2.") .set_attr("TGlobalSymbol", "__shfl_down_sync") - .set_attr("TCallEffectKind", Integer(CallEffectKind::kOpaque)) + .set_attr("TCallEffectKind", + Integer(CallEffectKind::kOpaque)) .set_attr("maca.need_warp_shuffle", true); TVM_REGISTER_OP("tir.maca.__activemask") .set_num_inputs(0) .set_attr("TGlobalSymbol", "__activemask") - .set_attr("TCallEffectKind", Integer(CallEffectKind::kPure)) + .set_attr("TCallEffectKind", + Integer(CallEffectKind::kPure)) .set_attr("maca.need_warp_shuffle", true); -} // namespace intrin -} // namespace codegen -} // namespace tvm +} // namespace intrin +} // namespace codegen +} // namespace tvm diff --git a/src/target/maca_common.h b/src/target/maca_common.h index 0ac54353..3f5322b5 100644 --- a/src/target/maca_common.h +++ b/src/target/maca_common.h @@ -34,23 +34,24 @@ namespace tvm { namespace runtime { -#define MACA_DRIVER_CALL(x) \ - { \ - mcError_t result = x; \ - if (result != mcSuccess && result != mcErrorDeinitialized) { \ - LOG(FATAL) << "MACA MACA Error: " #x " failed with error: " << mcGetErrorString(result); \ - } \ +#define MACA_DRIVER_CALL(x) \ + { \ + mcError_t result = x; \ + if (result != mcSuccess && result != mcErrorDeinitialized) { \ + LOG(FATAL) << "MACA MACA Error: " #x " failed with error: " \ + << mcGetErrorString(result); \ + } \ } -#define MACA_CALL(func) \ - { \ - mcError_t e = (func); \ - ICHECK(e == mcSuccess) << "MACA MACA: " << mcGetErrorString(e); \ +#define MACA_CALL(func) \ + { \ + mcError_t e = (func); \ + ICHECK(e == mcSuccess) << "MACA MACA: " << mcGetErrorString(e); \ } /*! \brief Thread local workspace */ class MACAThreadEntry { - public: +public: /*! \brief The maca stream */ mcStream_t stream{nullptr}; /*! \brief thread local pool*/ @@ -58,8 +59,8 @@ class MACAThreadEntry { /*! \brief constructor */ MACAThreadEntry(); // get the threadlocal workspace - static MACAThreadEntry* ThreadLocal(); + static MACAThreadEntry *ThreadLocal(); }; -} // namespace runtime -} // namespace tvm -#endif // TVM_RUNTIME_MACA_MACA_COMMON_H_ +} // namespace runtime +} // namespace tvm +#endif // TVM_RUNTIME_MACA_MACA_COMMON_H_ diff --git a/src/target/maca_device_api.cc b/src/target/maca_device_api.cc index c9212acf..2bad3e9a 100644 --- a/src/target/maca_device_api.cc +++ b/src/target/maca_device_api.cc @@ -41,109 +41,116 @@ namespace tvm { namespace runtime { class MACADeviceAPI final : public DeviceAPI { - public: +public: void SetDevice(Device dev) final { MACA_CALL(mcSetDevice(dev.device_id)); } - void GetAttr(Device device, DeviceAttrKind kind, ffi::Any* rv) final { + void GetAttr(Device device, DeviceAttrKind kind, ffi::Any *rv) final { int value = 0; switch (kind) { - case kExist: { - int count; - auto err = mcGetDeviceCount(&count); - value = (err == mcSuccess && static_cast(count > device.device_id)); - break; - } - case kMaxThreadsPerBlock: { - MACA_CALL( - mcDeviceGetAttribute(&value, mcDeviceAttributeMaxThreadsPerBlock, device.device_id)); - break; - } - case kWarpSize: { - MACA_CALL(mcDeviceGetAttribute(&value, mcDeviceAttributeWarpSize, device.device_id)); - break; - } - case kMaxSharedMemoryPerBlock: { - MACA_CALL(mcDeviceGetAttribute(&value, mcDeviceAttributeMaxSharedMemoryPerBlock, - device.device_id)); - break; - } - case kComputeVersion: { - std::ostringstream os; - MACA_CALL(mcDeviceGetAttribute(&value, mcDeviceAttributeComputeCapabilityMajor, - device.device_id)); - os << value << "."; - MACA_CALL(mcDeviceGetAttribute(&value, mcDeviceAttributeComputeCapabilityMinor, - device.device_id)); - os << value; - *rv = os.str(); - return; - } - case kDeviceName: { - std::string name(256, 0); - MACA_CALL(mcDeviceGetName(&name[0], name.size(), device.device_id)); - name.resize(strlen(name.c_str())); - *rv = std::move(name); - return; - } - case kMaxClockRate: { - MACA_CALL(mcDeviceGetAttribute(&value, mcDeviceAttributeClockRate, device.device_id)); - break; - } - case kMultiProcessorCount: { - MACA_CALL( - mcDeviceGetAttribute(&value, mcDeviceAttributeMultiProcessorCount, device.device_id)); - break; - } - case kMaxThreadDimensions: { - int dims[3]; - MACA_CALL(mcDeviceGetAttribute(&dims[0], mcDeviceAttributeMaxBlockDimX, device.device_id)); - MACA_CALL(mcDeviceGetAttribute(&dims[1], mcDeviceAttributeMaxBlockDimY, device.device_id)); - MACA_CALL(mcDeviceGetAttribute(&dims[2], mcDeviceAttributeMaxBlockDimZ, device.device_id)); + case kExist: { + int count; + auto err = mcGetDeviceCount(&count); + value = (err == mcSuccess && static_cast(count > device.device_id)); + break; + } + case kMaxThreadsPerBlock: { + MACA_CALL(mcDeviceGetAttribute( + &value, mcDeviceAttributeMaxThreadsPerBlock, device.device_id)); + break; + } + case kWarpSize: { + MACA_CALL(mcDeviceGetAttribute(&value, mcDeviceAttributeWarpSize, + device.device_id)); + break; + } + case kMaxSharedMemoryPerBlock: { + MACA_CALL(mcDeviceGetAttribute( + &value, mcDeviceAttributeMaxSharedMemoryPerBlock, device.device_id)); + break; + } + case kComputeVersion: { + std::ostringstream os; + MACA_CALL(mcDeviceGetAttribute( + &value, mcDeviceAttributeComputeCapabilityMajor, device.device_id)); + os << value << "."; + MACA_CALL(mcDeviceGetAttribute( + &value, mcDeviceAttributeComputeCapabilityMinor, device.device_id)); + os << value; + *rv = os.str(); + return; + } + case kDeviceName: { + std::string name(256, 0); + MACA_CALL(mcDeviceGetName(&name[0], name.size(), device.device_id)); + name.resize(strlen(name.c_str())); + *rv = std::move(name); + return; + } + case kMaxClockRate: { + MACA_CALL(mcDeviceGetAttribute(&value, mcDeviceAttributeClockRate, + device.device_id)); + break; + } + case kMultiProcessorCount: { + MACA_CALL(mcDeviceGetAttribute( + &value, mcDeviceAttributeMultiProcessorCount, device.device_id)); + break; + } + case kMaxThreadDimensions: { + int dims[3]; + MACA_CALL(mcDeviceGetAttribute(&dims[0], mcDeviceAttributeMaxBlockDimX, + device.device_id)); + MACA_CALL(mcDeviceGetAttribute(&dims[1], mcDeviceAttributeMaxBlockDimY, + device.device_id)); + MACA_CALL(mcDeviceGetAttribute(&dims[2], mcDeviceAttributeMaxBlockDimZ, + device.device_id)); - std::stringstream ss; - ss << "[" << dims[0] << ", " << dims[1] << ", " << dims[2] << "]"; - *rv = ss.str(); - return; - } - case kMaxRegistersPerBlock: - MACA_CALL( - mcDeviceGetAttribute(&value, mcDeviceAttributeMaxRegistersPerBlock, device.device_id)); - break; - case kGcnArch: - return; - case kApiVersion: { - // *rv = MACA_VERSION; - return; - } - case kDriverVersion: - return; - case kL2CacheSizeBytes: { - // Get size of device l2 cache size in bytes. - int l2_size; - MACA_CALL(mcDeviceGetAttribute(&l2_size, mcDeviceAttributeL2CacheSize, device.device_id)); - *rv = l2_size; - return; - } - case kTotalGlobalMemory: { - mcDeviceProp_t prop; - MACA_CALL(mcGetDeviceProperties(&prop, device.device_id)); - int64_t total_global_memory = prop.totalGlobalMem; - *rv = total_global_memory; - return; - } - case kAvailableGlobalMemory: { - size_t free_mem, total_mem; - MACA_CALL(mcMemGetInfo(&free_mem, &total_mem)); - *rv = static_cast(free_mem); - return; - } - case kImagePitchAlignment: - return; + std::stringstream ss; + ss << "[" << dims[0] << ", " << dims[1] << ", " << dims[2] << "]"; + *rv = ss.str(); + return; + } + case kMaxRegistersPerBlock: + MACA_CALL(mcDeviceGetAttribute( + &value, mcDeviceAttributeMaxRegistersPerBlock, device.device_id)); + break; + case kGcnArch: + return; + case kApiVersion: { + // *rv = MACA_VERSION; + return; + } + case kDriverVersion: + return; + case kL2CacheSizeBytes: { + // Get size of device l2 cache size in bytes. + int l2_size; + MACA_CALL(mcDeviceGetAttribute(&l2_size, mcDeviceAttributeL2CacheSize, + device.device_id)); + *rv = l2_size; + return; + } + case kTotalGlobalMemory: { + mcDeviceProp_t prop; + MACA_CALL(mcGetDeviceProperties(&prop, device.device_id)); + int64_t total_global_memory = prop.totalGlobalMem; + *rv = total_global_memory; + return; + } + case kAvailableGlobalMemory: { + size_t free_mem, total_mem; + MACA_CALL(mcMemGetInfo(&free_mem, &total_mem)); + *rv = static_cast(free_mem); + return; + } + case kImagePitchAlignment: + return; } *rv = value; } - void* AllocDataSpace(Device dev, size_t nbytes, size_t alignment, DLDataType type_hint) final { + void *AllocDataSpace(Device dev, size_t nbytes, size_t alignment, + DLDataType type_hint) final { ICHECK_EQ(256 % alignment, 0U) << "MACA space is aligned at 256 bytes"; - void* ret; + void *ret; if (dev.device_type == kDLMACAHost) { VLOG(1) << "allocating " << nbytes << "bytes on host"; MACA_CALL(mcMallocHost(&ret, nbytes)); @@ -155,7 +162,7 @@ class MACADeviceAPI final : public DeviceAPI { return ret; } - void FreeDataSpace(Device dev, void* ptr) final { + void FreeDataSpace(Device dev, void *ptr) final { if (dev.device_type == kDLMACAHost) { MACA_CALL(mcFreeHost(ptr)); } else { @@ -165,12 +172,13 @@ class MACADeviceAPI final : public DeviceAPI { } protected: - void CopyDataFromTo(const void* from, size_t from_offset, void* to, size_t to_offset, size_t size, - Device dev_from, Device dev_to, DLDataType type_hint, + void CopyDataFromTo(const void *from, size_t from_offset, void *to, + size_t to_offset, size_t size, Device dev_from, + Device dev_to, DLDataType type_hint, TVMStreamHandle stream) final { mcStream_t maca_stream = static_cast(stream); - from = static_cast(from) + from_offset; - to = static_cast(to) + to_offset; + from = static_cast(from) + from_offset; + to = static_cast(to) + to_offset; if (dev_from.device_type == kDLMACAHost) { dev_from.device_type = kDLCPU; } @@ -183,13 +191,15 @@ protected: if (dev_from.device_id == dev_to.device_id) { GPUCopy(from, to, size, mcMemcpyDeviceToDevice, maca_stream); } else { - MACA_CALL( - mcMemcpyPeerAsync(to, dev_to.device_id, from, dev_from.device_id, size, maca_stream)); + MACA_CALL(mcMemcpyPeerAsync(to, dev_to.device_id, from, + dev_from.device_id, size, maca_stream)); } - } else if (dev_from.device_type == kDLMACA && dev_to.device_type == kDLCPU) { + } else if (dev_from.device_type == kDLMACA && + dev_to.device_type == kDLCPU) { MACA_CALL(mcSetDevice(dev_from.device_id)); GPUCopy(from, to, size, mcMemcpyDeviceToHost, maca_stream); - } else if (dev_from.device_type == kDLCPU && dev_to.device_type == kDLMACA) { + } else if (dev_from.device_type == kDLCPU && + dev_to.device_type == kDLMACA) { MACA_CALL(mcSetDevice(dev_to.device_id)); GPUCopy(from, to, size, mcMemcpyHostToDevice, maca_stream); } else { @@ -211,7 +221,8 @@ public: MACA_CALL(mcStreamDestroy(mc_stream)); } - void SyncStreamFromTo(Device dev, TVMStreamHandle event_src, TVMStreamHandle event_dst) { + void SyncStreamFromTo(Device dev, TVMStreamHandle event_src, + TVMStreamHandle event_dst) { MACA_CALL(mcSetDevice(dev.device_id)); mcStream_t src_stream = static_cast(event_src); mcStream_t dst_stream = static_cast(event_dst); @@ -227,22 +238,22 @@ public: MACA_CALL(mcStreamSynchronize(static_cast(stream))); } - void* AllocWorkspace(Device dev, size_t size, DLDataType type_hint) final { + void *AllocWorkspace(Device dev, size_t size, DLDataType type_hint) final { return MACAThreadEntry::ThreadLocal()->pool.AllocWorkspace(dev, size); } - void FreeWorkspace(Device dev, void* data) final { + void FreeWorkspace(Device dev, void *data) final { MACAThreadEntry::ThreadLocal()->pool.FreeWorkspace(dev, data); } - static MACADeviceAPI* Global() { - static MACADeviceAPI* inst = new MACADeviceAPI(); + static MACADeviceAPI *Global() { + static MACADeviceAPI *inst = new MACADeviceAPI(); return inst; } - private: - static void GPUCopy(const void* from, void* to, size_t size, mcMemcpyKind kind, - mcStream_t stream) { +private: + static void GPUCopy(const void *from, void *to, size_t size, + mcMemcpyKind kind, mcStream_t stream) { MACA_CALL(mcMemcpyAsync(to, from, size, kind, stream)); } }; @@ -251,24 +262,27 @@ typedef dmlc::ThreadLocalStore MACAThreadStore; MACAThreadEntry::MACAThreadEntry() : pool(kDLMACA, MACADeviceAPI::Global()) {} -MACAThreadEntry* MACAThreadEntry::ThreadLocal() { return MACAThreadStore::Get(); } +MACAThreadEntry *MACAThreadEntry::ThreadLocal() { + return MACAThreadStore::Get(); +} TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() - .def_packed("device_api.maca", - [](ffi::PackedArgs args, ffi::Any *rv) { - DeviceAPI* ptr = MACADeviceAPI::Global(); - *rv = static_cast(ptr); - }) - .def_packed("device_api.maca_host", [](ffi::PackedArgs args, ffi::Any* rv) { - DeviceAPI* ptr = MACADeviceAPI::Global(); - *rv = static_cast(ptr); - }); + .def_packed("device_api.maca", + [](ffi::PackedArgs args, ffi::Any *rv) { + DeviceAPI *ptr = MACADeviceAPI::Global(); + *rv = static_cast(ptr); + }) + .def_packed("device_api.maca_host", + [](ffi::PackedArgs args, ffi::Any *rv) { + DeviceAPI *ptr = MACADeviceAPI::Global(); + *rv = static_cast(ptr); + }); } class MACATimerNode : public TimerNode { - public: +public: virtual void Start() { int device_id; MACA_CALL(mcGetDevice(&device_id)); @@ -293,9 +307,10 @@ class MACATimerNode : public TimerNode { MACA_CALL(mcEventCreate(&stop_)); } - TVM_FFI_DECLARE_OBJECT_INFO_FINAL("runtime.maca.MACATimerNode", MACATimerNode, TimerNode); + TVM_FFI_DECLARE_OBJECT_INFO_FINAL("runtime.maca.MACATimerNode", MACATimerNode, + TimerNode); - private: +private: mcEvent_t start_; mcEvent_t stop_; TVMStreamHandle stream_; @@ -303,8 +318,9 @@ class MACATimerNode : public TimerNode { TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; - refl::GlobalDef().def("profiling.timer.maca", - [](Device dev) { return Timer(ffi::make_object()); }); + refl::GlobalDef().def("profiling.timer.maca", [](Device dev) { + return Timer(ffi::make_object()); + }); } -} // namespace runtime -} // namespace tvm +} // namespace runtime +} // namespace tvm diff --git a/src/target/maca_module.cc b/src/target/maca_module.cc index 10cccc4f..b8c122c4 100644 --- a/src/target/maca_module.cc +++ b/src/target/maca_module.cc @@ -34,11 +34,11 @@ #include #include +#include "maca_common.h" #include "runtime/file_utils.h" #include "runtime/meta_data.h" #include "runtime/pack_args.h" #include "runtime/thread_storage_scope.h" -#include "maca_common.h" namespace tvm { namespace runtime { @@ -48,7 +48,7 @@ namespace runtime { // The runtime will contain a per-device module table // The modules will be lazily loaded class MACAModuleNode : public ffi::ModuleObj { - public: +public: explicit MACAModuleNode(std::string data, std::string fmt, std::unordered_map fmap, std::string maca_source) @@ -65,14 +65,15 @@ class MACAModuleNode : public ffi::ModuleObj { } } - const char* kind() const final { return "maca"; } + const char *kind() const final { return "maca"; } int GetPropertyMask() const final { return ffi::Module::kBinarySerializable | ffi::Module::kRunnable; } - ffi::Optional GetFunction(const ffi::String& name) final; + ffi::Optional GetFunction(const ffi::String &name) final; - void WriteToFile(const ffi::String& file_name, const ffi::String& format) const final { + void WriteToFile(const ffi::String &file_name, + const ffi::String &format) const final { std::string fmt = GetFileFormat(file_name, format); std::string meta_file = GetMetaFilePath(file_name); if (fmt == "maca") { @@ -89,25 +90,27 @@ class MACAModuleNode : public ffi::ModuleObj { ffi::Bytes SaveToBytes() const final { std::string buffer; dmlc::MemoryStringStream ms(&buffer); - dmlc::Stream* stream = &ms; + dmlc::Stream *stream = &ms; stream->Write(fmt_); stream->Write(fmap_); stream->Write(data_); return ffi::Bytes(buffer); } - ffi::String InspectSource(const ffi::String& format) const final { - if (format == fmt_) return data_; + ffi::String InspectSource(const ffi::String &format) const final { + if (format == fmt_) + return data_; if (maca_source_.length() != 0) { return maca_source_; } else { - if (fmt_ == "fatbin") return data_; + if (fmt_ == "fatbin") + return data_; return ""; } } // get a mcfunction_t from primary context in device_id - mcFunction_t GetFunc(int device_id, const std::string& func_name) { + mcFunction_t GetFunc(int device_id, const std::string &func_name) { std::lock_guard lock(mutex_); // must recheck under the lock scope @@ -115,7 +118,8 @@ class MACAModuleNode : public ffi::ModuleObj { MACA_DRIVER_CALL(mcModuleLoadData(&(module_[device_id]), data_.c_str())); } mcFunction_t func; - mcError_t result = mcModuleGetFunction(&func, module_[device_id], func_name.c_str()); + mcError_t result = + mcModuleGetFunction(&func, module_[device_id], func_name.c_str()); if (result != mcSuccess) { LOG(FATAL) << "MACAError: mcModuleGetFunction " << func_name << " failed with error: " << mcGetErrorString(result); @@ -123,7 +127,8 @@ class MACAModuleNode : public ffi::ModuleObj { return func; } // get a global var from primary context in device_id - mcDeviceptr_t GetGlobal(int device_id, const std::string& global_name, size_t expect_nbytes) { + mcDeviceptr_t GetGlobal(int device_id, const std::string &global_name, + size_t expect_nbytes) { std::lock_guard lock(mutex_); // must recheck under the lock scope if (module_[device_id] == nullptr) { @@ -132,12 +137,13 @@ class MACAModuleNode : public ffi::ModuleObj { mcDeviceptr_t global = nullptr; size_t nbytes = 0; - MACA_DRIVER_CALL(mcModuleGetGlobal(&global, &nbytes, module_[device_id], global_name.c_str())); + MACA_DRIVER_CALL(mcModuleGetGlobal(&global, &nbytes, module_[device_id], + global_name.c_str())); ICHECK_EQ(nbytes, expect_nbytes); return global; } - private: +private: // the binary data std::string data_; // The format @@ -154,10 +160,11 @@ class MACAModuleNode : public ffi::ModuleObj { // a wrapped function class to get packed func. class MACAWrappedFunc { - public: +public: // initialize the MACA function. - void Init(MACAModuleNode* m, ObjectPtr sptr, const std::string& func_name, - size_t num_void_args, const std::vector& launch_param_tags) { + void Init(MACAModuleNode *m, ObjectPtr sptr, + const std::string &func_name, size_t num_void_args, + const std::vector &launch_param_tags) { m_ = m; sptr_ = sptr; func_name_ = func_name; @@ -165,7 +172,7 @@ class MACAWrappedFunc { launch_param_config_.Init(num_void_args, launch_param_tags); } // invoke the function with void arguments - void operator()(ffi::PackedArgs args, ffi::Any* rv, void* packed_args, + void operator()(ffi::PackedArgs args, ffi::Any *rv, void *packed_args, size_t packed_nbytes) const { int device_id; MACA_CALL(mcGetDevice(&device_id)); @@ -173,21 +180,23 @@ class MACAWrappedFunc { fcache_[device_id] = m_->GetFunc(device_id, func_name_); } - mcStream_t strm = static_cast(TVMFFIEnvGetStream(kDLMACA, device_id)); + mcStream_t strm = + static_cast(TVMFFIEnvGetStream(kDLMACA, device_id)); ThreadWorkLoad wl = launch_param_config_.Extract(args); - void* config[] = {MC_LAUNCH_PARAM_BUFFER_POINTER, packed_args, MC_LAUNCH_PARAM_BUFFER_SIZE, - &packed_nbytes, MC_LAUNCH_PARAM_END}; + void *config[] = {MC_LAUNCH_PARAM_BUFFER_POINTER, packed_args, + MC_LAUNCH_PARAM_BUFFER_SIZE, &packed_nbytes, + MC_LAUNCH_PARAM_END}; // MACA supports only extra_args. - MACA_DRIVER_CALL(mcModuleLaunchKernel(fcache_[device_id], wl.grid_dim(0), wl.grid_dim(1), - wl.grid_dim(2), wl.block_dim(0), wl.block_dim(1), - wl.block_dim(2), wl.dyn_shmem_size, strm, nullptr, - reinterpret_cast(&config))); + MACA_DRIVER_CALL(mcModuleLaunchKernel( + fcache_[device_id], wl.grid_dim(0), wl.grid_dim(1), wl.grid_dim(2), + wl.block_dim(0), wl.block_dim(1), wl.block_dim(2), wl.dyn_shmem_size, + strm, nullptr, reinterpret_cast(&config))); } - private: +private: // internal module - MACAModuleNode* m_; + MACAModuleNode *m_; // the resource holder ObjectPtr sptr_; // The name of the function. @@ -199,25 +208,29 @@ class MACAWrappedFunc { LaunchParamConfig launch_param_config_; }; -ffi::Optional MACAModuleNode::GetFunction(const ffi::String& name) { +ffi::Optional +MACAModuleNode::GetFunction(const ffi::String &name) { ObjectPtr sptr_to_self = ffi::GetObjectPtr(this); ICHECK_EQ(sptr_to_self.get(), this); auto it = fmap_.find(name); - if (it == fmap_.end()) return ffi::Function(); - const FunctionInfo& info = it->second; + if (it == fmap_.end()) + return ffi::Function(); + const FunctionInfo &info = it->second; MACAWrappedFunc f; - f.Init(this, sptr_to_self, name, info.arg_types.size(), info.launch_param_tags); + f.Init(this, sptr_to_self, name, info.arg_types.size(), + info.launch_param_tags); return PackFuncPackedArgAligned(f, info.arg_types); } ffi::Module MACAModuleCreate(std::string data, std::string fmt, - std::unordered_map fmap, - std::string maca_source) { + std::unordered_map fmap, + std::string maca_source) { auto n = ffi::make_object(data, fmt, fmap, maca_source); return ffi::Module(n); } -ffi::Module MACAModuleLoadFile(const std::string& file_name, const ffi::String& format) { +ffi::Module MACAModuleLoadFile(const std::string &file_name, + const ffi::String &format) { std::string data; std::unordered_map fmap; std::string fmt = GetFileFormat(file_name, format); @@ -227,9 +240,10 @@ ffi::Module MACAModuleLoadFile(const std::string& file_name, const ffi::String& return MACAModuleCreate(data, fmt, fmap, std::string()); } -ffi::Module MACAModuleLoadFromBytes(const ffi::Bytes& bytes) { - dmlc::MemoryFixedSizeStream ms(const_cast(bytes.data()), bytes.size()); - dmlc::Stream* stream = &ms; +ffi::Module MACAModuleLoadFromBytes(const ffi::Bytes &bytes) { + dmlc::MemoryFixedSizeStream ms(const_cast(bytes.data()), + bytes.size()); + dmlc::Stream *stream = &ms; std::string data; std::unordered_map fmap; std::string fmt; @@ -242,8 +256,8 @@ ffi::Module MACAModuleLoadFromBytes(const ffi::Bytes& bytes) { TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() - .def("ffi.Module.load_from_file.maca", MACAModuleLoadFile) - .def("ffi.Module.load_from_bytes.maca", MACAModuleLoadFromBytes); + .def("ffi.Module.load_from_file.maca", MACAModuleLoadFile) + .def("ffi.Module.load_from_bytes.maca", MACAModuleLoadFromBytes); } -} // namespace runtime -} // namespace tvm +} // namespace runtime +} // namespace tvm diff --git a/src/target/maca_module.h b/src/target/maca_module.h index a1dc2a43..46896ae0 100644 --- a/src/target/maca_module.h +++ b/src/target/maca_module.h @@ -48,8 +48,8 @@ static constexpr const int kMaxNumGPUs = 32; * \param maca_source Optional, maca source file */ ffi::Module MACAModuleCreate(std::string data, std::string fmt, - std::unordered_map fmap, - std::string maca_source); -} // namespace runtime -} // namespace tvm -#endif // TVM_RUNTIME_MACA_MACA_MODULE_H_ + std::unordered_map fmap, + std::string maca_source); +} // namespace runtime +} // namespace tvm +#endif // TVM_RUNTIME_MACA_MACA_MODULE_H_ diff --git a/src/target/maca_target_kind.cc b/src/target/maca_target_kind.cc index 4ceff4cd..bb2ec579 100644 --- a/src/target/maca_target_kind.cc +++ b/src/target/maca_target_kind.cc @@ -3,24 +3,28 @@ namespace tvm { -std::string ExtractStringWithPrefix(const std::string& str, const std::string& prefix) { - if (str.find(prefix) != 0) return ""; +std::string ExtractStringWithPrefix(const std::string &str, + const std::string &prefix) { + if (str.find(prefix) != 0) + return ""; std::size_t pos = prefix.length(); - while (pos < str.length() && (std::isdigit(str[pos]) || std::isalpha(str[pos]))) { + while (pos < str.length() && + (std::isdigit(str[pos]) || std::isalpha(str[pos]))) { ++pos; } return str.substr(prefix.length(), pos - prefix.length()); } -void CheckOrSetAttr(ffi::Map* attrs, const ffi::String& name, - const ffi::String& value) { +void CheckOrSetAttr(ffi::Map *attrs, + const ffi::String &name, const ffi::String &value) { auto iter = attrs->find(name); if (iter == attrs->end()) { attrs->Set(name, value); } else { auto str = (*iter).second.try_cast(); - ICHECK(str && str.value() == value) << "ValueError: Expects \"" << name << "\" to be \"" - << value << "\", but gets: " << (*iter).second; + ICHECK(str && str.value() == value) + << "ValueError: Expects \"" << name << "\" to be \"" << value + << "\", but gets: " << (*iter).second; } } @@ -36,10 +40,12 @@ TargetJSON UpdateMACAAttrs(TargetJSON target) { if (target.count("mcpu")) { ffi::String mcpu = Downcast(target.at("mcpu")); arch = ExtractStringWithPrefix(mcpu, "xcore"); - ICHECK(!arch.empty()) << "ValueError: MACA target gets an invalid XCORE version: -mcpu=" - << mcpu; + ICHECK(!arch.empty()) + << "ValueError: MACA target gets an invalid XCORE version: -mcpu=" + << mcpu; } else { - if (auto f_get_maca_arch = tvm::ffi::Function::GetGlobal("tvm_callback_maca_get_arch")) { + if (auto f_get_maca_arch = + tvm::ffi::Function::GetGlobal("tvm_callback_maca_get_arch")) { arch = (*f_get_maca_arch)().cast(); } target.Set("mcpu", ffi::String(arch)); diff --git a/src/target/rt_mod_maca.cc b/src/target/rt_mod_maca.cc index 9c9597f1..281d96b9 100644 --- a/src/target/rt_mod_maca.cc +++ b/src/target/rt_mod_maca.cc @@ -1,4 +1,5 @@ -// Copyright (c) 2025 MetaX Integrated Circuits (Shanghai) Co., Ltd. All rights reserved. +// Copyright (c) 2025 MetaX Integrated Circuits (Shanghai) Co., Ltd. All rights +// reserved. #include "../transform/common/attr.h" #include "codegen_maca.h" @@ -118,9 +119,9 @@ ffi::Module BuildTileLangMACAWithoutCompile(IRModule mod, Target target) { TVM_FFI_STATIC_INIT_BLOCK() { namespace refl = tvm::ffi::reflection; refl::GlobalDef() - .def("target.build.tilelang_maca", BuildTileLangMACA) - .def("target.build.tilelang_maca_without_compile", - BuildTileLangMACAWithoutCompile); + .def("target.build.tilelang_maca", BuildTileLangMACA) + .def("target.build.tilelang_maca_without_compile", + BuildTileLangMACAWithoutCompile); } } // namespace codegen diff --git a/src/target/utils.cc b/src/target/utils.cc index 0e35bf9b..e35f1891 100644 --- a/src/target/utils.cc +++ b/src/target/utils.cc @@ -1,4 +1,5 @@ -// 2025 - Modified by MetaX Integrated Circuits (Shanghai) Co., Ltd. All Rights Reserved. +// 2025 - Modified by MetaX Integrated Circuits (Shanghai) Co., Ltd. All Rights +// Reserved. /*! * \file tl/target/utils.cc * \brief helper functions for target attributes. diff --git a/src/target/utils.h b/src/target/utils.h index 6ed6cc9e..c569c4e6 100644 --- a/src/target/utils.h +++ b/src/target/utils.h @@ -1,4 +1,5 @@ -// 2025 - Modified by MetaX Integrated Circuits (Shanghai) Co., Ltd. All Rights Reserved. +// 2025 - Modified by MetaX Integrated Circuits (Shanghai) Co., Ltd. All Rights +// Reserved. /*! * \file tl/target/utils.h * \brief helper functions for target attributes. diff --git a/src/tl_templates/maca/common.h b/src/tl_templates/maca/common.h index 9b019729..24b5d141 100644 --- a/src/tl_templates/maca/common.h +++ b/src/tl_templates/maca/common.h @@ -1,12 +1,13 @@ -// Copyright (c) 2025 MetaX Integrated Circuits (Shanghai) Co., Ltd. All rights reserved. +// Copyright (c) 2025 MetaX Integrated Circuits (Shanghai) Co., Ltd. All rights +// reserved. #pragma once -#include #include #include -#include #include +#include +#include #include #define MACART_INF_F __int_as_float(0x7f800000) @@ -31,20 +32,20 @@ #define TILELANG_CHECK(stmt) \ do { \ - mcError_t __err = (stmt); \ - if (__err != mcSuccess) { \ + mcError_t __err = (stmt); \ + if (__err != mcSuccess) { \ snprintf(error_buf, ERROR_BUF_SIZE, "%s:%d: %s - %s", __FILE__, \ - __LINE__, mcGetErrorName(__err), mcGetErrorString(__err)); \ + __LINE__, mcGetErrorName(__err), mcGetErrorString(__err)); \ return -1; \ } \ } while (0) #define TILELANG_CHECK_LAST_ERROR(kernel_name) \ do { \ - mcError_t __err = mcGetLastError(); \ - if (__err != mcSuccess) { \ + mcError_t __err = mcGetLastError(); \ + if (__err != mcSuccess) { \ snprintf(error_buf, ERROR_BUF_SIZE, "kernel_name: %s - %s", \ - mcGetErrorName(__err), mcGetErrorString(__err)); \ + mcGetErrorName(__err), mcGetErrorString(__err)); \ return -1; \ } \ } while (0) @@ -101,7 +102,8 @@ TL_DEVICE unsigned __pack_half2(const half_t x, const half_t y) { } // Pack two bfloat16_t values. -TL_DEVICE unsigned __pack_maca_bfloat162(const bfloat16_t x, const bfloat16_t y) { +TL_DEVICE unsigned __pack_maca_bfloat162(const bfloat16_t x, + const bfloat16_t y) { unsigned v0 = *((unsigned short *)&x); unsigned v1 = *((unsigned short *)&y); return (v1 << 16) | v0; @@ -113,8 +115,7 @@ TL_DEVICE void AtomicAdd(T1 *address, T2 val, int memory_order = 0) { atomicAdd(reinterpret_cast(address), static_cast(val)); } -template -TL_DEVICE void AtomicAdd(_Float16 *address, T val) { +template TL_DEVICE void AtomicAdd(_Float16 *address, T val) { atomicAdd(reinterpret_cast<__half *>(address), static_cast<__half>(val)); } @@ -129,11 +130,14 @@ TL_DEVICE half_t min(const half_t a, const half_t b) { // DP4A TL_DEVICE int __dp4a(int srcA, int srcB, int c) { int4 v_srca{(signed char)(srcA & 0xff), (signed char)((srcA >> 8) & 0xff), - (signed char)((srcA >> 16) & 0xff), (signed char)((srcA >> 24) & 0xff)}; + (signed char)((srcA >> 16) & 0xff), + (signed char)((srcA >> 24) & 0xff)}; int4 v_srcb{(signed char)(srcB & 0xff), (signed char)((srcB >> 8) & 0xff), - (signed char)((srcB >> 16) & 0xff), (signed char)((srcB >> 24) & 0xff)}; + (signed char)((srcB >> 16) & 0xff), + (signed char)((srcB >> 24) & 0xff)}; - return v_srca.x * v_srcb.x + v_srca.y * v_srcb.y + v_srca.z * v_srcb.z + v_srca.w * v_srcb.w + c; + return v_srca.x * v_srcb.x + v_srca.y * v_srcb.y + v_srca.z * v_srcb.z + + v_srca.w * v_srcb.w + c; } // Helper to cast SMEM pointer to unsigned diff --git a/src/tl_templates/maca/debug.h b/src/tl_templates/maca/debug.h index 874bef4d..22b9423b 100644 --- a/src/tl_templates/maca/debug.h +++ b/src/tl_templates/maca/debug.h @@ -1,4 +1,5 @@ -// Copyright (c) 2025 MetaX Integrated Circuits (Shanghai) Co., Ltd. All rights reserved. +// Copyright (c) 2025 MetaX Integrated Circuits (Shanghai) Co., Ltd. All rights +// reserved. #pragma once @@ -53,7 +54,6 @@ template <> __device__ void debug_print_var(const char *msg, half var) { threadIdx.z, (float)var); } - // Specialization for bfloat16_t type template <> __device__ void debug_print_var(const char *msg, bfloat16_t var) { @@ -86,10 +86,9 @@ __device__ void debug_print_var(const char *msg, fp8_e4_t var) { // template <> // __device__ void debug_print_var(const char *msg, fp8_e5_t var) { // printf( -// "msg='%s' BlockIdx=(%d, %d, %d), ThreadIdx=(%d, %d, %d): dtype=fp8_e5_t " -// "value=%f\n", -// msg, blockIdx.x, blockIdx.y, blockIdx.z, threadIdx.x, threadIdx.y, -// threadIdx.z, (float)var); +// "msg='%s' BlockIdx=(%d, %d, %d), ThreadIdx=(%d, %d, %d): dtype=fp8_e5_t +// " "value=%f\n", msg, blockIdx.x, blockIdx.y, blockIdx.z, threadIdx.x, +// threadIdx.y, threadIdx.z, (float)var); // } // Template declaration for device-side debug printing (buffer only) @@ -190,7 +189,8 @@ __device__ void debug_print_buffer_value(const char *msg, // __device__ void debug_print_buffer_value(const char *msg, // const char *buf_name, // int index, fp8_e5_t var) { -// printf("msg='%s' BlockIdx=(%d, %d, %d), ThreadIdx=(%d, %d, %d): buffer=%s, " +// printf("msg='%s' BlockIdx=(%d, %d, %d), ThreadIdx=(%d, %d, %d): buffer=%s, +// " // "index=%d, dtype=fp8_e5_t value=%f\n", // msg, blockIdx.x, blockIdx.y, blockIdx.z, threadIdx.x, threadIdx.y, // threadIdx.z, buf_name, index, (float)var); diff --git a/src/tl_templates/maca/gemm.h b/src/tl_templates/maca/gemm.h index 47f11b89..681922ba 100644 --- a/src/tl_templates/maca/gemm.h +++ b/src/tl_templates/maca/gemm.h @@ -1,4 +1,5 @@ -// Copyright (c) 2025 MetaX Integrated Circuits (Shanghai) Co., Ltd. All rights reserved. +// Copyright (c) 2025 MetaX Integrated Circuits (Shanghai) Co., Ltd. All rights +// reserved. #pragma once @@ -11,8 +12,7 @@ namespace cute { template struct DispatchInstruction; -template <> -struct DispatchInstruction { +template <> struct DispatchInstruction { using MMA = MMA_Atom>; }; @@ -24,7 +24,7 @@ template struct OperandTraits<16, N, K, true, num_warp_n, typename std::enable_if::type> { using LayoutAtom = decltype(composition( - Swizzle<2, 3, 3>{}, Layout, Stride<_32, _1>>{})); + Swizzle<2, 3, 3>{}, Layout, Stride<_32, _1>>{})); using Layout = decltype(tile_to_shape(LayoutAtom{}, Shape, Int>{})); using Copy = Copy_Traits>; }; @@ -68,8 +68,10 @@ public: using Instruction = DispatchInstruction; - using OperandATraits = OperandTraits::value, M, K, !trans_A, num_warp_m>; - using OperandBTraits = OperandTraits::value, N, K, trans_B, num_warp_n>; + using OperandATraits = + OperandTraits::value, M, K, !trans_A, num_warp_m>; + using OperandBTraits = + OperandTraits::value, N, K, trans_B, num_warp_n>; using SmemLayoutA = typename OperandATraits::Layout; using SmemLayoutB = typename OperandBTraits::Layout; @@ -159,9 +161,8 @@ template MCTLASS_DEVICE void gemm_ss(A_type *pA, B_type *pB, C_type *accum) { - using MMA = - cute::GemmTensorOp; + using MMA = cute::GemmTensorOp; MMA::body(pA, pB, accum); } @@ -169,9 +170,8 @@ template TL_DEVICE void gemm_rs(A_type *pA, B_type *pB, C_type *accum) { - using MMA = - cute::GemmTensorOp; + using MMA = cute::GemmTensorOp; MMA::body_rs(pA, pB, accum); } } // namespace tl diff --git a/src/tl_templates/maca/reduce.h b/src/tl_templates/maca/reduce.h index ecce0574..e455ed52 100644 --- a/src/tl_templates/maca/reduce.h +++ b/src/tl_templates/maca/reduce.h @@ -1,4 +1,5 @@ -// Copyright (c) 2025 MetaX Integrated Circuits (Shanghai) Co., Ltd. All rights reserved. +// Copyright (c) 2025 MetaX Integrated Circuits (Shanghai) Co., Ltd. All rights +// reserved. #pragma once diff --git a/src/tl_templates/maca/threadblock_swizzle.h b/src/tl_templates/maca/threadblock_swizzle.h index 60671cbf..1f2f5b0e 100644 --- a/src/tl_templates/maca/threadblock_swizzle.h +++ b/src/tl_templates/maca/threadblock_swizzle.h @@ -1,4 +1,5 @@ -// Copyright (c) 2025 MetaX Integrated Circuits (Shanghai) Co., Ltd. All rights reserved. +// Copyright (c) 2025 MetaX Integrated Circuits (Shanghai) Co., Ltd. All rights +// reserved. #pragma once diff --git a/src/transform/arg_binder.cc b/src/transform/arg_binder.cc index 4b92c0a1..9909588e 100644 --- a/src/transform/arg_binder.cc +++ b/src/transform/arg_binder.cc @@ -1041,7 +1041,9 @@ void ArgBinder::BindDLTensors( // Check device_type consistency (device_id equality is implicitly ensured // by binding above) { - PrimExpr ok = (device_type == actual_dev_type) || (device_type == DLDeviceType::kDLMACA && actual_dev_type == DLDeviceType::kDLCUDA); + PrimExpr ok = (device_type == actual_dev_type) || + (device_type == DLDeviceType::kDLMACA && + actual_dev_type == DLDeviceType::kDLCUDA); ffi::Array pargs2; pargs2.push_back(StringImm(tvm_error_device_type_mismatch)); pargs2.push_back(StringImm(kernel_nm)); diff --git a/test/test.commit b/test/test.commit index 06896a6d..11819826 100644 --- a/test/test.commit +++ b/test/test.commit @@ -1,3 +1,3 @@ 测试1 测试2 -测试3 \ No newline at end of file +测试3 diff --git a/testing/python/conftest.py b/testing/python/conftest.py index a6766a8d..2a15ccf3 100644 --- a/testing/python/conftest.py +++ b/testing/python/conftest.py @@ -3,15 +3,12 @@ import os import pytest + def _parameterize_target(metafunc): # ENV variable TILELANG_TEST_TARGETS specify target names splited by ";" # default value is maca if "target" in metafunc.fixturenames: - parametrized_args = [ - arg.strip() - for mark in metafunc.definition.iter_markers("parametrize") - for arg in mark.args[0].split(",") - ] + parametrized_args = [arg.strip() for mark in metafunc.definition.iter_markers("parametrize") for arg in mark.args[0].split(",")] if "target" not in parametrized_args: mark = pytest.mark.parametrize( "target", @@ -20,5 +17,6 @@ def _parameterize_target(metafunc): ) metafunc.definition.add_marker(mark) + def pytest_generate_tests(metafunc): - _parameterize_target(metafunc) \ No newline at end of file + _parameterize_target(metafunc) diff --git a/tilelang/carver/arch/maca.py b/tilelang/carver/arch/maca.py index 127503c9..e948bd28 100644 --- a/tilelang/carver/arch/maca.py +++ b/tilelang/carver/arch/maca.py @@ -6,6 +6,7 @@ from .arch_base import TileDevice from typing import List, Union from .cuda import TensorInstruction + def is_maca_arch(arch: TileDevice) -> bool: return isinstance(arch, MACA) @@ -34,7 +35,5 @@ class MACA(TileDevice): self.bandwidth: List[int] = [750, 12080] def get_avaliable_tensorintrin_shapes(self): - self.available_tensor_instructions = ( - TensorInstruction("wmma", [16, 16]), - ) + self.available_tensor_instructions = (TensorInstruction("wmma", [16, 16]),) return [t.shape for t in self.available_tensor_instructions] diff --git a/tilelang/carver/roller/hint.py b/tilelang/carver/roller/hint.py index f65ad705..d290a14a 100644 --- a/tilelang/carver/roller/hint.py +++ b/tilelang/carver/roller/hint.py @@ -111,6 +111,7 @@ class TileDict: def __repr__(self) -> str: return str(self) + class IntrinInfo: """ The information of tensorcore intrinsic related information diff --git a/tilelang/contrib/mxcc.py b/tilelang/contrib/mxcc.py index 2e188eca..13ef021a 100644 --- a/tilelang/contrib/mxcc.py +++ b/tilelang/contrib/mxcc.py @@ -236,8 +236,7 @@ def get_target_compute_version(target=None): return tvm.maca(0).compute_version raise ValueError( - "No MACA architecture was specified or GPU detected." - "Try specifying it by adding '--offload-arch=xcorexxxx' to your target." + "No MACA architecture was specified or GPU detected.Try specifying it by adding '--offload-arch=xcorexxxx' to your target." ) diff --git a/tilelang/intrinsics/maca_mma_macro_generator.py b/tilelang/intrinsics/maca_mma_macro_generator.py index f551a0c5..11c0bc1d 100644 --- a/tilelang/intrinsics/maca_mma_macro_generator.py +++ b/tilelang/intrinsics/maca_mma_macro_generator.py @@ -18,16 +18,12 @@ from .mfma_layout import ( shared_16x16_to_local_64x4_layout_B, shared_16x32_to_local_64x8_layout_A, shared_16x32_to_local_64x8_layout_B, - shared_16x64_to_local_64x16_layout_A, - shared_16x64_to_local_64x16_layout_B, thread_id_shared_access_64x1_to_16x4_layout_A, thread_id_shared_access_64x1_to_4x16_layout_B, thread_id_shared_access_64x4_to_16x16_layout_A, thread_id_shared_access_64x4_to_16x16_layout_B, thread_id_shared_access_64x8_to_16x32_layout_A, thread_id_shared_access_64x8_to_16x32_layout_B, - thread_id_shared_access_64x16_to_16x64_layout_A, - thread_id_shared_access_64x16_to_16x64_layout_B, ) lift = convert diff --git a/tilelang/intrinsics/mfma_macro_generator.py b/tilelang/intrinsics/mfma_macro_generator.py index 851d64d3..984476a4 100644 --- a/tilelang/intrinsics/mfma_macro_generator.py +++ b/tilelang/intrinsics/mfma_macro_generator.py @@ -186,6 +186,7 @@ class MatrixCoreIntrinEmitter: self.mfma_suffix = f"{out_dtype_abbrv}_{M_DIM}x{N_DIM}x{k_dim}{in_dtype_abbrv}" else: import logging + logger = logging.getLogger(__name__) logger.warning("need to fix mfma suffix") self.mfma_suffix = f"{M_DIM}x{N_DIM}x{k_dim}{in_dtype_abbrv}" diff --git a/tilelang/quantize/lop3_maca.py b/tilelang/quantize/lop3_maca.py index 77b094a7..9508b391 100644 --- a/tilelang/quantize/lop3_maca.py +++ b/tilelang/quantize/lop3_maca.py @@ -1,6 +1,5 @@ # Copyright (c) 2025 MetaX Integrated Circuits (Shanghai) Co., Ltd. All rights reserved. -from typing import Dict, Literal decode_i4_to_f16 = """ #include "maca_fp16.h" @@ -36,6 +35,4 @@ __device__ void decode_i4u_to_f16(T1 *_i4u, T2 *B_local_decode, const int N = 8) } """ -import_maca_c_map = { - "i4_to_f16": decode_i4_to_f16 -} \ No newline at end of file +import_maca_c_map = {"i4_to_f16": decode_i4_to_f16} diff --git a/tilelang/tileop/gemm_sp/__init__.py b/tilelang/tileop/gemm_sp/__init__.py index 6b8f97ce..9966abf0 100644 --- a/tilelang/tileop/gemm_sp/__init__.py +++ b/tilelang/tileop/gemm_sp/__init__.py @@ -1,8 +1,6 @@ from tilelang import tvm as tvm from tvm import tir -from tilelang.utils.target import ( - target_is_cuda, target_is_maca -) +from tilelang.utils.target import target_is_cuda, target_is_maca from tvm.target import Target from tvm.ir.base import Node from tvm.ir import Range -- Gitee From 96486720cfe166f5b364985c81097262d1c18d59 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Fri, 6 Mar 2026 16:32:25 +0800 Subject: [PATCH 21/94] 6 --- Jenkinsfile | 91 ----------------------------------------------------- 1 file changed, 91 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4c20ed32..3b01d1fa 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -79,95 +79,6 @@ pipeline { uv pip install --python .venv/bin/python pipx .venv/bin/python --version ''' - - // ── Step 4: 检测 GPU toolkit 并设置 PyTorch 索引 URL ───────────────── - // sh ''' - // set -euo pipefail - // export PATH="${HOME}/.local/bin:${PATH}" - // echo "==> [4/6] 检测 GPU toolkit 并配置 PIP_EXTRA_INDEX_URL" - - // # 通过检测工具链自动判断 CUDA / ROCm / Metal - // if command -v nvcc &>/dev/null || [ -x /usr/local/cuda/bin/nvcc ]; then - // export PATH="/usr/local/cuda/bin:${PATH}" - // export LD_LIBRARY_PATH="/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" - // CUDA_VERSION="$(nvcc --version | grep -oP 'release \\K[0-9]+\\.[0-9]+')" - // CUDA_NODOT="${CUDA_VERSION//./}" - // PIP_EXTRA_INDEX_URL="https://download.pytorch.org/whl/cu${CUDA_NODOT}" - // TOOLKIT="CUDA-${CUDA_VERSION}" - // echo "检测到 CUDA ${CUDA_VERSION}" - // echo "CUDA_VERSION=${CUDA_VERSION}" >> "${WORKSPACE}/.env_vars" - // echo "USE_CUDA=ON" >> "${WORKSPACE}/.env_vars" - // echo "CLANG_TIDY_CMAKE_OPTIONS=${CLANG_TIDY_CMAKE_OPTIONS} -DUSE_CUDA=ON" >> "${WORKSPACE}/.env_vars" - // echo "PATH=${PATH}" >> "${WORKSPACE}/.env_vars" - // echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> "${WORKSPACE}/.env_vars" - // elif command -v hipcc &>/dev/null || [ -x /opt/rocm/bin/hipcc ]; then - // export PATH="/opt/rocm/bin:${PATH}" - // export LD_LIBRARY_PATH="/opt/rocm/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" - // ROCM_VERSION="$(hipcc --version | grep -oP 'HIP version: \\K[0-9]+\\.[0-9]+')" - // PIP_EXTRA_INDEX_URL="https://download.pytorch.org/whl/rocm${ROCM_VERSION}" - // TOOLKIT="ROCm-${ROCM_VERSION}" - // echo "检测到 ROCm ${ROCM_VERSION}" - // echo "ROCM_VERSION=${ROCM_VERSION}" >> "${WORKSPACE}/.env_vars" - // echo "USE_ROCM=ON" >> "${WORKSPACE}/.env_vars" - // echo "CLANG_TIDY_CMAKE_OPTIONS=${CLANG_TIDY_CMAKE_OPTIONS} -DUSE_ROCM=ON" >> "${WORKSPACE}/.env_vars" - // echo "PATH=${PATH}" >> "${WORKSPACE}/.env_vars" - // echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> "${WORKSPACE}/.env_vars" - // elif [[ "$(uname)" == "Darwin" ]]; then - // PIP_EXTRA_INDEX_URL="" - // TOOLKIT="Metal" - // echo "检测到 macOS Metal" - // echo "USE_METAL=ON" >> "${WORKSPACE}/.env_vars" - // echo "CLANG_TIDY_CMAKE_OPTIONS=${CLANG_TIDY_CMAKE_OPTIONS} -DUSE_METAL=ON" >> "${WORKSPACE}/.env_vars" - // else - // echo "ERROR: 未检测到支持的 GPU toolkit (CUDA / ROCm / Metal)" >&2 - // exit 1 - // fi - - // echo "TOOLKIT=${TOOLKIT}" >> "${WORKSPACE}/.env_vars" - // echo "PIP_EXTRA_INDEX_URL=${PIP_EXTRA_INDEX_URL}" >> "${WORKSPACE}/.env_vars" - // echo "UV_INDEX=${PIP_EXTRA_INDEX_URL}" >> "${WORKSPACE}/.env_vars" - // ''' - - // ── Step 5: 升级基础包 pip / setuptools / wheel ─────────────────────── - // sh ''' - // set -euo pipefail - // export PATH="${HOME}/.local/bin:${PATH}" - // # 载入上一步写入的环境变量 - // [ -f "${WORKSPACE}/.env_vars" ] && export $(grep -v '^#' "${WORKSPACE}/.env_vars" | xargs) - // echo "==> [5/6] 升级 pip / setuptools / wheel" - // uv pip install --python .venv/bin/python --upgrade pip setuptools wheel - // ''' - - // ── Step 6: 安装测试依赖(对应 CI: Setup venv)──────────────────────── - // sh ''' - // set -euo pipefail - // export PATH="${HOME}/.local/bin:${PATH}" - // [ -f "${WORKSPACE}/.env_vars" ] && export $(grep -v '^#' "${WORKSPACE}/.env_vars" | xargs) - // echo "==> [6/6] 安装测试依赖 requirements-test.txt" - - // # 如果是 nightly index,允许预发布版 torch - // if echo "${UV_INDEX:-}" | grep -q "/nightly/"; then - // uv pip install --python .venv/bin/python --prerelease=allow -v torch - // fi - - // uv pip install --python .venv/bin/python -v -r requirements-test.txt - - // # 按 toolkit 安装对应的额外依赖 - // if echo "${TOOLKIT:-}" | grep -q "CUDA"; then - // uv pip install --python .venv/bin/python \ - // --no-build-isolation-package=flash-attn \ - // -v -r requirements-test-cuda.txt - // .venv/bin/python -c "import flash_attn; print(f'flash_attn: {flash_attn.__version__}')" - // elif echo "${TOOLKIT:-}" | grep -q "ROCm"; then - // uv pip install --python .venv/bin/python -v -r requirements-test-rocm.txt - // elif echo "${TOOLKIT:-}" | grep -q "Metal"; then - // uv pip install --python .venv/bin/python -v -r requirements-test-metal.txt - // fi - - // # 打印 torch 环境信息 - // .venv/bin/python -c "import torch; print(f'torch: {torch.__version__}')" - // .venv/bin/python -m torch.utils.collect_env || true - // ''' } post { failure { @@ -208,8 +119,6 @@ pipeline { steps { echo "--- [BUILD] 编译 C++ 内核并以 wheel 形式安装(对应 CI: Install project wheel form) ---" sh ''' - set -euo pipefail - ${UV_BIN} pip install -v . ''' } } -- Gitee From 2613551246fb2f1af68ec4c194569f707aba9b6a Mon Sep 17 00:00:00 2001 From: artlesbol Date: Mon, 9 Mar 2026 00:16:40 +0800 Subject: [PATCH 22/94] fix: import missing libraries, fix typos, update outdated data structures, correct function names, and remove unused scalars. --- examples/gemm/test_example_gemm.py | 1 + testing/python/conftest.py | 2 +- tilelang/carver/arch/maca.py | 8 ++++---- tilelang/intrinsics/maca_mma_macro_generator.py | 5 ++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/gemm/test_example_gemm.py b/examples/gemm/test_example_gemm.py index 88873be0..edeb3c81 100644 --- a/examples/gemm/test_example_gemm.py +++ b/examples/gemm/test_example_gemm.py @@ -1,5 +1,6 @@ # 2025 - Modified by MetaX Integrated Circuits (Shanghai) Co., Ltd. All Rights Reserved. +import pytest import tilelang.testing import example_gemm_autotune import example_gemm_intrinsics diff --git a/testing/python/conftest.py b/testing/python/conftest.py index 2a15ccf3..05fba382 100644 --- a/testing/python/conftest.py +++ b/testing/python/conftest.py @@ -5,7 +5,7 @@ import pytest def _parameterize_target(metafunc): - # ENV variable TILELANG_TEST_TARGETS specify target names splited by ";" + # ENV variable TILELANG_TEST_TARGETS specify target names split by ";" # default value is maca if "target" in metafunc.fixturenames: parametrized_args = [arg.strip() for mark in metafunc.definition.iter_markers("parametrize") for arg in mark.args[0].split(",")] diff --git a/tilelang/carver/arch/maca.py b/tilelang/carver/arch/maca.py index e948bd28..280d2dc5 100644 --- a/tilelang/carver/arch/maca.py +++ b/tilelang/carver/arch/maca.py @@ -1,9 +1,9 @@ # Copyright (c) 2025 MetaX Integrated Circuits (Shanghai) Co., Ltd. All rights reserved. +from __future__ import annotations import tvm from tvm.target import Target from .arch_base import TileDevice -from typing import List, Union from .cuda import TensorInstruction @@ -13,7 +13,7 @@ def is_maca_arch(arch: TileDevice) -> bool: class MACA(TileDevice): # FIXME: config should meets MACA - def __init__(self, target: Union[Target, str]): + def __init__(self, target: Target | str): if isinstance(target, str): target = tvm.target.Target(target) self.target = target @@ -30,9 +30,9 @@ class MACA(TileDevice): self.max_smem_usage: int = 2 * self.smem_cap self.sm_partition: int = 8 self.l2_cache_size_bytes: int = target.l2_cache_size_bytes - self.transaction_size: List[int] = [32, 128] # in bytes + self.transaction_size: list[int] = [32, 128] # in bytes - self.bandwidth: List[int] = [750, 12080] + self.bandwidth: list[int] = [750, 12080] def get_avaliable_tensorintrin_shapes(self): self.available_tensor_instructions = (TensorInstruction("wmma", [16, 16]),) diff --git a/tilelang/intrinsics/maca_mma_macro_generator.py b/tilelang/intrinsics/maca_mma_macro_generator.py index 11c0bc1d..6eca0b52 100644 --- a/tilelang/intrinsics/maca_mma_macro_generator.py +++ b/tilelang/intrinsics/maca_mma_macro_generator.py @@ -126,9 +126,8 @@ class TensorCoreIntrinEmitter: self.accum_dtype_abbrv = self.dtype_abbrv[accum_dtype] def _initialize_mma_prefix(self, k_dim=16): - in_dtype, out_dtype = self.a_dtype, self.accum_dtype + in_dtype = self.a_dtype M_DIM, N_DIM = self.M_DIM, self.N_DIM - out_dtype_abbrv = {T.float16: "f16", T.float32: "f32", T.int8: "i8", T.int32: "i32"}[out_dtype] in_dtype_abbrv = { "bfloat16": "bf16", @@ -415,7 +414,7 @@ class TensorCoreIntrinEmitter: tx, warp_n, warp_m = self.extract_thread_binding(thread_binding) for i, j in T.grid(warp_rows, warp_cols): for local_id in T.vectorized(local_size_out): - row, col = T.meta_var(maca_mma_store_index_map(tx, local_id)) + row, col = T.meta_var(mfma_store_index_map(tx, local_id)) C_buf[ (pid_m * BLOCK_M + warp_m * warp_rows + i) * M_DIM + row, (pid_n * BLOCK_N + warp_n * warp_cols + j) * N_DIM + col ] = C_local_buf[i * warp_cols * local_size_out + j * local_size_out + local_id] -- Gitee From 816ee7ab31ab272582e70b999250c01b6a3ef9d9 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Wed, 11 Mar 2026 15:02:50 +0800 Subject: [PATCH 23/94] 7 --- Jenkinsfile | 61 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3b01d1fa..0f7db0d8 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,9 +32,8 @@ pipeline { // clang-tidy cmake 选项 CLANG_TIDY_CMAKE_OPTIONS = "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" - // GPU Toolkit 标识:可选值 CUDA-12.8 / Nightly-ROCm-7.1 / Metal - // 由 gpu_node1 节点实际配置决定,此处以 CUDA 为默认示例 - TILELANG_TARGET = "cuda" + + DOCKER_IMAGE = "cr.metax-tech.com/public-library/maca-pytorch:3.6.0.10-torch2.6-py310-ubuntu24.04-amd64" } // 3. 构建生命周期 @@ -115,27 +114,49 @@ pipeline { } } - stage('Build & Install') { + stage('Build & Test') { + agent { + docker { + image "${DOCKER_IMAGE}" + args '--net=host --device=/dev/dri --device=/dev/mxcd --group-add video' + reuseNode true + } + } steps { - echo "--- [BUILD] 编译 C++ 内核并以 wheel 形式安装(对应 CI: Install project wheel form) ---" sh ''' + export TILELANG_HOME=$(pwd) + export TVM_ROOT=${TILELANG_HOME}/3rdparty/tvm + export PYTHONPATH=${TILELANG_HOME}:${TVM_ROOT}/python:${PYTHONPATH} + export USE_MACA=ON + export LD_LIBRARY_PATH=/opt/maca/ompi/lib:/opt/maca/mxgpu_llvm/lib:/opt/maca/lib:$LD_LIBRARY_PATH + + # 4. 容器内环境初始化 + sed -i 's@http.*com/ubuntu@http://repo.metax-tech.com/r/ubuntu@g' /etc/apt/sources.list + apt-get update && apt-get install -y git cmake + + pip3 config set global.index-url https://repo.metax-tech.com/r/pypi/simple + pip3 config set install.trusted-host repo.metax-tech.com + pip install pytest-csv cython z3-solver==4.13.0 psutil cloudpickle torch-c-dlpack-ext + + # 5. 编译 (注意安全目录设置,防止容器内 git 报错) + git config --global --add safe.directory ${TILELANG_HOME} + mkdir -p build + cmake -B build -DUSE_MACA=ON + make -C build -j$(nproc) + + # 6. 安装 tvm-ffi + cd 3rdparty/tvm/3rdparty/tvm-ffi && pip install . + cd ${TILELANG_HOME} + + # 7. 运行测试 + python3 examples/quickstart.py + pytest --junitxml=report.xml testing/python/analysis/test_tilelang_nested_loop_checker.py ''' } - } - - stage('Functional Testing') { - steps { - echo "--- [TEST] 正在执行算子功能验证 (pytest) ---" - echo "执行命令: TILELANG_TARGET=${TILELANG_TARGET} uv run pytest testing/python" - echo "预期:通过对标 CPU 结果验证算子生成正确性" - } - } - - stage('Performance Benchmarking') { - steps { - echo "--- [PERF] 正在执行算子性能压测 ---" - echo "执行命令: uv run python benchmarks/gemm_perf.py" - echo "执行命令: uv run python benchmarks/flash_attn_perf.py" + post { + always { + junit 'report.xml' + } } } } -- Gitee From 6631c9dd66c4c731eb3f773f3da1da47f76979dd Mon Sep 17 00:00:00 2001 From: artlesbol Date: Wed, 11 Mar 2026 15:05:55 +0800 Subject: [PATCH 24/94] 8 --- Jenkinsfile | 71 ++++++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0f7db0d8..ac7fda6f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -115,42 +115,47 @@ pipeline { } stage('Build & Test') { - agent { - docker { - image "${DOCKER_IMAGE}" - args '--net=host --device=/dev/dri --device=/dev/mxcd --group-add video' - reuseNode true - } - } + // 这里不再使用 agent { docker },而是直接在节点上运行命令 steps { sh ''' - export TILELANG_HOME=$(pwd) - export TVM_ROOT=${TILELANG_HOME}/3rdparty/tvm - export PYTHONPATH=${TILELANG_HOME}:${TVM_ROOT}/python:${PYTHONPATH} - export USE_MACA=ON - export LD_LIBRARY_PATH=/opt/maca/ompi/lib:/opt/maca/mxgpu_llvm/lib:/opt/maca/lib:$LD_LIBRARY_PATH - - # 4. 容器内环境初始化 - sed -i 's@http.*com/ubuntu@http://repo.metax-tech.com/r/ubuntu@g' /etc/apt/sources.list - apt-get update && apt-get install -y git cmake + echo "--- [DOCKER] 在 gpu_node1 上启动容器 ---" - pip3 config set global.index-url https://repo.metax-tech.com/r/pypi/simple - pip3 config set install.trusted-host repo.metax-tech.com - pip install pytest-csv cython z3-solver==4.13.0 psutil cloudpickle torch-c-dlpack-ext - - # 5. 编译 (注意安全目录设置,防止容器内 git 报错) - git config --global --add safe.directory ${TILELANG_HOME} - mkdir -p build - cmake -B build -DUSE_MACA=ON - make -C build -j$(nproc) - - # 6. 安装 tvm-ffi - cd 3rdparty/tvm/3rdparty/tvm-ffi && pip install . - cd ${TILELANG_HOME} - - # 7. 运行测试 - python3 examples/quickstart.py - pytest --junitxml=report.xml testing/python/analysis/test_tilelang_nested_loop_checker.py + # 使用 docker run 手动挂载工作目录和 GPU 设备 + docker run --rm \ + --net=host \ + --device=/dev/dri:/dev/dri \ + --device=/dev/mxcd:/dev/mxcd \ + --group-add video \ + -v "${WORKSPACE}:${WORKSPACE}" \ + -w "${WORKSPACE}" \ + -e TILELANG_HOME="${WORKSPACE}" \ + "${DOCKER_IMAGE}" /bin/bash -c ' + set -e + export TVM_ROOT=${TILELANG_HOME}/3rdparty/tvm + export PYTHONPATH=${TILELANG_HOME}:${TVM_ROOT}/python:${PYTHONPATH} + export USE_MACA=ON + export LD_LIBRARY_PATH=/opt/maca/ompi/lib:/opt/maca/mxgpu_llvm/lib:/opt/maca/lib:$LD_LIBRARY_PATH + + # 容器内环境初始化 + sed -i "s@http.*com/ubuntu@http://repo.metax-tech.com/r/ubuntu@g" /etc/apt/sources.list + apt-get update && apt-get install -y git cmake + + pip3 config set global.index-url https://repo.metax-tech.com/r/pypi/simple + pip3 config set install.trusted-host repo.metax-tech.com + pip install pytest-csv cython z3-solver==4.13.0 psutil cloudpickle torch-c-dlpack-ext + + # 编译 + git config --global --add safe.directory ${TILELANG_HOME} + mkdir -p build + cmake -B build -DUSE_MACA=ON + make -C build -j$(nproc) + + # 安装 ffi 并运行测试 + cd 3rdparty/tvm/3rdparty/tvm-ffi && pip install . + cd ${TILELANG_HOME} + python3 examples/quickstart.py + pytest --junitxml=report.xml testing/python/analysis/test_tilelang_nested_loop_checker.py + ' ''' } post { -- Gitee From eb3768ac942e4f36f6548979cfc19cec5fafd272 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Wed, 11 Mar 2026 15:07:13 +0800 Subject: [PATCH 25/94] 8 --- Jenkinsfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ac7fda6f..7e1fe0e6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -119,7 +119,7 @@ pipeline { steps { sh ''' echo "--- [DOCKER] 在 gpu_node1 上启动容器 ---" - + # 使用 docker run 手动挂载工作目录和 GPU 设备 docker run --rm \ --net=host \ @@ -135,21 +135,21 @@ pipeline { export PYTHONPATH=${TILELANG_HOME}:${TVM_ROOT}/python:${PYTHONPATH} export USE_MACA=ON export LD_LIBRARY_PATH=/opt/maca/ompi/lib:/opt/maca/mxgpu_llvm/lib:/opt/maca/lib:$LD_LIBRARY_PATH - + # 容器内环境初始化 sed -i "s@http.*com/ubuntu@http://repo.metax-tech.com/r/ubuntu@g" /etc/apt/sources.list apt-get update && apt-get install -y git cmake - + pip3 config set global.index-url https://repo.metax-tech.com/r/pypi/simple pip3 config set install.trusted-host repo.metax-tech.com pip install pytest-csv cython z3-solver==4.13.0 psutil cloudpickle torch-c-dlpack-ext - + # 编译 git config --global --add safe.directory ${TILELANG_HOME} mkdir -p build cmake -B build -DUSE_MACA=ON make -C build -j$(nproc) - + # 安装 ffi 并运行测试 cd 3rdparty/tvm/3rdparty/tvm-ffi && pip install . cd ${TILELANG_HOME} -- Gitee From dc7b6e84acc8291e27719ae11b2e66cd21c0f3dc Mon Sep 17 00:00:00 2001 From: artlesbol Date: Wed, 11 Mar 2026 15:09:52 +0800 Subject: [PATCH 26/94] 8 --- Jenkinsfile | 67 +++++++++++++++++++++++++---------------------------- 1 file changed, 32 insertions(+), 35 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7e1fe0e6..2782d8a4 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -115,12 +115,41 @@ pipeline { } stage('Build & Test') { - // 这里不再使用 agent { docker },而是直接在节点上运行命令 steps { sh ''' echo "--- [DOCKER] 在 gpu_node1 上启动容器 ---" - # 使用 docker run 手动挂载工作目录和 GPU 设备 + # 1. 先定义好脚本内容,避免在 docker run 命令行里嵌套太深 + # 注意:内部使用 \$ 来防止 Jenkins 提前解析容器内的变量 + cat << 'EOF' > docker_internal_script.sh +set -e +export TVM_ROOT=${TILELANG_HOME}/3rdparty/tvm +export PYTHONPATH=${TILELANG_HOME}:${TVM_ROOT}/python:${PYTHONPATH} +export USE_MACA=ON +export LD_LIBRARY_PATH=/opt/maca/ompi/lib:/opt/maca/mxgpu_llvm/lib:/opt/maca/lib:$LD_LIBRARY_PATH + +# 容器内环境初始化 +sed -i "s@http.*com/ubuntu@http://repo.metax-tech.com/r/ubuntu@g" /etc/apt/sources.list +apt-get update && apt-get install -y git cmake + +pip3 config set global.index-url https://repo.metax-tech.com/r/pypi/simple +pip3 config set install.trusted-host repo.metax-tech.com +pip install pytest-csv cython z3-solver==4.13.0 psutil cloudpickle torch-c-dlpack-ext + +# 编译 +git config --global --add safe.directory ${TILELANG_HOME} +mkdir -p build +cmake -B build -DUSE_MACA=ON +make -C build -j$(nproc) + +# 安装 ffi 并运行测试 +cd 3rdparty/tvm/3rdparty/tvm-ffi && pip install . +cd ${TILELANG_HOME} +python3 examples/quickstart.py +pytest --junitxml=report.xml testing/python/analysis/test_tilelang_nested_loop_checker.py +EOF + + # 2. 执行 Docker,直接运行脚本文件 docker run --rm \ --net=host \ --device=/dev/dri:/dev/dri \ @@ -129,41 +158,9 @@ pipeline { -v "${WORKSPACE}:${WORKSPACE}" \ -w "${WORKSPACE}" \ -e TILELANG_HOME="${WORKSPACE}" \ - "${DOCKER_IMAGE}" /bin/bash -c ' - set -e - export TVM_ROOT=${TILELANG_HOME}/3rdparty/tvm - export PYTHONPATH=${TILELANG_HOME}:${TVM_ROOT}/python:${PYTHONPATH} - export USE_MACA=ON - export LD_LIBRARY_PATH=/opt/maca/ompi/lib:/opt/maca/mxgpu_llvm/lib:/opt/maca/lib:$LD_LIBRARY_PATH - - # 容器内环境初始化 - sed -i "s@http.*com/ubuntu@http://repo.metax-tech.com/r/ubuntu@g" /etc/apt/sources.list - apt-get update && apt-get install -y git cmake - - pip3 config set global.index-url https://repo.metax-tech.com/r/pypi/simple - pip3 config set install.trusted-host repo.metax-tech.com - pip install pytest-csv cython z3-solver==4.13.0 psutil cloudpickle torch-c-dlpack-ext - - # 编译 - git config --global --add safe.directory ${TILELANG_HOME} - mkdir -p build - cmake -B build -DUSE_MACA=ON - make -C build -j$(nproc) - - # 安装 ffi 并运行测试 - cd 3rdparty/tvm/3rdparty/tvm-ffi && pip install . - cd ${TILELANG_HOME} - python3 examples/quickstart.py - pytest --junitxml=report.xml testing/python/analysis/test_tilelang_nested_loop_checker.py - ' + "${DOCKER_IMAGE}" /bin/bash docker_internal_script.sh ''' } - post { - always { - junit 'report.xml' - } - } - } } // 4. 后置处理逻辑(无论成功失败都会触发) -- Gitee From f2af25b9ecc2c3d5f6065f0e5ae9e18cd2446a57 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Wed, 11 Mar 2026 15:11:32 +0800 Subject: [PATCH 27/94] 8 --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 2782d8a4..24bdd4c2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -161,6 +161,7 @@ EOF "${DOCKER_IMAGE}" /bin/bash docker_internal_script.sh ''' } + } } // 4. 后置处理逻辑(无论成功失败都会触发) -- Gitee From 4b6db0d28040febdf75cb0f8163cb17e6e1653ce Mon Sep 17 00:00:00 2001 From: artlesbol Date: Wed, 11 Mar 2026 15:14:28 +0800 Subject: [PATCH 28/94] 9 --- Jenkinsfile | 35 ++--------------------------------- ci/build_and_test.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 33 deletions(-) create mode 100644 ci/build_and_test.sh diff --git a/Jenkinsfile b/Jenkinsfile index 24bdd4c2..9cff27b5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -118,38 +118,8 @@ pipeline { steps { sh ''' echo "--- [DOCKER] 在 gpu_node1 上启动容器 ---" + chmod +x ci/build_and_test.sh - # 1. 先定义好脚本内容,避免在 docker run 命令行里嵌套太深 - # 注意:内部使用 \$ 来防止 Jenkins 提前解析容器内的变量 - cat << 'EOF' > docker_internal_script.sh -set -e -export TVM_ROOT=${TILELANG_HOME}/3rdparty/tvm -export PYTHONPATH=${TILELANG_HOME}:${TVM_ROOT}/python:${PYTHONPATH} -export USE_MACA=ON -export LD_LIBRARY_PATH=/opt/maca/ompi/lib:/opt/maca/mxgpu_llvm/lib:/opt/maca/lib:$LD_LIBRARY_PATH - -# 容器内环境初始化 -sed -i "s@http.*com/ubuntu@http://repo.metax-tech.com/r/ubuntu@g" /etc/apt/sources.list -apt-get update && apt-get install -y git cmake - -pip3 config set global.index-url https://repo.metax-tech.com/r/pypi/simple -pip3 config set install.trusted-host repo.metax-tech.com -pip install pytest-csv cython z3-solver==4.13.0 psutil cloudpickle torch-c-dlpack-ext - -# 编译 -git config --global --add safe.directory ${TILELANG_HOME} -mkdir -p build -cmake -B build -DUSE_MACA=ON -make -C build -j$(nproc) - -# 安装 ffi 并运行测试 -cd 3rdparty/tvm/3rdparty/tvm-ffi && pip install . -cd ${TILELANG_HOME} -python3 examples/quickstart.py -pytest --junitxml=report.xml testing/python/analysis/test_tilelang_nested_loop_checker.py -EOF - - # 2. 执行 Docker,直接运行脚本文件 docker run --rm \ --net=host \ --device=/dev/dri:/dev/dri \ @@ -157,8 +127,7 @@ EOF --group-add video \ -v "${WORKSPACE}:${WORKSPACE}" \ -w "${WORKSPACE}" \ - -e TILELANG_HOME="${WORKSPACE}" \ - "${DOCKER_IMAGE}" /bin/bash docker_internal_script.sh + "${DOCKER_IMAGE}" /bin/bash ./ci/build_and_test.sh ''' } } diff --git a/ci/build_and_test.sh b/ci/build_and_test.sh new file mode 100644 index 00000000..705d67e8 --- /dev/null +++ b/ci/build_and_test.sh @@ -0,0 +1,27 @@ +#!/bin/bash +set -e +export TILELANG_HOME=$(pwd) +export TVM_ROOT=${TILELANG_HOME}/3rdparty/tvm +export PYTHONPATH=${TILELANG_HOME}:${TVM_ROOT}/python:${PYTHONPATH} +export USE_MACA=ON +export LD_LIBRARY_PATH=/opt/maca/ompi/lib:/opt/maca/mxgpu_llvm/lib:/opt/maca/lib:$LD_LIBRARY_PATH + +# 容器内环境初始化 +sed -i "s@http.*com/ubuntu@http://repo.metax-tech.com/r/ubuntu@g" /etc/apt/sources.list +apt-get update && apt-get install -y git cmake + +pip3 config set global.index-url https://repo.metax-tech.com/r/pypi/simple +pip3 config set install.trusted-host repo.metax-tech.com +pip install pytest-csv cython z3-solver==4.13.0 psutil cloudpickle torch-c-dlpack-ext + +# 编译 +git config --global --add safe.directory ${TILELANG_HOME} +mkdir -p build +cmake -B build -DUSE_MACA=ON +make -C build -j$(nproc) + +# 安装 ffi 并运行测试 +cd 3rdparty/tvm/3rdparty/tvm-ffi && pip install . +cd ${TILELANG_HOME} +python3 examples/quickstart.py +pytest --junitxml=report.xml testing/python/analysis/test_tilelang_nested_loop_checker.py \ No newline at end of file -- Gitee From c437d19a71f8f81ca6832e67438ece7da88d45a5 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Wed, 11 Mar 2026 15:17:36 +0800 Subject: [PATCH 29/94] 9 --- ci/build_and_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) mode change 100644 => 100755 ci/build_and_test.sh diff --git a/ci/build_and_test.sh b/ci/build_and_test.sh old mode 100644 new mode 100755 index 705d67e8..ae6ae81a --- a/ci/build_and_test.sh +++ b/ci/build_and_test.sh @@ -24,4 +24,4 @@ make -C build -j$(nproc) cd 3rdparty/tvm/3rdparty/tvm-ffi && pip install . cd ${TILELANG_HOME} python3 examples/quickstart.py -pytest --junitxml=report.xml testing/python/analysis/test_tilelang_nested_loop_checker.py \ No newline at end of file +pytest --junitxml=report.xml testing/python/analysis/test_tilelang_nested_loop_checker.py -- Gitee From 558f96dc82aba71a2a492d54406f50faef0501e8 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Wed, 11 Mar 2026 15:30:54 +0800 Subject: [PATCH 30/94] 9 --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 9cff27b5..5b82a453 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -119,6 +119,7 @@ pipeline { sh ''' echo "--- [DOCKER] 在 gpu_node1 上启动容器 ---" chmod +x ci/build_and_test.sh + docker run --help docker run --rm \ --net=host \ -- Gitee From 5d8053754dac57de208cb3bcf2f444f338e1e906 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Thu, 12 Mar 2026 10:18:06 +0800 Subject: [PATCH 31/94] 10 --- Jenkinsfile | 157 +++++++++++++++++++++++----------------------------- 1 file changed, 69 insertions(+), 88 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5b82a453..a1f1e3b7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,117 +2,97 @@ pipeline { // 1. 指定机器 agent { label 'gpu_node1' } - // 2. 全局环境变量定义 environment { - // Python 环境变量(对应 CI 全局 env) PYTHONDEVMODE = "1" PYTHONUNBUFFERED = "1" - PYTHONPATH = "" // 显式清空,避免污染 - PIP_USER = "" // 显式清空 + PYTHONPATH = "" + PIP_USER = "" COLUMNS = "100" FORCE_COLOR = "1" CLICOLOR_FORCE = "1" - - // uv 配置 UV_INDEX_STRATEGY = "unsafe-best-match" UV_HTTP_TIMEOUT = "600" - - // 缓存目录(对应 CI 中 self-hosted runner 使用 tool_cache) XDG_CACHE_HOME = "${WORKSPACE}/.cache" PIP_CACHE_DIR = "${WORKSPACE}/.cache/pip" UV_CACHE_DIR = "${WORKSPACE}/.cache/uv" PRE_COMMIT_HOME = "${WORKSPACE}/.cache/pip/.pre-commit" - - // uv 可执行路径(安装后由 Setup 阶段写入) UV_BIN = "${HOME}/.local/bin/uv" - - // Python 3.9 解释器路径(由 Setup 阶段写入,Lint 阶段使用) PY39 = "" - - // clang-tidy cmake 选项 + PYTHON_VERSIONS = "3.12" CLANG_TIDY_CMAKE_OPTIONS = "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" - - DOCKER_IMAGE = "cr.metax-tech.com/public-library/maca-pytorch:3.6.0.10-torch2.6-py310-ubuntu24.04-amd64" } // 3. 构建生命周期 stages { - stage('Setup Python & Dependencies') { - steps { - echo "--- [SETUP] 安装 Python 依赖(对应 CI: Setup venv) ---" - - // ── Step 1: 安装 / 升级 uv(对应 CI: astral-sh/setup-uv) ────────────── - sh ''' - set -euo pipefail - echo "==> [1/6] 安装 uv" - if ! command -v uv &>/dev/null; then - pip install --user -U uv -i https://pypi.tuna.tsinghua.edu.cn/simple - fi - export PATH="${HOME}/.local/bin:${PATH}" - uv --version - ''' - - // ── Step 2: 安装 Python 3.9(用于 Lint 阶段 AST 兼容性检查) ─────────── - sh ''' - set -euo pipefail - export PATH="${HOME}/.local/bin:${PATH}" - echo "==> [2/6] 安装 Python 3.9(AST 兼容性检查用)" - uv python install 3.9 - PY39_PATH="$(uv python find 3.9)" - echo "Python 3.9 路径: ${PY39_PATH}" - "${PY39_PATH}" --version - # 将路径写入 Jenkins 环境,供后续 stage 使用 - echo "PY39=${PY39_PATH}" >> "${WORKSPACE}/.env_vars" - ''' - - // ── Step 3: 安装主工作 Python 3.12 并创建虚拟环境 ───────────────────── - sh ''' - set -euo pipefail - export PATH="${HOME}/.local/bin:${PATH}" - echo "==> [3/6] 安装 Python 3.12 并创建 venv" - uv python install 3.12 - rm -rf .venv - uv venv --python 3.12 .venv - uv pip install --python .venv/bin/python -r requirements-lint.txt - uv pip install --python .venv/bin/python pipx - .venv/bin/python --version - ''' + stage('Quick Lint') { + stages { + stage('Setup Python 3.9') { + steps { + sh ''' + set -euo pipefail + export PATH="${HOME}/.local/bin:${PATH}" + uv python install 3.9 + PY39_PATH="$(uv python find 3.9)" + echo "Python 3.9 path: ${PY39_PATH}" + "${PY39_PATH}" --version + echo "PY39=${PY39_PATH}" >> "${WORKSPACE}/.env_vars" + if ! command -v uv &>/dev/null; then + pip install --user -U uv -i https://pypi.tuna.tsinghua.edu.cn/simple + fi + export PATH="${HOME}/.local/bin:${PATH}" + uv --version + uv pip install --python .venv/bin/python -r requirements-lint.txt + uv pip install --python .venv/bin/python pipx + ''' + } + post { + failure { + sh ''' + export PATH="${HOME}/.local/bin:${PATH}" + echo "==> [CLEANUP] Setup 失败,清理 uv 缓存: ${UV_CACHE_DIR}" + uv cache clean || true + ''' + } + } + } + stage('Check AST with Python 3.9') { + steps { + sh ''' + [ -f "${WORKSPACE}/.env_vars" ] && export $(grep -v '^#' "${WORKSPACE}/.env_vars" | xargs) + echo "Using Python interpreter: ${PY39}" + "${PY39}" --version + "${PY39}" -m compileall -q -f tilelang + ''' + } + } + stage('Pre-commit Lint') { + steps { + sh ''' + export PATH="${WORKSPACE}/.venv/bin:${HOME}/.local/bin:${PATH}" + if ! pipx run pre-commit run --all-files --color=always --show-diff-on-failure; then + echo "Pre-commit checks failed. Please run 'pre-commit run --all-files' locally to see the issues." + exit 1 + fi + ''' + } + } } - post { - failure { - // 失败时清理 uv 缓存,避免脏缓存影响下次构建(对应 CI: Clear uv cache if setup failed) + } + stage("Test for Python ${PYTHON_VERSIONS} with Metax") { + stage("Setup Python ${PYTHON_VERSIONS}") { + steps { sh ''' + set -euo pipefail export PATH="${HOME}/.local/bin:${PATH}" - echo "==> [CLEANUP] Setup 失败,清理 uv 缓存: ${UV_CACHE_DIR}" - uv cache clean || true + uv python install ${PYTHON_VERSIONS} + rm -rf .venv + uv venv --python ${PYTHON_VERSIONS} .venv + .venv/bin/python --version ''' } } - } - - stage('Lint & Static Check') { - steps { - echo "--- [LINT] 正在进行静态代码检查 ---" - // Step 1: 用 Python 3.9 检查 tilelang 包的 AST 语法兼容性(对应 CI 中 "Check AST with Python 3.9") - sh ''' - [ -f "${WORKSPACE}/.env_vars" ] && export $(grep -v '^#' "${WORKSPACE}/.env_vars" | xargs) - echo "Using Python interpreter: ${PY39}" - "${PY39}" --version - "${PY39}" -m compileall -q -f tilelang - ''' - - // Step 2: 运行 pre-commit 对全部文件执行 lint(对应 CI 中 "Pre-commit Lint") - sh ''' - export PATH="${WORKSPACE}/.venv/bin:${HOME}/.local/bin:${PATH}" - if ! pipx run pre-commit run --all-files --color=always --show-diff-on-failure; then - echo "Pre-commit checks failed. Please run 'pre-commit run --all-files' locally to see the issues." - exit 1 - fi - ''' - } - } stage('Build & Test') { steps { @@ -137,10 +117,11 @@ pipeline { // 4. 后置处理逻辑(无论成功失败都会触发) post { always { - echo "--- [CLEANUP] 正在清理工作区与 GPU 状态 ---" - echo "操作: 收集 reports/*.xml 到 Jenkins 仪表盘" - echo "操作: 检查是否存在 core.* 文件并归档" - echo "操作: 执行 cleanWs() 清理磁盘" + echo "--- [CLEANUP] 无论成功失败,清理 uv 缓存: ${UV_CACHE_DIR} ---" + sh ''' + export PATH="${HOME}/.local/bin:${PATH}" + uv cache clean || true + ''' } success { -- Gitee From d8e9b12b72052e8ed38cc1daec51c0b8cdb09d55 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Thu, 12 Mar 2026 10:20:57 +0800 Subject: [PATCH 32/94] 10 --- Jenkinsfile | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a1f1e3b7..2bdedc9c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,7 +23,6 @@ pipeline { DOCKER_IMAGE = "cr.metax-tech.com/public-library/maca-pytorch:3.6.0.10-torch2.6-py310-ubuntu24.04-amd64" } - // 3. 构建生命周期 stages { stage('Quick Lint') { stages { @@ -92,29 +91,26 @@ pipeline { ''' } } + stage('Build & Test') { + steps { + sh ''' + echo "--- [DOCKER] 在 gpu_node1 上启动容器 ---" + chmod +x ci/build_and_test.sh + docker run --help - - stage('Build & Test') { - steps { - sh ''' - echo "--- [DOCKER] 在 gpu_node1 上启动容器 ---" - chmod +x ci/build_and_test.sh - docker run --help - - docker run --rm \ - --net=host \ - --device=/dev/dri:/dev/dri \ - --device=/dev/mxcd:/dev/mxcd \ - --group-add video \ - -v "${WORKSPACE}:${WORKSPACE}" \ - -w "${WORKSPACE}" \ - "${DOCKER_IMAGE}" /bin/bash ./ci/build_and_test.sh - ''' + docker run --rm \ + --net=host \ + --device=/dev/dri:/dev/dri \ + --device=/dev/mxcd:/dev/mxcd \ + --group-add video \ + -v "${WORKSPACE}:${WORKSPACE}" \ + -w "${WORKSPACE}" \ + "${DOCKER_IMAGE}" /bin/bash ./ci/build_and_test.sh + ''' + } } } } - - // 4. 后置处理逻辑(无论成功失败都会触发) post { always { echo "--- [CLEANUP] 无论成功失败,清理 uv 缓存: ${UV_CACHE_DIR} ---" -- Gitee From 3ef2f80631d15c8895c689af92baa3b27115b15d Mon Sep 17 00:00:00 2001 From: artlesbol Date: Thu, 12 Mar 2026 10:24:57 +0800 Subject: [PATCH 33/94] 10 --- Jenkinsfile | 56 +++++++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2bdedc9c..80ec5048 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -78,35 +78,37 @@ pipeline { } } } - stage("Test for Python ${PYTHON_VERSIONS} with Metax") { - stage("Setup Python ${PYTHON_VERSIONS}") { - steps { - sh ''' - set -euo pipefail - export PATH="${HOME}/.local/bin:${PATH}" - uv python install ${PYTHON_VERSIONS} - rm -rf .venv - uv venv --python ${PYTHON_VERSIONS} .venv - .venv/bin/python --version - ''' + stage("Test for Python 3.12 with Metax") { + stages { + stage("Setup Python 3.12") { + steps { + sh ''' + set -euo pipefail + export PATH="${HOME}/.local/bin:${PATH}" + uv python install ${PYTHON_VERSIONS} + rm -rf .venv + uv venv --python ${PYTHON_VERSIONS} .venv + .venv/bin/python --version + ''' + } } - } - stage('Build & Test') { - steps { - sh ''' - echo "--- [DOCKER] 在 gpu_node1 上启动容器 ---" - chmod +x ci/build_and_test.sh - docker run --help + stage('Run Metal tests with Python 3.12') { + steps { + sh ''' + echo "--- [DOCKER] 在 gpu_node1 上启动容器 ---" + chmod +x ci/build_and_test.sh + docker run --help - docker run --rm \ - --net=host \ - --device=/dev/dri:/dev/dri \ - --device=/dev/mxcd:/dev/mxcd \ - --group-add video \ - -v "${WORKSPACE}:${WORKSPACE}" \ - -w "${WORKSPACE}" \ - "${DOCKER_IMAGE}" /bin/bash ./ci/build_and_test.sh - ''' + docker run --rm \ + --net=host \ + --device=/dev/dri:/dev/dri \ + --device=/dev/mxcd:/dev/mxcd \ + --group-add video \ + -v "${WORKSPACE}:${WORKSPACE}" \ + -w "${WORKSPACE}" \ + "${DOCKER_IMAGE}" /bin/bash ./ci/build_and_test.sh + ''' + } } } } -- Gitee From cc144f2e579d300ea9524c7c2e2b8a8d791555cc Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 17 Mar 2026 14:32:05 +0800 Subject: [PATCH 34/94] =?UTF-8?q?=E5=AF=B9=E9=BD=90=E7=A4=BE=E5=8C=BAcuda?= =?UTF-8?q?=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 152 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 129 insertions(+), 23 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 80ec5048..e99eeff1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,8 +1,8 @@ pipeline { - // 1. 指定机器 agent { label 'gpu_node1' } environment { + CLANG_TIDY_CMAKE_OPTIONS = "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" PYTHONDEVMODE = "1" PYTHONUNBUFFERED = "1" PYTHONPATH = "" @@ -16,11 +16,9 @@ pipeline { PIP_CACHE_DIR = "${WORKSPACE}/.cache/pip" UV_CACHE_DIR = "${WORKSPACE}/.cache/uv" PRE_COMMIT_HOME = "${WORKSPACE}/.cache/pip/.pre-commit" - UV_BIN = "${HOME}/.local/bin/uv" + PY39 = "" PYTHON_VERSIONS = "3.12" - CLANG_TIDY_CMAKE_OPTIONS = "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" - DOCKER_IMAGE = "cr.metax-tech.com/public-library/maca-pytorch:3.6.0.10-torch2.6-py310-ubuntu24.04-amd64" } stages { @@ -80,36 +78,144 @@ pipeline { } stage("Test for Python 3.12 with Metax") { stages { - stage("Setup Python 3.12") { + stage('Set environment (self-hosted runners)') { steps { + withCredentials([string(credentialsId: 'SECRET_PATH_PREFIXES', variable: 'PATH_PREFIXES')]) { + if (PATH_PREFIXES) { + echo "Setting up masking for: ${PATH_PREFIXES}" + } + + env.XDG_CACHE_HOME = "${env.CACHE_ROOT}" + env.PIP_CACHE_DIR = "${env.XDG_CACHE_HOME}/pip" + env.UV_CACHE_DIR = "${env.XDG_CACHE_HOME}/uv" + env.PRE_COMMIT_HOME = "${env.XDG_CACHE_HOME}/pip/.pre-commit" + } sh ''' - set -euo pipefail - export PATH="${HOME}/.local/bin:${PATH}" - uv python install ${PYTHON_VERSIONS} - rm -rf .venv - uv venv --python ${PYTHON_VERSIONS} .venv - .venv/bin/python --version + echo "XDG_CACHE_HOME: $XDG_CACHE_HOME" + mkdir -p "$PIP_CACHE_DIR" "$UV_CACHE_DIR" "$PRE_COMMIT_HOME" + ''' + } + } + stage("Set environment Metax") { + steps { + // 这里需要配置实际的Metax环境变量 + sh ''' + echo "Set environment for Metax tests" + ''' + } + } + stage('Setup Python and uv with caching') { + steps { + sh ''' + if ! command -v uv &> /dev/null; then + echo "Installing uv..." + curl -LsSf https://astral.sh/uv/install.sh | sh + source $HOME/.cargo/env + fi + ''' + sh """ + export UV_CACHE_DIR="${env.UV_CACHE_DIR}" + mkdir -p "${env.UV_CACHE_DIR}" + uv python install ${env.PYTHON_VERSION} + uv venv --python ${env.PYTHON_VERSION} + echo "Python and UV ready." + """ + } + } + stage('Setup venv') { + steps { + // 这里可以添加安装项目依赖的步骤,使用requirements-metax.txt + // 这里社区给出的是各个平台有自己的PIP_EXTRA_INDEX_URL,作为UV_INDEX + sh ''' + echo "Setting up virtual environment and installing dependencies..." + ''' + } + } + stage('Install project (wheel form)') { + steps { + sh ''' + uv pip install -v . ''' } } - stage('Run Metal tests with Python 3.12') { + stage('Run clang-tidy') { steps { sh ''' - echo "--- [DOCKER] 在 gpu_node1 上启动容器 ---" - chmod +x ci/build_and_test.sh - docker run --help + echo "\$ $(command -v clang-tidy) --version" && clang-tidy --version + + # Download run-clang-tidy script + RCT_URL=https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/release/21.x/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py + echo "Downloading run-clang-tidy script from ${RCT_URL}" + echo "import urllib.request; url = '${RCT_URL}'.rstrip('/'); urllib.request.urlretrieve(url, url.split('/')[-1])" | uv run --no-project --script - + RUN_CLANG_TIDY=(uv run --no-project --script -- run-clang-tidy.py) + + if [[ -x "$(command -v clang-apply-replacements)" ]]; then + echo "Using clang-apply-replacements from $(command -v clang-apply-replacements)" + RUN_CLANG_TIDY+=(-fix -clang-apply-replacements-binary="$(command -v clang-apply-replacements)") + else + echo "::warning::clang-apply-replacements not found in PATH, automatic fixing disabled." + fi + + # Run cmake to create the build directory with compile_commands.json + cmake -S . -B cmake-build --fresh ${CLANG_TIDY_CMAKE_OPTIONS} # no quotes here + echo "::group::compile_commands.json" + ls -alh cmake-build/compile_commands.json + uv run --no-project -m -- json.tool --no-ensure-ascii cmake-build/compile_commands.json + echo "::endgroup::" - docker run --rm \ - --net=host \ - --device=/dev/dri:/dev/dri \ - --device=/dev/mxcd:/dev/mxcd \ - --group-add video \ - -v "${WORKSPACE}:${WORKSPACE}" \ - -w "${WORKSPACE}" \ - "${DOCKER_IMAGE}" /bin/bash ./ci/build_and_test.sh + CXX_FILES=$(find src -type f -iname "*.[ch]pp" -o -iname "*.cc" -o -iname "*.c" -o -iname "*.h") + rc=0 + echo "::group::run-clang-tidy" + "${RUN_CLANG_TIDY[@]}" -clang-tidy-binary="$(command -v clang-tidy)" \ + -exclude-header-filter='^(3rdparty|tvm)/.*$' \ + -p="cmake-build" ${CXX_FILES} || rc="$?" + echo "::endgroup::" + rm -rf cmake-build run-clang-tidy.py + if (( rc != 0 )); then + echo "::error::clang-tidy found issues (exit code: ${rc}). Please run 'clang-tidy --fix' locally to fix them." + git diff --color=always || true + exit "${rc}" + fi + ''' + } + } + stage('Run Metax tests with Python') { + steps { + sh ''' + cd testing + PYTEST=( + uv run --no-project -m -- + pytest --verbose --color=yes --durations=0 --showlocals --cache-clear + ) + "${PYTEST[@]}" --maxfail=3 --numprocesses=4 \ + -k metax \ + ./python ''' } } + stage('List generated files') { + steps { + sh ''' + find . -type f -name '*.py[co]' -delete + find . -depth -type d -name "__pycache__" -exec rm -r "{}" + + if git status --ignored --porcelain | grep -qvE '/$'; then + ls -alh $(git status --ignored --porcelain | grep -vE '/$' | grep -oE '\S+$') + fi + ''' + } + } + } + post { + failure { + stage('Clear uv cache for self-hosted runners (if setup failed)') { + steps { + sh ''' + echo "Clearing uv cache at ${UV_CACHE_DIR} due to failure." + uv cache clean + ''' + } + } + } } } } -- Gitee From a01d7dc527d2e418d42fbcf1259db8b171a11d07 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 17 Mar 2026 15:35:09 +0800 Subject: [PATCH 35/94] 11 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e99eeff1..92017f50 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -199,7 +199,7 @@ pipeline { find . -type f -name '*.py[co]' -delete find . -depth -type d -name "__pycache__" -exec rm -r "{}" + if git status --ignored --porcelain | grep -qvE '/$'; then - ls -alh $(git status --ignored --porcelain | grep -vE '/$' | grep -oE '\S+$') + ls -alh $(git status --ignored --porcelain | grep -vE '/$' | grep -oE '\\S+$') fi ''' } -- Gitee From d6eebeb5ba752fa1d387a688c9fd7fd8119d20f5 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 17 Mar 2026 15:37:21 +0800 Subject: [PATCH 36/94] 11 --- Jenkinsfile | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 92017f50..f2ee5611 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -80,20 +80,22 @@ pipeline { stages { stage('Set environment (self-hosted runners)') { steps { - withCredentials([string(credentialsId: 'SECRET_PATH_PREFIXES', variable: 'PATH_PREFIXES')]) { - if (PATH_PREFIXES) { - echo "Setting up masking for: ${PATH_PREFIXES}" - } + script { + withCredentials([string(credentialsId: 'SECRET_PATH_PREFIXES', variable: 'PATH_PREFIXES')]) { + if (PATH_PREFIXES) { + echo "Setting up masking for: ${PATH_PREFIXES}" + } - env.XDG_CACHE_HOME = "${env.CACHE_ROOT}" - env.PIP_CACHE_DIR = "${env.XDG_CACHE_HOME}/pip" - env.UV_CACHE_DIR = "${env.XDG_CACHE_HOME}/uv" - env.PRE_COMMIT_HOME = "${env.XDG_CACHE_HOME}/pip/.pre-commit" + env.XDG_CACHE_HOME = "${env.CACHE_ROOT}" + env.PIP_CACHE_DIR = "${env.XDG_CACHE_HOME}/pip" + env.UV_CACHE_DIR = "${env.XDG_CACHE_HOME}/uv" + env.PRE_COMMIT_HOME = "${env.XDG_CACHE_HOME}/pip/.pre-commit" + } + sh ''' + echo "XDG_CACHE_HOME: $XDG_CACHE_HOME" + mkdir -p "$PIP_CACHE_DIR" "$UV_CACHE_DIR" "$PRE_COMMIT_HOME" + ''' } - sh ''' - echo "XDG_CACHE_HOME: $XDG_CACHE_HOME" - mkdir -p "$PIP_CACHE_DIR" "$UV_CACHE_DIR" "$PRE_COMMIT_HOME" - ''' } } stage("Set environment Metax") { -- Gitee From 8d879820d02d079d05b9a00a599a7f3d8e8fa041 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 17 Mar 2026 15:39:42 +0800 Subject: [PATCH 37/94] 11 --- Jenkinsfile | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f2ee5611..7b8aaaf9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -209,14 +209,10 @@ pipeline { } post { failure { - stage('Clear uv cache for self-hosted runners (if setup failed)') { - steps { - sh ''' - echo "Clearing uv cache at ${UV_CACHE_DIR} due to failure." - uv cache clean - ''' - } - } + sh ''' + echo "Clearing uv cache at ${UV_CACHE_DIR} due to failure." + uv cache clean + ''' } } } -- Gitee From f540d55d34d10a34a3d2aee246b43a9089d64e9c Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 17 Mar 2026 15:43:03 +0800 Subject: [PATCH 38/94] 11 --- Jenkinsfile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7b8aaaf9..8365e538 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -45,11 +45,12 @@ pipeline { } post { failure { - sh ''' - export PATH="${HOME}/.local/bin:${PATH}" - echo "==> [CLEANUP] Setup 失败,清理 uv 缓存: ${UV_CACHE_DIR}" + sh """ + export PATH="\${HOME}/.local/bin:\${PATH}" + echo "PATH: \${PATH}" + echo "==> [CLEANUP] Setup 失败,清理 uv 缓存: ${env.UV_CACHE_DIR}" uv cache clean || true - ''' + """ } } } -- Gitee From c9c040cc95018ba73880d1a67fbd234baf04d8be Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 17 Mar 2026 15:47:49 +0800 Subject: [PATCH 39/94] 12 --- Jenkinsfile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8365e538..72e8d71c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -29,18 +29,17 @@ pipeline { sh ''' set -euo pipefail export PATH="${HOME}/.local/bin:${PATH}" + if ! command -v uv &>/dev/null; then + pip install --user -U uv -i https://pypi.tuna.tsinghua.edu.cn/simple + fi uv python install 3.9 PY39_PATH="$(uv python find 3.9)" echo "Python 3.9 path: ${PY39_PATH}" "${PY39_PATH}" --version echo "PY39=${PY39_PATH}" >> "${WORKSPACE}/.env_vars" - if ! command -v uv &>/dev/null; then - pip install --user -U uv -i https://pypi.tuna.tsinghua.edu.cn/simple - fi - export PATH="${HOME}/.local/bin:${PATH}" uv --version - uv pip install --python .venv/bin/python -r requirements-lint.txt - uv pip install --python .venv/bin/python pipx + uv pip install -r requirements-lint.txt + uv pip install pipx ''' } post { -- Gitee From 99746bde1e36bc215ac0dd7df1c40f8e5c1c96ef Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 17 Mar 2026 16:01:58 +0800 Subject: [PATCH 40/94] 13 --- Jenkinsfile | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 72e8d71c..b374c804 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -22,36 +22,38 @@ pipeline { } stages { + stage('Prepare UV Environments') { + steps { + script { + sh ''' + export PATH="${HOME}/.local/bin:${PATH}" + if ! command -v uv &>/dev/null; then + pip install --user -U uv -i https://pypi.tuna.tsinghua.edu.cn/simple + fi + ''' + def pytestVersion = env.PYTHON_VERSIONS.split(',')[0].trim() + sh "uv venv .venv_lint --python 3.9 --allow-existing" + sh "uv venv .venv_test --python ${pytestVersion} --allow-existing" + echo "Environments prepared: Lint (3.9), Test (${pytestVersion})" + } + } + } stage('Quick Lint') { + environment { + VIRTUAL_ENV = "${WORKSPACE}/.venv_lint" + PATH = "${WORKSPACE}/.venv_lint/bin:${env.PATH}" + } stages { stage('Setup Python 3.9') { steps { sh ''' set -euo pipefail - export PATH="${HOME}/.local/bin:${PATH}" - if ! command -v uv &>/dev/null; then - pip install --user -U uv -i https://pypi.tuna.tsinghua.edu.cn/simple - fi - uv python install 3.9 - PY39_PATH="$(uv python find 3.9)" - echo "Python 3.9 path: ${PY39_PATH}" - "${PY39_PATH}" --version - echo "PY39=${PY39_PATH}" >> "${WORKSPACE}/.env_vars" - uv --version + python --version + which python uv pip install -r requirements-lint.txt uv pip install pipx ''' } - post { - failure { - sh """ - export PATH="\${HOME}/.local/bin:\${PATH}" - echo "PATH: \${PATH}" - echo "==> [CLEANUP] Setup 失败,清理 uv 缓存: ${env.UV_CACHE_DIR}" - uv cache clean || true - """ - } - } } stage('Check AST with Python 3.9') { steps { @@ -75,6 +77,14 @@ pipeline { } } } + post { + failure { + sh ''' + echo "Clearing uv cache at ${UV_CACHE_DIR} due to failure." + uv cache clean + ''' + } + } } stage("Test for Python 3.12 with Metax") { stages { -- Gitee From e8e626b54b90aa5b2fdb7fd241765f435af5354c Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 17 Mar 2026 16:08:58 +0800 Subject: [PATCH 41/94] 14 --- Jenkinsfile | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b374c804..7f2b3a9d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,23 +25,22 @@ pipeline { stage('Prepare UV Environments') { steps { script { + def pytestVersion = env.PYTHON_VERSIONS.split(',')[0].trim() sh ''' export PATH="${HOME}/.local/bin:${PATH}" if ! command -v uv &>/dev/null; then pip install --user -U uv -i https://pypi.tuna.tsinghua.edu.cn/simple fi + uv venv .venv_lint --python 3.9 --allow-existing + uv venv .venv_test --python ${pytestVersion} --allow-existing ''' - def pytestVersion = env.PYTHON_VERSIONS.split(',')[0].trim() - sh "uv venv .venv_lint --python 3.9 --allow-existing" - sh "uv venv .venv_test --python ${pytestVersion} --allow-existing" - echo "Environments prepared: Lint (3.9), Test (${pytestVersion})" } } } stage('Quick Lint') { environment { VIRTUAL_ENV = "${WORKSPACE}/.venv_lint" - PATH = "${WORKSPACE}/.venv_lint/bin:${env.PATH}" + PATH = "${WORKSPACE}/.venv_lint/bin:${HOME}/.local/bin:${env.PATH}" } stages { stage('Setup Python 3.9') { @@ -87,6 +86,10 @@ pipeline { } } stage("Test for Python 3.12 with Metax") { + environment { + VIRTUAL_ENV = "${WORKSPACE}/.venv_pytest" + PATH = "${WORKSPACE}/.venv_pytest/bin:${HOME}/.local/bin:${env.PATH}" + } stages { stage('Set environment (self-hosted runners)') { steps { -- Gitee From 429e8c09348893dbb76c5588da8eb5cc5f8ba1f6 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 17 Mar 2026 16:12:46 +0800 Subject: [PATCH 42/94] 15 --- Jenkinsfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7f2b3a9d..6d08e253 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,7 +17,6 @@ pipeline { UV_CACHE_DIR = "${WORKSPACE}/.cache/uv" PRE_COMMIT_HOME = "${WORKSPACE}/.cache/pip/.pre-commit" - PY39 = "" PYTHON_VERSIONS = "3.12" } @@ -26,14 +25,15 @@ pipeline { steps { script { def pytestVersion = env.PYTHON_VERSIONS.split(',')[0].trim() - sh ''' - export PATH="${HOME}/.local/bin:${PATH}" + sh """ + set -euo pipefail + export PATH="\${HOME}/.local/bin:\$PATH" if ! command -v uv &>/dev/null; then pip install --user -U uv -i https://pypi.tuna.tsinghua.edu.cn/simple fi uv venv .venv_lint --python 3.9 --allow-existing uv venv .venv_test --python ${pytestVersion} --allow-existing - ''' + """ } } } -- Gitee From 79a82a4cc4cd44c3bb82ff8d08e5d73003b17e86 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 17 Mar 2026 17:22:41 +0800 Subject: [PATCH 43/94] 16 --- Jenkinsfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6d08e253..6bb67f2b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -57,10 +57,8 @@ pipeline { stage('Check AST with Python 3.9') { steps { sh ''' - [ -f "${WORKSPACE}/.env_vars" ] && export $(grep -v '^#' "${WORKSPACE}/.env_vars" | xargs) - echo "Using Python interpreter: ${PY39}" - "${PY39}" --version - "${PY39}" -m compileall -q -f tilelang + python --version + python -m compileall -q -f tilelang ''' } } -- Gitee From 4512d0c1b5a0b42bd7e9901331e5204764e773ba Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 17 Mar 2026 17:31:03 +0800 Subject: [PATCH 44/94] 17 --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 6bb67f2b..d2a72090 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -47,6 +47,7 @@ pipeline { steps { sh ''' set -euo pipefail + pre-commit clean python --version which python uv pip install -r requirements-lint.txt -- Gitee From 1f1de7ef5084c3fedee247cdc24f0ef5624b38b9 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Thu, 19 Mar 2026 14:15:53 +0800 Subject: [PATCH 45/94] 18 --- Jenkinsfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d2a72090..e3c546fc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -47,9 +47,6 @@ pipeline { steps { sh ''' set -euo pipefail - pre-commit clean - python --version - which python uv pip install -r requirements-lint.txt uv pip install pipx ''' -- Gitee From 9a07655c59031351bc6429f3a2b0c7e39df1b04a Mon Sep 17 00:00:00 2001 From: artlesbol Date: Thu, 19 Mar 2026 14:20:59 +0800 Subject: [PATCH 46/94] 19 --- Jenkinsfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e3c546fc..ba5359fc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -55,7 +55,6 @@ pipeline { stage('Check AST with Python 3.9') { steps { sh ''' - python --version python -m compileall -q -f tilelang ''' } @@ -63,7 +62,6 @@ pipeline { stage('Pre-commit Lint') { steps { sh ''' - export PATH="${WORKSPACE}/.venv/bin:${HOME}/.local/bin:${PATH}" if ! pipx run pre-commit run --all-files --color=always --show-diff-on-failure; then echo "Pre-commit checks failed. Please run 'pre-commit run --all-files' locally to see the issues." exit 1 -- Gitee From f56319a1d14943d1b91ccb900205e2eb3f5c7222 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Thu, 19 Mar 2026 14:28:24 +0800 Subject: [PATCH 47/94] 20 --- Jenkinsfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ba5359fc..a2409f3a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -17,7 +17,8 @@ pipeline { UV_CACHE_DIR = "${WORKSPACE}/.cache/uv" PRE_COMMIT_HOME = "${WORKSPACE}/.cache/pip/.pre-commit" - PYTHON_VERSIONS = "3.12" + LINT_PYTHON_VERSION = "3.10" + PYTEST_PYTHON_VERSIONS = "3.12" } stages { @@ -31,8 +32,8 @@ pipeline { if ! command -v uv &>/dev/null; then pip install --user -U uv -i https://pypi.tuna.tsinghua.edu.cn/simple fi - uv venv .venv_lint --python 3.9 --allow-existing - uv venv .venv_test --python ${pytestVersion} --allow-existing + uv venv .venv_lint --python ${env.LINT_PYTHON_VERSION} --allow-existing + uv venv .venv_test --python ${env.PYTEST_PYTHON_VERSIONS} --allow-existing """ } } @@ -43,7 +44,7 @@ pipeline { PATH = "${WORKSPACE}/.venv_lint/bin:${HOME}/.local/bin:${env.PATH}" } stages { - stage('Setup Python 3.9') { + stage('Setup Python') { steps { sh ''' set -euo pipefail @@ -52,7 +53,7 @@ pipeline { ''' } } - stage('Check AST with Python 3.9') { + stage('Check AST with Python') { steps { sh ''' python -m compileall -q -f tilelang -- Gitee From 0e92360419f68f1b0c567857a1339fce227f84ec Mon Sep 17 00:00:00 2001 From: artlesbol Date: Thu, 19 Mar 2026 14:32:07 +0800 Subject: [PATCH 48/94] 21 --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index a2409f3a..2383db9c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,7 +25,6 @@ pipeline { stage('Prepare UV Environments') { steps { script { - def pytestVersion = env.PYTHON_VERSIONS.split(',')[0].trim() sh """ set -euo pipefail export PATH="\${HOME}/.local/bin:\$PATH" -- Gitee From 0edadb6a251c9a47a3668ed6d8eba9190a9f414c Mon Sep 17 00:00:00 2001 From: artlesbol Date: Thu, 19 Mar 2026 14:58:27 +0800 Subject: [PATCH 49/94] 22 --- Jenkinsfile | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2383db9c..59851a89 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -88,20 +88,20 @@ pipeline { stage('Set environment (self-hosted runners)') { steps { script { + if (!env.CACHE_ROOT) { + error "环境错误:未定义 env.CACHE_ROOT 路径" + } withCredentials([string(credentialsId: 'SECRET_PATH_PREFIXES', variable: 'PATH_PREFIXES')]) { - if (PATH_PREFIXES) { - echo "Setting up masking for: ${PATH_PREFIXES}" - } - - env.XDG_CACHE_HOME = "${env.CACHE_ROOT}" + env.XDG_CACHE_HOME = "${env.CACHE_ROOT}/.ci-cache-${env.JOB_NAME}" env.PIP_CACHE_DIR = "${env.XDG_CACHE_HOME}/pip" env.UV_CACHE_DIR = "${env.XDG_CACHE_HOME}/uv" env.PRE_COMMIT_HOME = "${env.XDG_CACHE_HOME}/pip/.pre-commit" + sh """ + echo "Initializing cache directories..." + mkdir -p "\$PIP_CACHE_DIR" "\$UV_CACHE_DIR" "\$PRE_COMMIT_HOME" + echo "XDG_CACHE_HOME is set to: \$XDG_CACHE_HOME" + """ } - sh ''' - echo "XDG_CACHE_HOME: $XDG_CACHE_HOME" - mkdir -p "$PIP_CACHE_DIR" "$UV_CACHE_DIR" "$PRE_COMMIT_HOME" - ''' } } } -- Gitee From c6327cddce6196633c24a6748cd03ec197b0a155 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Thu, 19 Mar 2026 15:32:19 +0800 Subject: [PATCH 50/94] 23 --- Jenkinsfile | 58 +++++++++++++++++++------------------ requirements-test-metax.txt | 5 ++++ 2 files changed, 35 insertions(+), 28 deletions(-) create mode 100644 requirements-test-metax.txt diff --git a/Jenkinsfile b/Jenkinsfile index 59851a89..4375e5d6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -88,29 +88,21 @@ pipeline { stage('Set environment (self-hosted runners)') { steps { script { - if (!env.CACHE_ROOT) { - error "环境错误:未定义 env.CACHE_ROOT 路径" - } - withCredentials([string(credentialsId: 'SECRET_PATH_PREFIXES', variable: 'PATH_PREFIXES')]) { - env.XDG_CACHE_HOME = "${env.CACHE_ROOT}/.ci-cache-${env.JOB_NAME}" - env.PIP_CACHE_DIR = "${env.XDG_CACHE_HOME}/pip" - env.UV_CACHE_DIR = "${env.XDG_CACHE_HOME}/uv" - env.PRE_COMMIT_HOME = "${env.XDG_CACHE_HOME}/pip/.pre-commit" - sh """ - echo "Initializing cache directories..." - mkdir -p "\$PIP_CACHE_DIR" "\$UV_CACHE_DIR" "\$PRE_COMMIT_HOME" - echo "XDG_CACHE_HOME is set to: \$XDG_CACHE_HOME" - """ - } + // 对于只在Jenkins上跑的内网机器,不用重设cache } } } stage("Set environment Metax") { steps { - // 这里需要配置实际的Metax环境变量 - sh ''' - echo "Set environment for Metax tests" - ''' + script { + // Metax/MACA 环境变量配置 + env.TILELANG_HOME = "${WORKSPACE}" + env.TVM_ROOT = "${WORKSPACE}/3rdparty/tvm" + env.TVM_IMPORT_PYTHON_PATH = "${env.TVM_ROOT}/python" + env.PYTHONPATH = "${env.TILELANG_HOME}:${env.TVM_IMPORT_PYTHON_PATH}:${env.PYTHONPATH ?: ''}" + env.USE_MACA = "ON" + env.LD_LIBRARY_PATH = "/opt/maca/ompi/lib:/opt/maca/mxgpu_llvm/lib:/opt/maca/lib${env.LD_LIBRARY_PATH ? ':' + env.LD_LIBRARY_PATH : ''}" + } } } stage('Setup Python and uv with caching') { @@ -122,21 +114,31 @@ pipeline { source $HOME/.cargo/env fi ''' - sh """ - export UV_CACHE_DIR="${env.UV_CACHE_DIR}" - mkdir -p "${env.UV_CACHE_DIR}" - uv python install ${env.PYTHON_VERSION} - uv venv --python ${env.PYTHON_VERSION} - echo "Python and UV ready." - """ + env.UV_CACHE_DIR = "${WORKSPACE}/.cache/uv" } } stage('Setup venv') { steps { - // 这里可以添加安装项目依赖的步骤,使用requirements-metax.txt - // 这里社区给出的是各个平台有自己的PIP_EXTRA_INDEX_URL,作为UV_INDEX + script { + env.UV_INDEX = "http://mirrors.aliyun.com/pypi/simple" + } sh ''' - echo "Setting up virtual environment and installing dependencies..." + set -euo pipefail + uv pip install --upgrade pip setuptools wheel + if [[ -n "${UV_INDEX:-}" ]]; then + uv pip install --prerelease=allow -v torch --index-url "${UV_INDEX}" || \ + uv pip install -v torch + else + uv pip install -v torch + fi + echo "import torch; print(f'torch: {torch.__version__}')" | uv run --no-project --script - + uv pip install -v -r requirements-test.txt + if [[ -f requirements-test-metax.txt ]]; then + uv pip install -v -r requirements-test-metax.txt + fi + echo "::group::torch.utils.collect_env" + uv run --no-project -m -- torch.utils.collect_env || true + echo "::endgroup::" ''' } } diff --git a/requirements-test-metax.txt b/requirements-test-metax.txt new file mode 100644 index 00000000..f379d9ee --- /dev/null +++ b/requirements-test-metax.txt @@ -0,0 +1,5 @@ +# Lint requirements +--requirement requirements-lint.txt + +# Common test requirements +--requirement requirements-test.txt -- Gitee From bc2eff9d4526ebc13b67f47674f1266ce9b142c0 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Thu, 19 Mar 2026 15:34:45 +0800 Subject: [PATCH 51/94] 1 --- Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4375e5d6..64bd7782 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -114,7 +114,9 @@ pipeline { source $HOME/.cargo/env fi ''' - env.UV_CACHE_DIR = "${WORKSPACE}/.cache/uv" + script { + env.UV_CACHE_DIR = "${WORKSPACE}/.cache/uv" + } } } stage('Setup venv') { -- Gitee From 9abf11d3abf01e6c729c298100cd2b8a82b6b73b Mon Sep 17 00:00:00 2001 From: artlesbol Date: Thu, 19 Mar 2026 15:36:20 +0800 Subject: [PATCH 52/94] 24 --- Jenkinsfile | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 64bd7782..69848d87 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -107,13 +107,6 @@ pipeline { } stage('Setup Python and uv with caching') { steps { - sh ''' - if ! command -v uv &> /dev/null; then - echo "Installing uv..." - curl -LsSf https://astral.sh/uv/install.sh | sh - source $HOME/.cargo/env - fi - ''' script { env.UV_CACHE_DIR = "${WORKSPACE}/.cache/uv" } -- Gitee From 8df1c09433ee40977dbe5c4eb69518f66077db1e Mon Sep 17 00:00:00 2001 From: artlesbol Date: Thu, 19 Mar 2026 15:37:52 +0800 Subject: [PATCH 53/94] 25 --- Jenkinsfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 69848d87..dc3fd7aa 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -87,9 +87,7 @@ pipeline { stages { stage('Set environment (self-hosted runners)') { steps { - script { - // 对于只在Jenkins上跑的内网机器,不用重设cache - } + echo "Self-hosted runner, skipping cache reconfiguration" } } stage("Set environment Metax") { -- Gitee From 15619b75ef50f2b3eb19d215ee908cf196ab5f81 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Thu, 19 Mar 2026 15:40:48 +0800 Subject: [PATCH 54/94] 26 --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index dc3fd7aa..0c1c15b2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -81,8 +81,8 @@ pipeline { } stage("Test for Python 3.12 with Metax") { environment { - VIRTUAL_ENV = "${WORKSPACE}/.venv_pytest" - PATH = "${WORKSPACE}/.venv_pytest/bin:${HOME}/.local/bin:${env.PATH}" + VIRTUAL_ENV = "${WORKSPACE}/.venv_test" + PATH = "${WORKSPACE}/.venv_test/bin:${HOME}/.local/bin:${env.PATH}" } stages { stage('Set environment (self-hosted runners)') { -- Gitee From 1ece28d0a6296b54a2ca35b42a6c7b23685dd571 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Thu, 19 Mar 2026 15:44:41 +0800 Subject: [PATCH 55/94] 1 --- Jenkinsfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 0c1c15b2..957d2bfc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -112,9 +112,6 @@ pipeline { } stage('Setup venv') { steps { - script { - env.UV_INDEX = "http://mirrors.aliyun.com/pypi/simple" - } sh ''' set -euo pipefail uv pip install --upgrade pip setuptools wheel -- Gitee From d335547b1412fa35b5ba2717f22cb38429c539c4 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Fri, 20 Mar 2026 14:25:51 +0800 Subject: [PATCH 56/94] =?UTF-8?q?=E6=9A=82=E6=97=B6=E5=B1=8F=E8=94=BDclang?= =?UTF-8?q?-tidy=E7=9C=8B=E7=9C=8B=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 87 +++++++++++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 40 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 957d2bfc..34f7de5b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -112,8 +112,16 @@ pipeline { } stage('Setup venv') { steps { + script { + env.UV_INDEX = "https://repo.metax-tech.com/r/pypi/simple" + } sh ''' set -euo pipefail + + pip3 config set global.index https://repo.metax-tech.com/r/pypi/pypi + pip3 config set global.index-url https://repo.metax-tech.com/r/pypi/simple + pip3 config set install.trusted-host repo.metax-tech.com + uv pip install --upgrade pip setuptools wheel if [[ -n "${UV_INDEX:-}" ]]; then uv pip install --prerelease=allow -v torch --index-url "${UV_INDEX}" || \ @@ -139,47 +147,47 @@ pipeline { ''' } } - stage('Run clang-tidy') { - steps { - sh ''' - echo "\$ $(command -v clang-tidy) --version" && clang-tidy --version + // stage('Run clang-tidy') { + // steps { + // sh ''' + // echo "\$ $(command -v clang-tidy) --version" && clang-tidy --version - # Download run-clang-tidy script - RCT_URL=https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/release/21.x/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py - echo "Downloading run-clang-tidy script from ${RCT_URL}" - echo "import urllib.request; url = '${RCT_URL}'.rstrip('/'); urllib.request.urlretrieve(url, url.split('/')[-1])" | uv run --no-project --script - - RUN_CLANG_TIDY=(uv run --no-project --script -- run-clang-tidy.py) + // # Download run-clang-tidy script + // RCT_URL=https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/release/21.x/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py + // echo "Downloading run-clang-tidy script from ${RCT_URL}" + // echo "import urllib.request; url = '${RCT_URL}'.rstrip('/'); urllib.request.urlretrieve(url, url.split('/')[-1])" | uv run --no-project --script - + // RUN_CLANG_TIDY=(uv run --no-project --script -- run-clang-tidy.py) - if [[ -x "$(command -v clang-apply-replacements)" ]]; then - echo "Using clang-apply-replacements from $(command -v clang-apply-replacements)" - RUN_CLANG_TIDY+=(-fix -clang-apply-replacements-binary="$(command -v clang-apply-replacements)") - else - echo "::warning::clang-apply-replacements not found in PATH, automatic fixing disabled." - fi + // if [[ -x "$(command -v clang-apply-replacements)" ]]; then + // echo "Using clang-apply-replacements from $(command -v clang-apply-replacements)" + // RUN_CLANG_TIDY+=(-fix -clang-apply-replacements-binary="$(command -v clang-apply-replacements)") + // else + // echo "::warning::clang-apply-replacements not found in PATH, automatic fixing disabled." + // fi - # Run cmake to create the build directory with compile_commands.json - cmake -S . -B cmake-build --fresh ${CLANG_TIDY_CMAKE_OPTIONS} # no quotes here - echo "::group::compile_commands.json" - ls -alh cmake-build/compile_commands.json - uv run --no-project -m -- json.tool --no-ensure-ascii cmake-build/compile_commands.json - echo "::endgroup::" + // # Run cmake to create the build directory with compile_commands.json + // cmake -S . -B cmake-build --fresh ${CLANG_TIDY_CMAKE_OPTIONS} # no quotes here + // echo "::group::compile_commands.json" + // ls -alh cmake-build/compile_commands.json + // uv run --no-project -m -- json.tool --no-ensure-ascii cmake-build/compile_commands.json + // echo "::endgroup::" - CXX_FILES=$(find src -type f -iname "*.[ch]pp" -o -iname "*.cc" -o -iname "*.c" -o -iname "*.h") - rc=0 - echo "::group::run-clang-tidy" - "${RUN_CLANG_TIDY[@]}" -clang-tidy-binary="$(command -v clang-tidy)" \ - -exclude-header-filter='^(3rdparty|tvm)/.*$' \ - -p="cmake-build" ${CXX_FILES} || rc="$?" - echo "::endgroup::" - rm -rf cmake-build run-clang-tidy.py - if (( rc != 0 )); then - echo "::error::clang-tidy found issues (exit code: ${rc}). Please run 'clang-tidy --fix' locally to fix them." - git diff --color=always || true - exit "${rc}" - fi - ''' - } - } + // CXX_FILES=$(find src -type f -iname "*.[ch]pp" -o -iname "*.cc" -o -iname "*.c" -o -iname "*.h") + // rc=0 + // echo "::group::run-clang-tidy" + // "${RUN_CLANG_TIDY[@]}" -clang-tidy-binary="$(command -v clang-tidy)" \ + // -exclude-header-filter='^(3rdparty|tvm)/.*$' \ + // -p="cmake-build" ${CXX_FILES} || rc="$?" + // echo "::endgroup::" + // rm -rf cmake-build run-clang-tidy.py + // if (( rc != 0 )); then + // echo "::error::clang-tidy found issues (exit code: ${rc}). Please run 'clang-tidy --fix' locally to fix them." + // git diff --color=always || true + // exit "${rc}" + // fi + // ''' + // } + // } stage('Run Metax tests with Python') { steps { sh ''' @@ -218,10 +226,9 @@ pipeline { } post { always { - echo "--- [CLEANUP] 无论成功失败,清理 uv 缓存: ${UV_CACHE_DIR} ---" sh ''' - export PATH="${HOME}/.local/bin:${PATH}" - uv cache clean || true + # export PATH="${HOME}/.local/bin:${PATH}" + # uv cache clean || true ''' } -- Gitee From 928e1ca50c554594e0e43683a82791ed7f5b7dde Mon Sep 17 00:00:00 2001 From: artlesbol Date: Fri, 20 Mar 2026 14:31:54 +0800 Subject: [PATCH 57/94] 27 --- Jenkinsfile | 74 ++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 34f7de5b..f950724a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -147,47 +147,47 @@ pipeline { ''' } } - // stage('Run clang-tidy') { - // steps { - // sh ''' - // echo "\$ $(command -v clang-tidy) --version" && clang-tidy --version + stage('Run clang-tidy') { + steps { + sh ''' + echo "\$ $(command -v clang-tidy) --version" && clang-tidy --version - // # Download run-clang-tidy script - // RCT_URL=https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/release/21.x/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py - // echo "Downloading run-clang-tidy script from ${RCT_URL}" - // echo "import urllib.request; url = '${RCT_URL}'.rstrip('/'); urllib.request.urlretrieve(url, url.split('/')[-1])" | uv run --no-project --script - - // RUN_CLANG_TIDY=(uv run --no-project --script -- run-clang-tidy.py) + # Download run-clang-tidy script + RCT_URL=https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/release/21.x/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py + echo "Downloading run-clang-tidy script from ${RCT_URL}" + echo "import urllib.request; url = '${RCT_URL}'.rstrip('/'); urllib.request.urlretrieve(url, url.split('/')[-1])" | uv run --no-project --script - + RUN_CLANG_TIDY=(uv run --no-project --script -- run-clang-tidy.py) - // if [[ -x "$(command -v clang-apply-replacements)" ]]; then - // echo "Using clang-apply-replacements from $(command -v clang-apply-replacements)" - // RUN_CLANG_TIDY+=(-fix -clang-apply-replacements-binary="$(command -v clang-apply-replacements)") - // else - // echo "::warning::clang-apply-replacements not found in PATH, automatic fixing disabled." - // fi + if [[ -x "$(command -v clang-apply-replacements)" ]]; then + echo "Using clang-apply-replacements from $(command -v clang-apply-replacements)" + RUN_CLANG_TIDY+=(-fix -clang-apply-replacements-binary="$(command -v clang-apply-replacements)") + else + echo "::warning::clang-apply-replacements not found in PATH, automatic fixing disabled." + fi - // # Run cmake to create the build directory with compile_commands.json - // cmake -S . -B cmake-build --fresh ${CLANG_TIDY_CMAKE_OPTIONS} # no quotes here - // echo "::group::compile_commands.json" - // ls -alh cmake-build/compile_commands.json - // uv run --no-project -m -- json.tool --no-ensure-ascii cmake-build/compile_commands.json - // echo "::endgroup::" + # Run cmake to create the build directory with compile_commands.json + cmake -S . -B cmake-build --fresh ${CLANG_TIDY_CMAKE_OPTIONS} # no quotes here + echo "::group::compile_commands.json" + ls -alh cmake-build/compile_commands.json + uv run --no-project -m -- json.tool --no-ensure-ascii cmake-build/compile_commands.json + echo "::endgroup::" - // CXX_FILES=$(find src -type f -iname "*.[ch]pp" -o -iname "*.cc" -o -iname "*.c" -o -iname "*.h") - // rc=0 - // echo "::group::run-clang-tidy" - // "${RUN_CLANG_TIDY[@]}" -clang-tidy-binary="$(command -v clang-tidy)" \ - // -exclude-header-filter='^(3rdparty|tvm)/.*$' \ - // -p="cmake-build" ${CXX_FILES} || rc="$?" - // echo "::endgroup::" - // rm -rf cmake-build run-clang-tidy.py - // if (( rc != 0 )); then - // echo "::error::clang-tidy found issues (exit code: ${rc}). Please run 'clang-tidy --fix' locally to fix them." - // git diff --color=always || true - // exit "${rc}" - // fi - // ''' - // } - // } + CXX_FILES=$(find src -type f -iname "*.[ch]pp" -o -iname "*.cc" -o -iname "*.c" -o -iname "*.h") + rc=0 + echo "::group::run-clang-tidy" + "${RUN_CLANG_TIDY[@]}" -clang-tidy-binary="$(command -v clang-tidy)" \ + -exclude-header-filter='^(3rdparty|tvm)/.*$' \ + -p="cmake-build" ${CXX_FILES} || rc="$?" + echo "::endgroup::" + rm -rf cmake-build run-clang-tidy.py + if (( rc != 0 )); then + echo "::error::clang-tidy found issues (exit code: ${rc}). Please run 'clang-tidy --fix' locally to fix them." + git diff --color=always || true + exit "${rc}" + fi + ''' + } + } stage('Run Metax tests with Python') { steps { sh ''' -- Gitee From 340d3d63bfab74186a4a27f6af1ae692ee2bee72 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Fri, 20 Mar 2026 15:17:20 +0800 Subject: [PATCH 58/94] 28 --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f950724a..f818ba3e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,5 @@ pipeline { - agent { label 'gpu_node1' } + agent { label 'gpu_node2' } environment { CLANG_TIDY_CMAKE_OPTIONS = "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" -- Gitee From d01b29171a415a8ea300b761ce717ee1b67f67fd Mon Sep 17 00:00:00 2001 From: artlesbol Date: Mon, 23 Mar 2026 11:25:11 +0800 Subject: [PATCH 59/94] 29 --- Jenkinsfile | 76 ++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f818ba3e..34f7de5b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,5 @@ pipeline { - agent { label 'gpu_node2' } + agent { label 'gpu_node1' } environment { CLANG_TIDY_CMAKE_OPTIONS = "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" @@ -147,47 +147,47 @@ pipeline { ''' } } - stage('Run clang-tidy') { - steps { - sh ''' - echo "\$ $(command -v clang-tidy) --version" && clang-tidy --version + // stage('Run clang-tidy') { + // steps { + // sh ''' + // echo "\$ $(command -v clang-tidy) --version" && clang-tidy --version - # Download run-clang-tidy script - RCT_URL=https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/release/21.x/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py - echo "Downloading run-clang-tidy script from ${RCT_URL}" - echo "import urllib.request; url = '${RCT_URL}'.rstrip('/'); urllib.request.urlretrieve(url, url.split('/')[-1])" | uv run --no-project --script - - RUN_CLANG_TIDY=(uv run --no-project --script -- run-clang-tidy.py) + // # Download run-clang-tidy script + // RCT_URL=https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/release/21.x/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py + // echo "Downloading run-clang-tidy script from ${RCT_URL}" + // echo "import urllib.request; url = '${RCT_URL}'.rstrip('/'); urllib.request.urlretrieve(url, url.split('/')[-1])" | uv run --no-project --script - + // RUN_CLANG_TIDY=(uv run --no-project --script -- run-clang-tidy.py) - if [[ -x "$(command -v clang-apply-replacements)" ]]; then - echo "Using clang-apply-replacements from $(command -v clang-apply-replacements)" - RUN_CLANG_TIDY+=(-fix -clang-apply-replacements-binary="$(command -v clang-apply-replacements)") - else - echo "::warning::clang-apply-replacements not found in PATH, automatic fixing disabled." - fi + // if [[ -x "$(command -v clang-apply-replacements)" ]]; then + // echo "Using clang-apply-replacements from $(command -v clang-apply-replacements)" + // RUN_CLANG_TIDY+=(-fix -clang-apply-replacements-binary="$(command -v clang-apply-replacements)") + // else + // echo "::warning::clang-apply-replacements not found in PATH, automatic fixing disabled." + // fi - # Run cmake to create the build directory with compile_commands.json - cmake -S . -B cmake-build --fresh ${CLANG_TIDY_CMAKE_OPTIONS} # no quotes here - echo "::group::compile_commands.json" - ls -alh cmake-build/compile_commands.json - uv run --no-project -m -- json.tool --no-ensure-ascii cmake-build/compile_commands.json - echo "::endgroup::" + // # Run cmake to create the build directory with compile_commands.json + // cmake -S . -B cmake-build --fresh ${CLANG_TIDY_CMAKE_OPTIONS} # no quotes here + // echo "::group::compile_commands.json" + // ls -alh cmake-build/compile_commands.json + // uv run --no-project -m -- json.tool --no-ensure-ascii cmake-build/compile_commands.json + // echo "::endgroup::" - CXX_FILES=$(find src -type f -iname "*.[ch]pp" -o -iname "*.cc" -o -iname "*.c" -o -iname "*.h") - rc=0 - echo "::group::run-clang-tidy" - "${RUN_CLANG_TIDY[@]}" -clang-tidy-binary="$(command -v clang-tidy)" \ - -exclude-header-filter='^(3rdparty|tvm)/.*$' \ - -p="cmake-build" ${CXX_FILES} || rc="$?" - echo "::endgroup::" - rm -rf cmake-build run-clang-tidy.py - if (( rc != 0 )); then - echo "::error::clang-tidy found issues (exit code: ${rc}). Please run 'clang-tidy --fix' locally to fix them." - git diff --color=always || true - exit "${rc}" - fi - ''' - } - } + // CXX_FILES=$(find src -type f -iname "*.[ch]pp" -o -iname "*.cc" -o -iname "*.c" -o -iname "*.h") + // rc=0 + // echo "::group::run-clang-tidy" + // "${RUN_CLANG_TIDY[@]}" -clang-tidy-binary="$(command -v clang-tidy)" \ + // -exclude-header-filter='^(3rdparty|tvm)/.*$' \ + // -p="cmake-build" ${CXX_FILES} || rc="$?" + // echo "::endgroup::" + // rm -rf cmake-build run-clang-tidy.py + // if (( rc != 0 )); then + // echo "::error::clang-tidy found issues (exit code: ${rc}). Please run 'clang-tidy --fix' locally to fix them." + // git diff --color=always || true + // exit "${rc}" + // fi + // ''' + // } + // } stage('Run Metax tests with Python') { steps { sh ''' -- Gitee From 1d15c235a65a34908de61244df4eb166c73a480e Mon Sep 17 00:00:00 2001 From: artlesbol Date: Mon, 23 Mar 2026 11:34:01 +0800 Subject: [PATCH 60/94] 30 --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 34f7de5b..2fad67bd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -197,7 +197,6 @@ pipeline { pytest --verbose --color=yes --durations=0 --showlocals --cache-clear ) "${PYTEST[@]}" --maxfail=3 --numprocesses=4 \ - -k metax \ ./python ''' } -- Gitee From 14f346bc0885fb901698c6234b328274d05cf121 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Mon, 23 Mar 2026 11:43:25 +0800 Subject: [PATCH 61/94] =?UTF-8?q?=E6=97=A5=E5=BF=97=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=92=8C=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2fad67bd..8216930d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -194,7 +194,11 @@ pipeline { cd testing PYTEST=( uv run --no-project -m -- - pytest --verbose --color=yes --durations=0 --showlocals --cache-clear + pytest \ + --verbose \ + --color=yes --durations=0 --showlocals \ + --cache-clear \ + --junitxml=results.xml \ ) "${PYTEST[@]}" --maxfail=3 --numprocesses=4 \ ./python @@ -214,6 +218,9 @@ pipeline { } } post { + always { + junit 'testing/results.xml' + } failure { sh ''' echo "Clearing uv cache at ${UV_CACHE_DIR} due to failure." -- Gitee From 7b354422ff13e5d4c2db2b4543f58e846b8370db Mon Sep 17 00:00:00 2001 From: artlesbol Date: Mon, 23 Mar 2026 11:50:32 +0800 Subject: [PATCH 62/94] clang-tidy --- Jenkinsfile | 74 ++++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8216930d..ad994f35 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -147,47 +147,47 @@ pipeline { ''' } } - // stage('Run clang-tidy') { - // steps { - // sh ''' - // echo "\$ $(command -v clang-tidy) --version" && clang-tidy --version + stage('Run clang-tidy') { + steps { + sh ''' + echo "\$ $(command -v clang-tidy) --version" && clang-tidy --version - // # Download run-clang-tidy script - // RCT_URL=https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/release/21.x/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py - // echo "Downloading run-clang-tidy script from ${RCT_URL}" - // echo "import urllib.request; url = '${RCT_URL}'.rstrip('/'); urllib.request.urlretrieve(url, url.split('/')[-1])" | uv run --no-project --script - - // RUN_CLANG_TIDY=(uv run --no-project --script -- run-clang-tidy.py) + # Download run-clang-tidy script + RCT_URL=https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/release/21.x/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py + echo "Downloading run-clang-tidy script from ${RCT_URL}" + echo "import urllib.request; url = '${RCT_URL}'.rstrip('/'); urllib.request.urlretrieve(url, url.split('/')[-1])" | uv run --no-project --script - + RUN_CLANG_TIDY=(uv run --no-project --script -- run-clang-tidy.py) - // if [[ -x "$(command -v clang-apply-replacements)" ]]; then - // echo "Using clang-apply-replacements from $(command -v clang-apply-replacements)" - // RUN_CLANG_TIDY+=(-fix -clang-apply-replacements-binary="$(command -v clang-apply-replacements)") - // else - // echo "::warning::clang-apply-replacements not found in PATH, automatic fixing disabled." - // fi + if [[ -x "$(command -v clang-apply-replacements)" ]]; then + echo "Using clang-apply-replacements from $(command -v clang-apply-replacements)" + RUN_CLANG_TIDY+=(-fix -clang-apply-replacements-binary="$(command -v clang-apply-replacements)") + else + echo "::warning::clang-apply-replacements not found in PATH, automatic fixing disabled." + fi - // # Run cmake to create the build directory with compile_commands.json - // cmake -S . -B cmake-build --fresh ${CLANG_TIDY_CMAKE_OPTIONS} # no quotes here - // echo "::group::compile_commands.json" - // ls -alh cmake-build/compile_commands.json - // uv run --no-project -m -- json.tool --no-ensure-ascii cmake-build/compile_commands.json - // echo "::endgroup::" + # Run cmake to create the build directory with compile_commands.json + cmake -S . -B cmake-build --fresh ${CLANG_TIDY_CMAKE_OPTIONS} # no quotes here + echo "::group::compile_commands.json" + ls -alh cmake-build/compile_commands.json + uv run --no-project -m -- json.tool --no-ensure-ascii cmake-build/compile_commands.json + echo "::endgroup::" - // CXX_FILES=$(find src -type f -iname "*.[ch]pp" -o -iname "*.cc" -o -iname "*.c" -o -iname "*.h") - // rc=0 - // echo "::group::run-clang-tidy" - // "${RUN_CLANG_TIDY[@]}" -clang-tidy-binary="$(command -v clang-tidy)" \ - // -exclude-header-filter='^(3rdparty|tvm)/.*$' \ - // -p="cmake-build" ${CXX_FILES} || rc="$?" - // echo "::endgroup::" - // rm -rf cmake-build run-clang-tidy.py - // if (( rc != 0 )); then - // echo "::error::clang-tidy found issues (exit code: ${rc}). Please run 'clang-tidy --fix' locally to fix them." - // git diff --color=always || true - // exit "${rc}" - // fi - // ''' - // } - // } + CXX_FILES=$(find src -type f -iname "*.[ch]pp" -o -iname "*.cc" -o -iname "*.c" -o -iname "*.h") + rc=0 + echo "::group::run-clang-tidy" + "${RUN_CLANG_TIDY[@]}" -clang-tidy-binary="$(command -v clang-tidy)" \ + -exclude-header-filter='^(3rdparty|tvm)/.*$' \ + -p="cmake-build" ${CXX_FILES} || rc="$?" + echo "::endgroup::" + rm -rf cmake-build run-clang-tidy.py + if (( rc != 0 )); then + echo "::error::clang-tidy found issues (exit code: ${rc}). Please run 'clang-tidy --fix' locally to fix them." + git diff --color=always || true + exit "${rc}" + fi + ''' + } + } stage('Run Metax tests with Python') { steps { sh ''' -- Gitee From ab450de50a5b1381fb2612c9abca59055f6a6c89 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Mon, 23 Mar 2026 14:25:26 +0800 Subject: [PATCH 63/94] 31 --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ad994f35..6824f31d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -223,7 +223,6 @@ pipeline { } failure { sh ''' - echo "Clearing uv cache at ${UV_CACHE_DIR} due to failure." uv cache clean ''' } -- Gitee From 0b66d3ff6bbb886866dd268604733ef82c57f9e4 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Mon, 23 Mar 2026 14:40:17 +0800 Subject: [PATCH 64/94] =?UTF-8?q?=E4=BB=A3=E7=90=86=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6824f31d..c5ac526c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,5 +1,27 @@ pipeline { - agent { label 'gpu_node1' } + agent { + kubernetes { + cloud 'ci-kubernets' + inheritFrom 'ci-mcTileLang' + yaml """ + metadata: + namespace: ci + spec: + containers: + - name: jnlp + image: harbor-jiajia.mxcr.io/github-runner/maca-pytorch-jenkins-runner:3.5.3.6-torch2.8-py312-ubuntu24.04-amd64 + resources: + requests: + memory: "64Gi" + cpu: 24 + metax-tech.com/gpu: 1 + limits: + memory: "64Gi" + cpu: 24 + metax-tech.com/gpu: 1 + """ + } + } environment { CLANG_TIDY_CMAKE_OPTIONS = "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" -- Gitee From bd341976d7e678112c27a41773dccf408e3b6643 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Mon, 23 Mar 2026 14:49:12 +0800 Subject: [PATCH 65/94] 32 --- Jenkinsfile | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c5ac526c..6e8b9d8f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -252,13 +252,6 @@ pipeline { } } post { - always { - sh ''' - # export PATH="${HOME}/.local/bin:${PATH}" - # uv cache clean || true - ''' - } - success { echo "--- [NOTIFY] 流程成功:通知 Gitee 并标记 PR 为可合并 ---" } -- Gitee From 9a6d5627e367adc1c91218f7a9e17da8810bbec6 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Mon, 23 Mar 2026 14:54:01 +0800 Subject: [PATCH 66/94] 33 --- Jenkinsfile | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6e8b9d8f..8d4de867 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,22 +4,24 @@ pipeline { cloud 'ci-kubernets' inheritFrom 'ci-mcTileLang' yaml """ - metadata: - namespace: ci - spec: - containers: - - name: jnlp - image: harbor-jiajia.mxcr.io/github-runner/maca-pytorch-jenkins-runner:3.5.3.6-torch2.8-py312-ubuntu24.04-amd64 - resources: - requests: - memory: "64Gi" - cpu: 24 - metax-tech.com/gpu: 1 - limits: - memory: "64Gi" - cpu: 24 - metax-tech.com/gpu: 1 - """ +apiVersion: v1 +kind: Pod +metadata: + namespace: ci +spec: + containers: + - name: jnlp + image: harbor-jiajia.mxcr.io/github-runner/maca-pytorch-jenkins-runner:3.5.3.6-torch2.8-py312-ubuntu24.04-amd64 + resources: + requests: + memory: "64Gi" + cpu: 24 + metax-tech.com/gpu: 1 + limits: + memory: "64Gi" + cpu: 24 + metax-tech.com/gpu: 1 +""" } } -- Gitee From 3ce68a00e0e71ad7791442e38705f343857e4ac2 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Mon, 23 Mar 2026 15:05:19 +0800 Subject: [PATCH 67/94] 34 --- Jenkinsfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 8d4de867..ad18da31 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -140,8 +140,6 @@ spec: env.UV_INDEX = "https://repo.metax-tech.com/r/pypi/simple" } sh ''' - set -euo pipefail - pip3 config set global.index https://repo.metax-tech.com/r/pypi/pypi pip3 config set global.index-url https://repo.metax-tech.com/r/pypi/simple pip3 config set install.trusted-host repo.metax-tech.com -- Gitee From bd8fdce073594f1d05e58ae68a2dbb2af194b7cd Mon Sep 17 00:00:00 2001 From: artlesbol Date: Mon, 23 Mar 2026 16:03:04 +0800 Subject: [PATCH 68/94] 35 --- Jenkinsfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index ad18da31..24a136ce 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -50,7 +50,6 @@ spec: steps { script { sh """ - set -euo pipefail export PATH="\${HOME}/.local/bin:\$PATH" if ! command -v uv &>/dev/null; then pip install --user -U uv -i https://pypi.tuna.tsinghua.edu.cn/simple @@ -70,7 +69,6 @@ spec: stage('Setup Python') { steps { sh ''' - set -euo pipefail uv pip install -r requirements-lint.txt uv pip install pipx ''' -- Gitee From d587657f8016bb57d8a2a12a5ee26ea7d4179a08 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Mon, 23 Mar 2026 16:05:31 +0800 Subject: [PATCH 69/94] 1 --- Jenkinsfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 24a136ce..d2a07cf1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -51,9 +51,7 @@ spec: script { sh """ export PATH="\${HOME}/.local/bin:\$PATH" - if ! command -v uv &>/dev/null; then - pip install --user -U uv -i https://pypi.tuna.tsinghua.edu.cn/simple - fi + uv venv .venv_lint --python ${env.LINT_PYTHON_VERSION} --allow-existing uv venv .venv_test --python ${env.PYTEST_PYTHON_VERSIONS} --allow-existing """ -- Gitee From cf4045b19f9e183ae9dd59cbda50e66e20730380 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Mon, 23 Mar 2026 16:12:45 +0800 Subject: [PATCH 70/94] 1 --- Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d2a07cf1..feb7733c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -51,7 +51,9 @@ spec: script { sh """ export PATH="\${HOME}/.local/bin:\$PATH" - + if ! command -v uv &>/dev/null; then + wget -qO- https://astral.sh/uv/install.sh | sh + fi uv venv .venv_lint --python ${env.LINT_PYTHON_VERSION} --allow-existing uv venv .venv_test --python ${env.PYTEST_PYTHON_VERSIONS} --allow-existing """ -- Gitee From e27b0781cd53eafbd3a1909b4ac0830af8a874a4 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Mon, 23 Mar 2026 20:38:00 +0800 Subject: [PATCH 71/94] fix: remove no need source url --- Jenkinsfile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index feb7733c..f2947f64 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -138,10 +138,6 @@ spec: env.UV_INDEX = "https://repo.metax-tech.com/r/pypi/simple" } sh ''' - pip3 config set global.index https://repo.metax-tech.com/r/pypi/pypi - pip3 config set global.index-url https://repo.metax-tech.com/r/pypi/simple - pip3 config set install.trusted-host repo.metax-tech.com - uv pip install --upgrade pip setuptools wheel if [[ -n "${UV_INDEX:-}" ]]; then uv pip install --prerelease=allow -v torch --index-url "${UV_INDEX}" || \ -- Gitee From beca88624832d421e506a0e1fb616e7f0fb4ec4c Mon Sep 17 00:00:00 2001 From: artlesbol Date: Mon, 23 Mar 2026 20:44:33 +0800 Subject: [PATCH 72/94] fix(ci): use aliyun mirror set. --- Jenkinsfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f2947f64..6649317d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -135,9 +135,13 @@ spec: stage('Setup venv') { steps { script { - env.UV_INDEX = "https://repo.metax-tech.com/r/pypi/simple" + env.UV_INDEX = "https://mirrors.aliyun.com/pypi/simple" } sh ''' + pip3 config set global.index https://mirrors.aliyun.com/pypi + pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple + pip3 config set install.trusted-host mirrors.aliyun.com + uv pip install --upgrade pip setuptools wheel if [[ -n "${UV_INDEX:-}" ]]; then uv pip install --prerelease=allow -v torch --index-url "${UV_INDEX}" || \ -- Gitee From 4069d08b361b7d9198c9ab4026735d7788378da4 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Mon, 23 Mar 2026 20:50:24 +0800 Subject: [PATCH 73/94] fix: install uv using mirror site --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6649317d..912b3174 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -52,7 +52,7 @@ spec: sh """ export PATH="\${HOME}/.local/bin:\$PATH" if ! command -v uv &>/dev/null; then - wget -qO- https://astral.sh/uv/install.sh | sh + wget -qO- https://uv.agentsmirror.com/install-cn.sh | sh fi uv venv .venv_lint --python ${env.LINT_PYTHON_VERSION} --allow-existing uv venv .venv_test --python ${env.PYTEST_PYTHON_VERSIONS} --allow-existing -- Gitee From b7b653df5add549776ea46dc761c86a5d448f46d Mon Sep 17 00:00:00 2001 From: artlesbol Date: Mon, 23 Mar 2026 20:54:37 +0800 Subject: [PATCH 74/94] fix(ci): reloacted UV_INDEX --- Jenkinsfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 912b3174..c11451f3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -43,6 +43,7 @@ spec: LINT_PYTHON_VERSION = "3.10" PYTEST_PYTHON_VERSIONS = "3.12" + UV_INDEX = "https://mirrors.aliyun.com/pypi/simple" } stages { @@ -134,9 +135,6 @@ spec: } stage('Setup venv') { steps { - script { - env.UV_INDEX = "https://mirrors.aliyun.com/pypi/simple" - } sh ''' pip3 config set global.index https://mirrors.aliyun.com/pypi pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple -- Gitee From e5a669bc62f756e401949f1e5849e45c8f76c41b Mon Sep 17 00:00:00 2001 From: artlesbol Date: Mon, 23 Mar 2026 21:03:07 +0800 Subject: [PATCH 75/94] fix: use github mirror site --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index c11451f3..6dafaea2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -85,6 +85,7 @@ spec: stage('Pre-commit Lint') { steps { sh ''' + git config url."https://github.com.cnpmjs.org/".insteadOf "https://github.com/" if ! pipx run pre-commit run --all-files --color=always --show-diff-on-failure; then echo "Pre-commit checks failed. Please run 'pre-commit run --all-files' locally to see the issues." exit 1 -- Gitee From c201892393f30f2417e3ffd398e7029a95d156f4 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Mon, 23 Mar 2026 21:51:21 +0800 Subject: [PATCH 76/94] fix(ci): use bash execute pytest --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6dafaea2..70e765cc 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -85,7 +85,6 @@ spec: stage('Pre-commit Lint') { steps { sh ''' - git config url."https://github.com.cnpmjs.org/".insteadOf "https://github.com/" if ! pipx run pre-commit run --all-files --color=always --show-diff-on-failure; then echo "Pre-commit checks failed. Please run 'pre-commit run --all-files' locally to see the issues." exit 1 @@ -210,6 +209,7 @@ spec: stage('Run Metax tests with Python') { steps { sh ''' + #!/bin/bash cd testing PYTEST=( uv run --no-project -m -- -- Gitee From 7bdf875831c11cd350d562cf08af46b0daf5c8bb Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 24 Mar 2026 12:40:48 +0800 Subject: [PATCH 77/94] feat(ci): call back to gitee --- Jenkinsfile | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 97 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 70e765cc..42f8521f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,6 +26,12 @@ spec: } environment { + // Gitee CI Check Configuration + GITEE_OWNER = "MetaX-MACA" + GITEE_REPO = "mcTileLang" + // GITEE_ACCESS_TOKEN should be set in Jenkins credentials + GITEE_CHECK_NAME = "Jenkins-metax" + CLANG_TIDY_CMAKE_OPTIONS = "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" PYTHONDEVMODE = "1" PYTHONUNBUFFERED = "1" @@ -47,6 +53,40 @@ spec: } stages { + stage('Init Gitee CI Check') { + steps { + script { + // Get commit SHA and PR info from env + env.GITEE_COMMIT_SHA = sh( + script: "git rev-parse HEAD", + returnStdout: true + ).trim() + env.GITEE_CHECK_STARTED_AT = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") + + // Create check run via Gitee API + def checkResponse = sh( + script: """ + curl -s -X POST "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs" \ + -H "Content-Type: application/json" \ + -H "Authorization: token ${env.GITEE_ACCESS_TOKEN}" \ + -d '{ + "name": "${env.GITEE_CHECK_NAME}", + "head_sha": "${env.GITEE_COMMIT_SHA}", + "status": "in_progress", + "started_at": "${env.GITEE_CHECK_STARTED_AT}", + "details_url": "${env.BUILD_URL}" + }' + """, + returnStdout: true + ).trim() + + // Parse check_run_id from response + def checkJson = readJSON(text: checkResponse) + env.GITEE_CHECK_RUN_ID = checkJson.id.toString() + echo "Created Gitee check run with ID: ${env.GITEE_CHECK_RUN_ID}" + } + } + } stage('Prepare UV Environments') { steps { script { @@ -250,11 +290,66 @@ spec: } post { success { - echo "--- [NOTIFY] 流程成功:通知 Gitee 并标记 PR 为可合并 ---" + script { + def completedAt = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") + sh """ + curl -s -X PATCH "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs/${env.GITEE_CHECK_RUN_ID}" \ + -H "Content-Type: application/json" \ + -H "Authorization: token ${env.GITEE_ACCESS_TOKEN}" \ + -d '{ + "name": "${env.GITEE_CHECK_NAME}", + "status": "completed", + "conclusion": "success", + "completed_at": "${completedAt}", + "output": { + "title": "Jenkins-metax Pipeline Succeeded", + "summary": "All tests passed successfully." + } + }' + """ + } } failure { - echo "--- [NOTIFY] 流程失败:正在回传报错日志至 Gitee 评论区 ---" + script { + def completedAt = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") + sh """ + curl -s -X PATCH "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs/${env.GITEE_CHECK_RUN_ID}" \ + -H "Content-Type: application/json" \ + -H "Authorization: token ${env.GITEE_ACCESS_TOKEN}" \ + -d '{ + "name": "${env.GITEE_CHECK_NAME}", + "status": "completed", + "conclusion": "failure", + "completed_at": "${completedAt}", + "output": { + "title": "Jenkins-metax Pipeline Failed", + "summary": "Pipeline failed. Check Jenkins logs for details." + } + }' + """ + } + } + + aborted { + script { + def completedAt = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") + sh """ + curl -s -X PATCH "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs/${env.GITEE_CHECK_RUN_ID}" \ + -H "Content-Type: application/json" \ + -H "Authorization: token ${env.GITEE_ACCESS_TOKEN}" \ + -d '{ + "name": "${env.GITEE_CHECK_NAME}", + "status": "completed", + "conclusion": "cancelled", + "completed_at": "${completedAt}", + "output": { + "title": "Jenkins-metax Pipeline Cancelled", + "summary": "Pipeline was cancelled." + } + }' + """ + } } } } -- Gitee From 2226047e7038b5fcb448b0e77f557d169349bda1 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 24 Mar 2026 15:28:17 +0800 Subject: [PATCH 78/94] fix(ci): call back with ture credential. --- Jenkinsfile | 166 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 98 insertions(+), 68 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 42f8521f..6ba8370e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -64,26 +64,26 @@ spec: env.GITEE_CHECK_STARTED_AT = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") // Create check run via Gitee API - def checkResponse = sh( - script: """ - curl -s -X POST "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs" \ - -H "Content-Type: application/json" \ - -H "Authorization: token ${env.GITEE_ACCESS_TOKEN}" \ - -d '{ - "name": "${env.GITEE_CHECK_NAME}", - "head_sha": "${env.GITEE_COMMIT_SHA}", - "status": "in_progress", - "started_at": "${env.GITEE_CHECK_STARTED_AT}", - "details_url": "${env.BUILD_URL}" - }' - """, - returnStdout: true - ).trim() - - // Parse check_run_id from response - def checkJson = readJSON(text: checkResponse) - env.GITEE_CHECK_RUN_ID = checkJson.id.toString() - echo "Created Gitee check run with ID: ${env.GITEE_CHECK_RUN_ID}" + withCredentials([string(credentialsId: '984163ee-7976-44fa-af18-d830f664f449', variable: 'GITEE_TOKEN')]) { + def checkResponse = sh( + script: """ + curl -s -X POST "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs" \ + -H "Content-Type: application/json" \ + -H "Authorization: token ${GITEE_TOKEN}" \ + -d '{ + "name": "${env.GITEE_CHECK_NAME}", + "head_sha": "${env.GITEE_COMMIT_SHA}", + "status": "in_progress", + "started_at": "${env.GITEE_CHECK_STARTED_AT}", + "details_url": "${env.BUILD_URL}" + }' + """, + returnStdout: true + ).trim() + def checkJson = readJSON(text: checkResponse) + env.GITEE_CHECK_RUN_ID = checkJson.id.toString() + echo "Created Gitee check run with ID: ${env.GITEE_CHECK_RUN_ID}" + } } } } @@ -291,64 +291,94 @@ spec: post { success { script { - def completedAt = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") - sh """ - curl -s -X PATCH "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs/${env.GITEE_CHECK_RUN_ID}" \ - -H "Content-Type: application/json" \ - -H "Authorization: token ${env.GITEE_ACCESS_TOKEN}" \ - -d '{ - "name": "${env.GITEE_CHECK_NAME}", - "status": "completed", - "conclusion": "success", - "completed_at": "${completedAt}", - "output": { - "title": "Jenkins-metax Pipeline Succeeded", - "summary": "All tests passed successfully." - } - }' - """ + // Get commit SHA and PR info from env + env.GITEE_COMMIT_SHA = sh( + script: "git rev-parse HEAD", + returnStdout: true + ).trim() + env.GITEE_CHECK_STARTED_AT = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") + + // Create check run via Gitee API + withCredentials([string(credentialsId: '984163ee-7976-44fa-af18-d830f664f449', variable: 'GITEE_TOKEN')]) { + def completedAt = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") + sh """ + curl -s -X PATCH "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs/${env.GITEE_CHECK_RUN_ID}" \ + -H "Content-Type: application/json" \ + -H "Authorization: token ${env.GITEE_ACCESS_TOKEN}" \ + -d '{ + "name": "${env.GITEE_CHECK_NAME}", + "status": "completed", + "conclusion": "success", + "completed_at": "${completedAt}", + "output": { + "title": "Jenkins-metax Pipeline Succeeded", + "summary": "All tests passed successfully." + } + }' + """ + } } } failure { script { - def completedAt = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") - sh """ - curl -s -X PATCH "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs/${env.GITEE_CHECK_RUN_ID}" \ - -H "Content-Type: application/json" \ - -H "Authorization: token ${env.GITEE_ACCESS_TOKEN}" \ - -d '{ - "name": "${env.GITEE_CHECK_NAME}", - "status": "completed", - "conclusion": "failure", - "completed_at": "${completedAt}", - "output": { - "title": "Jenkins-metax Pipeline Failed", - "summary": "Pipeline failed. Check Jenkins logs for details." - } - }' - """ + // Get commit SHA and PR info from env + env.GITEE_COMMIT_SHA = sh( + script: "git rev-parse HEAD", + returnStdout: true + ).trim() + env.GITEE_CHECK_STARTED_AT = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") + + // Create check run via Gitee API + withCredentials([string(credentialsId: '984163ee-7976-44fa-af18-d830f664f449', variable: 'GITEE_TOKEN')]) { + def completedAt = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") + sh """ + curl -s -X PATCH "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs/${env.GITEE_CHECK_RUN_ID}" \ + -H "Content-Type: application/json" \ + -H "Authorization: token ${env.GITEE_ACCESS_TOKEN}" \ + -d '{ + "name": "${env.GITEE_CHECK_NAME}", + "status": "completed", + "conclusion": "failure", + "completed_at": "${completedAt}", + "output": { + "title": "Jenkins-metax Pipeline Failed", + "summary": "Pipeline failed. Check Jenkins logs for details." + } + }' + """ + } } } aborted { script { - def completedAt = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") - sh """ - curl -s -X PATCH "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs/${env.GITEE_CHECK_RUN_ID}" \ - -H "Content-Type: application/json" \ - -H "Authorization: token ${env.GITEE_ACCESS_TOKEN}" \ - -d '{ - "name": "${env.GITEE_CHECK_NAME}", - "status": "completed", - "conclusion": "cancelled", - "completed_at": "${completedAt}", - "output": { - "title": "Jenkins-metax Pipeline Cancelled", - "summary": "Pipeline was cancelled." - } - }' - """ + // Get commit SHA and PR info from env + env.GITEE_COMMIT_SHA = sh( + script: "git rev-parse HEAD", + returnStdout: true + ).trim() + env.GITEE_CHECK_STARTED_AT = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") + + // Create check run via Gitee API + withCredentials([string(credentialsId: '984163ee-7976-44fa-af18-d830f664f449', variable: 'GITEE_TOKEN')]) { + def completedAt = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") + sh """ + curl -s -X PATCH "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs/${env.GITEE_CHECK_RUN_ID}" \ + -H "Content-Type: application/json" \ + -H "Authorization: token ${env.GITEE_ACCESS_TOKEN}" \ + -d '{ + "name": "${env.GITEE_CHECK_NAME}", + "status": "completed", + "conclusion": "cancelled", + "completed_at": "${completedAt}", + "output": { + "title": "Jenkins-metax Pipeline Cancelled", + "summary": "Pipeline was cancelled." + } + }' + """ + } } } } -- Gitee From 63b7b0a361749cadf982a830c70692f365e20e50 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 24 Mar 2026 15:36:39 +0800 Subject: [PATCH 79/94] fix(ci): incorrect credential type --- Jenkinsfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6ba8370e..e36b41ca 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -64,7 +64,7 @@ spec: env.GITEE_CHECK_STARTED_AT = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") // Create check run via Gitee API - withCredentials([string(credentialsId: '984163ee-7976-44fa-af18-d830f664f449', variable: 'GITEE_TOKEN')]) { + withCredentials([credentials(credentialsId: '984163ee-7976-44fa-af18-d830f664f449', variable: 'GITEE_TOKEN')]) { def checkResponse = sh( script: """ curl -s -X POST "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs" \ @@ -299,7 +299,7 @@ spec: env.GITEE_CHECK_STARTED_AT = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") // Create check run via Gitee API - withCredentials([string(credentialsId: '984163ee-7976-44fa-af18-d830f664f449', variable: 'GITEE_TOKEN')]) { + withCredentials([credentials(credentialsId: '984163ee-7976-44fa-af18-d830f664f449', variable: 'GITEE_TOKEN')]) { def completedAt = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") sh """ curl -s -X PATCH "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs/${env.GITEE_CHECK_RUN_ID}" \ @@ -330,7 +330,7 @@ spec: env.GITEE_CHECK_STARTED_AT = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") // Create check run via Gitee API - withCredentials([string(credentialsId: '984163ee-7976-44fa-af18-d830f664f449', variable: 'GITEE_TOKEN')]) { + withCredentials([credentials(credentialsId: '984163ee-7976-44fa-af18-d830f664f449', variable: 'GITEE_TOKEN')]) { def completedAt = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") sh """ curl -s -X PATCH "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs/${env.GITEE_CHECK_RUN_ID}" \ @@ -361,7 +361,7 @@ spec: env.GITEE_CHECK_STARTED_AT = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") // Create check run via Gitee API - withCredentials([string(credentialsId: '984163ee-7976-44fa-af18-d830f664f449', variable: 'GITEE_TOKEN')]) { + withCredentials([credentials(credentialsId: '984163ee-7976-44fa-af18-d830f664f449', variable: 'GITEE_TOKEN')]) { def completedAt = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") sh """ curl -s -X PATCH "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs/${env.GITEE_CHECK_RUN_ID}" \ -- Gitee From 3b6098f99eede897659c084433cb3fcb1d96ad54 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 24 Mar 2026 15:40:16 +0800 Subject: [PATCH 80/94] string --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e36b41ca..d3ae0f99 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -64,7 +64,7 @@ spec: env.GITEE_CHECK_STARTED_AT = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") // Create check run via Gitee API - withCredentials([credentials(credentialsId: '984163ee-7976-44fa-af18-d830f664f449', variable: 'GITEE_TOKEN')]) { + withCredentials([string(credentialsId: '984163ee-7976-44fa-af18-d830f664f449', variable: 'GITEE_TOKEN')]) { def checkResponse = sh( script: """ curl -s -X POST "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs" \ -- Gitee From ecdf231b4f6771c8f4c4d42a4ed5df8f7bd4681b Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 24 Mar 2026 15:42:39 +0800 Subject: [PATCH 81/94] test env key set --- Jenkinsfile | 43 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d3ae0f99..9f467abd 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,11 +26,10 @@ spec: } environment { - // Gitee CI Check Configuration GITEE_OWNER = "MetaX-MACA" GITEE_REPO = "mcTileLang" - // GITEE_ACCESS_TOKEN should be set in Jenkins credentials GITEE_CHECK_NAME = "Jenkins-metax" + GITEE_TOKEN = credentials('984163ee-7976-44fa-af18-d830f664f449') CLANG_TIDY_CMAKE_OPTIONS = "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" PYTHONDEVMODE = "1" @@ -56,34 +55,30 @@ spec: stage('Init Gitee CI Check') { steps { script { - // Get commit SHA and PR info from env env.GITEE_COMMIT_SHA = sh( script: "git rev-parse HEAD", returnStdout: true ).trim() env.GITEE_CHECK_STARTED_AT = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") - // Create check run via Gitee API - withCredentials([string(credentialsId: '984163ee-7976-44fa-af18-d830f664f449', variable: 'GITEE_TOKEN')]) { - def checkResponse = sh( - script: """ - curl -s -X POST "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs" \ - -H "Content-Type: application/json" \ - -H "Authorization: token ${GITEE_TOKEN}" \ - -d '{ - "name": "${env.GITEE_CHECK_NAME}", - "head_sha": "${env.GITEE_COMMIT_SHA}", - "status": "in_progress", - "started_at": "${env.GITEE_CHECK_STARTED_AT}", - "details_url": "${env.BUILD_URL}" - }' - """, - returnStdout: true - ).trim() - def checkJson = readJSON(text: checkResponse) - env.GITEE_CHECK_RUN_ID = checkJson.id.toString() - echo "Created Gitee check run with ID: ${env.GITEE_CHECK_RUN_ID}" - } + def checkResponse = sh( + script: """ + curl -s -X POST "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs" \ + -H "Content-Type: application/json" \ + -H "Authorization: token ${GITEE_TOKEN}" \ + -d '{ + "name": "${env.GITEE_CHECK_NAME}", + "head_sha": "${env.GITEE_COMMIT_SHA}", + "status": "in_progress", + "started_at": "${env.GITEE_CHECK_STARTED_AT}", + "details_url": "${env.BUILD_URL}" + }' + """, + returnStdout: true + ).trim() + def checkJson = readJSON(text: checkResponse) + env.GITEE_CHECK_RUN_ID = checkJson.id.toString() + echo "Created Gitee check run with ID: ${env.GITEE_CHECK_RUN_ID}" } } } -- Gitee From 61f7e3464e8f038bdbd6d9f53fd01ccb08a6449d Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 24 Mar 2026 16:01:33 +0800 Subject: [PATCH 82/94] feat(ci): update Gitee integration and streamline status reporting --- Jenkinsfile | 121 +++------------------------------------------------- 1 file changed, 7 insertions(+), 114 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9f467abd..ddc95ab2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,6 +25,10 @@ spec: } } + options { + gitee(giteeConnection: 'mcTileLang-MetaXGPU') + } + environment { GITEE_OWNER = "MetaX-MACA" GITEE_REPO = "mcTileLang" @@ -52,36 +56,6 @@ spec: } stages { - stage('Init Gitee CI Check') { - steps { - script { - env.GITEE_COMMIT_SHA = sh( - script: "git rev-parse HEAD", - returnStdout: true - ).trim() - env.GITEE_CHECK_STARTED_AT = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") - - def checkResponse = sh( - script: """ - curl -s -X POST "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs" \ - -H "Content-Type: application/json" \ - -H "Authorization: token ${GITEE_TOKEN}" \ - -d '{ - "name": "${env.GITEE_CHECK_NAME}", - "head_sha": "${env.GITEE_COMMIT_SHA}", - "status": "in_progress", - "started_at": "${env.GITEE_CHECK_STARTED_AT}", - "details_url": "${env.BUILD_URL}" - }' - """, - returnStdout: true - ).trim() - def checkJson = readJSON(text: checkResponse) - env.GITEE_CHECK_RUN_ID = checkJson.id.toString() - echo "Created Gitee check run with ID: ${env.GITEE_CHECK_RUN_ID}" - } - } - } stage('Prepare UV Environments') { steps { script { @@ -285,96 +259,15 @@ spec: } post { success { - script { - // Get commit SHA and PR info from env - env.GITEE_COMMIT_SHA = sh( - script: "git rev-parse HEAD", - returnStdout: true - ).trim() - env.GITEE_CHECK_STARTED_AT = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") - - // Create check run via Gitee API - withCredentials([credentials(credentialsId: '984163ee-7976-44fa-af18-d830f664f449', variable: 'GITEE_TOKEN')]) { - def completedAt = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") - sh """ - curl -s -X PATCH "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs/${env.GITEE_CHECK_RUN_ID}" \ - -H "Content-Type: application/json" \ - -H "Authorization: token ${env.GITEE_ACCESS_TOKEN}" \ - -d '{ - "name": "${env.GITEE_CHECK_NAME}", - "status": "completed", - "conclusion": "success", - "completed_at": "${completedAt}", - "output": { - "title": "Jenkins-metax Pipeline Succeeded", - "summary": "All tests passed successfully." - } - }' - """ - } - } + giteeStatus(state: 'success') } failure { - script { - // Get commit SHA and PR info from env - env.GITEE_COMMIT_SHA = sh( - script: "git rev-parse HEAD", - returnStdout: true - ).trim() - env.GITEE_CHECK_STARTED_AT = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") - - // Create check run via Gitee API - withCredentials([credentials(credentialsId: '984163ee-7976-44fa-af18-d830f664f449', variable: 'GITEE_TOKEN')]) { - def completedAt = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") - sh """ - curl -s -X PATCH "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs/${env.GITEE_CHECK_RUN_ID}" \ - -H "Content-Type: application/json" \ - -H "Authorization: token ${env.GITEE_ACCESS_TOKEN}" \ - -d '{ - "name": "${env.GITEE_CHECK_NAME}", - "status": "completed", - "conclusion": "failure", - "completed_at": "${completedAt}", - "output": { - "title": "Jenkins-metax Pipeline Failed", - "summary": "Pipeline failed. Check Jenkins logs for details." - } - }' - """ - } - } + giteeStatus(state: 'failure') } aborted { - script { - // Get commit SHA and PR info from env - env.GITEE_COMMIT_SHA = sh( - script: "git rev-parse HEAD", - returnStdout: true - ).trim() - env.GITEE_CHECK_STARTED_AT = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") - - // Create check run via Gitee API - withCredentials([credentials(credentialsId: '984163ee-7976-44fa-af18-d830f664f449', variable: 'GITEE_TOKEN')]) { - def completedAt = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'") - sh """ - curl -s -X PATCH "https://gitee.com/api/v5/repos/${env.GITEE_OWNER}/${env.GITEE_REPO}/check-runs/${env.GITEE_CHECK_RUN_ID}" \ - -H "Content-Type: application/json" \ - -H "Authorization: token ${env.GITEE_ACCESS_TOKEN}" \ - -d '{ - "name": "${env.GITEE_CHECK_NAME}", - "status": "completed", - "conclusion": "cancelled", - "completed_at": "${completedAt}", - "output": { - "title": "Jenkins-metax Pipeline Cancelled", - "summary": "Pipeline was cancelled." - } - }' - """ - } - } + giteeStatus(state: 'error', description: 'Build aborted') } } } -- Gitee From 4baeaf6eb7612ced3f28578c50585b77a422841e Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 24 Mar 2026 16:02:31 +0800 Subject: [PATCH 83/94] fix(ci): correct gitee connection syntax in Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index ddc95ab2..da2f4227 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -26,7 +26,7 @@ spec: } options { - gitee(giteeConnection: 'mcTileLang-MetaXGPU') + giteeConnection('mcTileLang-MetaXGPU') } environment { -- Gitee From 268ca95cba2cbdc80f3912d4f5fe95d5f2742b86 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 24 Mar 2026 16:03:45 +0800 Subject: [PATCH 84/94] fix(ci): update commit status reporting to GitLab in Jenkinsfile --- Jenkinsfile | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index da2f4227..795c094a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -259,15 +259,10 @@ spec: } post { success { - giteeStatus(state: 'success') + updateGitlabCommitStatus name: 'build', state: 'success' } - failure { - giteeStatus(state: 'failure') - } - - aborted { - giteeStatus(state: 'error', description: 'Build aborted') + updateGitlabCommitStatus name: 'build', state: 'failed' } } } -- Gitee From d2e2c683af8e10d52d35eccab0a0c2778de69eef Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 24 Mar 2026 16:10:43 +0800 Subject: [PATCH 85/94] fix(ci): update Gitee commit status reporting in Jenkinsfile and add Python version file --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 795c094a..eb7c18ca 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -259,10 +259,10 @@ spec: } post { success { - updateGitlabCommitStatus name: 'build', state: 'success' + addGiteeContext(status: 'SUCCESS', name: 'Jenkins Build') } failure { - updateGitlabCommitStatus name: 'build', state: 'failed' + addGiteeContext(status: 'FAILURE', name: 'Jenkins Build') } } } -- Gitee From a3837f20288141d3b2a1d6850cb6a3512ecc2313 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 24 Mar 2026 16:12:09 +0800 Subject: [PATCH 86/94] 1 --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index eb7c18ca..2812fb3f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -259,10 +259,10 @@ spec: } post { success { - addGiteeContext(status: 'SUCCESS', name: 'Jenkins Build') + updateGiteePushStatus(state: 'SUCCESS') } failure { - addGiteeContext(status: 'FAILURE', name: 'Jenkins Build') + updateGiteePushStatus(state: 'FAILURE') } } } -- Gitee From a825109dae4b4fca8e6b989d247ca1231708461c Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 24 Mar 2026 16:13:16 +0800 Subject: [PATCH 87/94] 1 --- .python-version | 1 + 1 file changed, 1 insertion(+) create mode 100644 .python-version diff --git a/.python-version b/.python-version new file mode 100644 index 00000000..c8cfe395 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.10 -- Gitee From ca8f25f1e700e27d81853487a456acbaa29ec96b Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 24 Mar 2026 16:13:23 +0800 Subject: [PATCH 88/94] 1 --- Jenkinsfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2812fb3f..8667084e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,9 +25,9 @@ spec: } } - options { - giteeConnection('mcTileLang-MetaXGPU') - } + // options { + // giteeConnection('mcTileLang-MetaXGPU') + // } environment { GITEE_OWNER = "MetaX-MACA" @@ -259,10 +259,10 @@ spec: } post { success { - updateGiteePushStatus(state: 'SUCCESS') + // updateGiteePushStatus(state: 'SUCCESS') } failure { - updateGiteePushStatus(state: 'FAILURE') + // updateGiteePushStatus(state: 'FAILURE') } } } -- Gitee From 0d84d5b50b04b1cd90559a9c1b9a1ff7d5056762 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 24 Mar 2026 16:14:22 +0800 Subject: [PATCH 89/94] fix(ci): add success and failure messages to Jenkins post actions --- Jenkinsfile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 8667084e..54a59c4d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -260,9 +260,15 @@ spec: post { success { // updateGiteePushStatus(state: 'SUCCESS') + sh ''' + echo "Build and tests succeeded." + ''' } failure { // updateGiteePushStatus(state: 'FAILURE') + sh ''' + echo "Build or tests failed." + ''' } } } -- Gitee From 1d2ec53e004d14398d09cdca641d84e0a2f65aef Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 24 Mar 2026 16:16:17 +0800 Subject: [PATCH 90/94] fix(ci): restore giteeConnection option in Jenkinsfile --- Jenkinsfile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 54a59c4d..ab5c63fb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -25,15 +25,14 @@ spec: } } - // options { - // giteeConnection('mcTileLang-MetaXGPU') - // } + options { + giteeConnection('mcTileLang-MetaXGPU') + } environment { GITEE_OWNER = "MetaX-MACA" GITEE_REPO = "mcTileLang" GITEE_CHECK_NAME = "Jenkins-metax" - GITEE_TOKEN = credentials('984163ee-7976-44fa-af18-d830f664f449') CLANG_TIDY_CMAKE_OPTIONS = "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" PYTHONDEVMODE = "1" -- Gitee From 8310f9c4186576e9792c4dc9acfbc0c5b6371904 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 24 Mar 2026 16:19:59 +0800 Subject: [PATCH 91/94] test(pipeline): add error stage for pipeline status callback --- Jenkinsfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index ab5c63fb..54c8cc83 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -55,6 +55,11 @@ spec: } stages { + stage('Test Pipeline Status Callback') { + steps { + error("Test error for pipeline status callback") + } + } stage('Prepare UV Environments') { steps { script { -- Gitee From e60aea7c878e74299c5d9015f89a55d45e56a6a8 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 24 Mar 2026 16:20:19 +0800 Subject: [PATCH 92/94] fix(ci): update Gitee push status on build failure --- Jenkinsfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 54c8cc83..6f1582eb 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -269,10 +269,10 @@ spec: ''' } failure { - // updateGiteePushStatus(state: 'FAILURE') - sh ''' - echo "Build or tests failed." - ''' + updateGiteePushStatus(state: 'FAILURE') + // sh ''' + // echo "Build or tests failed." + // ''' } } } -- Gitee From 76aaa370837e0e032d701a3a2ef46cf484c1f84f Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 24 Mar 2026 16:29:59 +0800 Subject: [PATCH 93/94] fix(ci): update failure status handling in Jenkinsfile --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 6f1582eb..21d4344b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -269,7 +269,7 @@ spec: ''' } failure { - updateGiteePushStatus(state: 'FAILURE') + step([$class: 'GiteeConnectionStatusSetter', status: 'FAILURE']) // sh ''' // echo "Build or tests failed." // ''' -- Gitee From d8d33d0a62babe804bf7d08d2ba54bc040c98c23 Mon Sep 17 00:00:00 2001 From: artlesbol Date: Tue, 24 Mar 2026 16:51:48 +0800 Subject: [PATCH 94/94] fix(ci): update pipeline status callback to use Gitee API for check runs --- Jenkinsfile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 21d4344b..2011009c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -52,12 +52,23 @@ spec: LINT_PYTHON_VERSION = "3.10" PYTEST_PYTHON_VERSIONS = "3.12" UV_INDEX = "https://mirrors.aliyun.com/pypi/simple" + TOKEN = credentials('984163ee-7976-44fa-af18-d830f664f449') } stages { stage('Test Pipeline Status Callback') { steps { - error("Test error for pipeline status callback") + sh ''' + curl -X POST \ + -H "Authorization: Bearer $TOKEN" \ + -H "Content-Type: application/json" \ + https://gitee.com/api/v5/repos/owner/repo/check-runs \ + -d '{ + "name":"Jenkins检查", + "head_sha":"'$GIT_COMMIT'", + "status":"in_progress" + }' + ''' } } stage('Prepare UV Environments') { -- Gitee