From 9929433ea2511c361a0e84fb3e0f8c40446581ed Mon Sep 17 00:00:00 2001 From: CSY-ModelCloud Date: Wed, 22 Oct 2025 10:04:19 +0800 Subject: [PATCH 1/5] [CI] fix cutlass was not installed & checkout dir doesn't exist --- .github/workflows/release.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 114986dc3..e4beb7050 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -310,7 +310,10 @@ jobs: - name: Compile if: env.SHOULD_RUN == 1 - run: python setup.py bdist_wheel + run: | + mkdir -p cutlass/python || true + python gptqmodel_ext/machete/generate.py + python setup.py bdist_wheel - name: Test install if: env.SHOULD_RUN == 1 @@ -395,7 +398,10 @@ jobs: git checkout pr-${PR_NUMBER} - name: Compile - run: python -m build --no-isolation --sdist + run: | + mkdir -p cutlass/python || true + python gptqmodel_ext/machete/generate.py + python -m build --no-isolation --sdist - name: Check dist run: | @@ -478,7 +484,7 @@ jobs: git config --global --add safe.directory $(pwd) git fetch origin pull/${PR_NUMBER}/head:pr-${PR_NUMBER} git checkout pr-${PR_NUMBER} - + - uses: actions/setup-python@v6 with: python-version: 3.13 @@ -488,8 +494,13 @@ jobs: run: | pip install build setuptools uv -U uv pip install torch twine ninja --system + - name: Compile - run: python -m build --no-isolation --sdist + run: | + mkdir -p cutlass/python || true + python gptqmodel_ext/machete/generate.py + python -m build --no-isolation --sdist + - name: Check dist run: | @@ -497,6 +508,7 @@ jobs: whl=$(ls -t dist/*.gz | head -n 1 | xargs basename) echo "WHL_NAME=$whl" >> $GITHUB_ENV twine check dist/$whl + - name: Upload to artifact uses: actions/upload-artifact@v4 with: @@ -516,6 +528,7 @@ jobs: if: (github.event_name == 'release' || github.event.inputs.upload_pypi == 'true') && !cancelled() run: | for i in {1..5}; do sleep 5; done + - name: Upload sdist to pypi if: (github.event_name == 'release' || github.event.inputs.upload_pypi == 'true') && !cancelled() env: From 7ddaf889c20fc0cb318aceec86e4d1651fe5c2b3 Mon Sep 17 00:00:00 2001 From: CSY-ModelCloud Date: Wed, 22 Oct 2025 10:13:39 +0800 Subject: [PATCH 2/5] [CI] auto mkdir for cutlass --- .github/workflows/release.yml | 6 ------ gptqmodel_ext/machete/generate.py | 2 ++ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e4beb7050..7da1cc520 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -311,8 +311,6 @@ jobs: - name: Compile if: env.SHOULD_RUN == 1 run: | - mkdir -p cutlass/python || true - python gptqmodel_ext/machete/generate.py python setup.py bdist_wheel - name: Test install @@ -399,8 +397,6 @@ jobs: - name: Compile run: | - mkdir -p cutlass/python || true - python gptqmodel_ext/machete/generate.py python -m build --no-isolation --sdist - name: Check dist @@ -497,8 +493,6 @@ jobs: - name: Compile run: | - mkdir -p cutlass/python || true - python gptqmodel_ext/machete/generate.py python -m build --no-isolation --sdist diff --git a/gptqmodel_ext/machete/generate.py b/gptqmodel_ext/machete/generate.py index bea0bddda..52bd805de 100644 --- a/gptqmodel_ext/machete/generate.py +++ b/gptqmodel_ext/machete/generate.py @@ -26,6 +26,8 @@ _CUTLASS_PYTHON_DIR = _CUTLASS_ROOT / "python" +_CUTLASS_PYTHON_DIR.mkdir(parents=True, exist_ok=True) + if str(_CUTLASS_EXT_DIR) not in sys.path: sys.path.append(str(_CUTLASS_EXT_DIR)) if _CUTLASS_PYTHON_DIR.exists() and str(_CUTLASS_PYTHON_DIR) not in sys.path: From eccb7d132a0426aabdfeeecaa2fc794dd2d95a38 Mon Sep 17 00:00:00 2001 From: CSY-ModelCloud Date: Wed, 22 Oct 2025 10:21:05 +0800 Subject: [PATCH 3/5] remove duplicated codes --- setup.py | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/setup.py b/setup.py index 1234b3bd2..571bbacb2 100644 --- a/setup.py +++ b/setup.py @@ -641,33 +641,6 @@ def _hipify_compile_flags(flags): ) ] - if BUILD_MACHETE and HAS_CUDA_V9 and _version_geq(NVCC_VERSION, 12, 0): - machete_dir = Path("gptqmodel_ext/machete") - machete_generated_dir = machete_dir / "generated" - - machete_sources = [str(machete_dir / "machete_pytorch.cu")] - machete_generated_sources = sorted(machete_generated_dir.glob("*.cu")) - - if not machete_generated_sources: - raise RuntimeError( - "No generated machete kernel templates detected. Run gptqmodel_ext/machete/generate.py" - " with CUTLASS checkout before building." - ) - - machete_sources += [str(path) for path in machete_generated_sources] - - machete_include_dirs = [str(Path("gptqmodel_ext").resolve())] + [str(path) for path in cutlass_include_paths] - - extensions += [ - cpp_ext.CUDAExtension( - "gptqmodel_machete_kernels", - machete_sources, - extra_link_args=extra_link_args, - extra_compile_args=extra_compile_args, - include_dirs=machete_include_dirs, - ) - ] - if BUILD_QQQ: extensions += [ cpp_ext.CUDAExtension( From 1c2e6bc2e1028ac3f0f2e200381f7b1f731c69b9 Mon Sep 17 00:00:00 2001 From: CSY-ModelCloud Date: Wed, 22 Oct 2025 10:24:59 +0800 Subject: [PATCH 4/5] call generate first --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 571bbacb2..a12cf23ee 100644 --- a/setup.py +++ b/setup.py @@ -615,6 +615,7 @@ def _hipify_compile_flags(flags): ] if BUILD_MACHETE and HAS_CUDA_V9 and _version_geq(NVCC_VERSION, 12, 0): + subprocess.run(["python", "gptqmodel_ext/machete/generate.py"]) machete_dir = Path("gptqmodel_ext/machete") machete_generated_dir = machete_dir / "generated" From 2b8f17cd27cbc9b8f2047c318904261574d3446f Mon Sep 17 00:00:00 2001 From: CSY-ModelCloud Date: Wed, 22 Oct 2025 10:50:05 +0800 Subject: [PATCH 5/5] handle error --- setup.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a12cf23ee..f9a5027e3 100644 --- a/setup.py +++ b/setup.py @@ -615,7 +615,20 @@ def _hipify_compile_flags(flags): ] if BUILD_MACHETE and HAS_CUDA_V9 and _version_geq(NVCC_VERSION, 12, 0): - subprocess.run(["python", "gptqmodel_ext/machete/generate.py"]) + try: + result = subprocess.run( + [sys.executable, "gptqmodel_ext/machete/generate.py"], + check=True, + text=True, + capture_output=True + ) + except subprocess.CalledProcessError as e: + raise RuntimeError( + f"Error generating machete kernel templates:\n" + f"Return code: {e.returncode}\n" + f"Stderr: {e.stderr}\n" + f"Stdout: {e.stdout}" + ) machete_dir = Path("gptqmodel_ext/machete") machete_generated_dir = machete_dir / "generated"