Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions maint/scripts/pypi.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,40 @@ FROM nvidia/cuda:12.1.0-devel-ubuntu18.04

RUN set -eux; \
apt-get update; \
apt-get install -y wget curl libtinfo-dev zlib1g-dev libssl-dev build-essential libedit-dev libxml2-dev git; \
# Install gcc-9 and g++-9
apt-get install -y software-properties-common; \
add-apt-repository ppa:ubuntu-toolchain-r/test -y; \
apt-get update; \
apt-get install -y wget curl libtinfo-dev zlib1g-dev libssl-dev build-essential \
libedit-dev libxml2-dev git gcc-9 g++-9; \
# Switch default gcc/g++ to new version
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100; \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 100; \
update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 100; \
update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 100; \
gcc --version; g++ --version; \
Comment on lines +5 to +16
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

❓ Verification inconclusive

Base OS and toolchain approach is brittle; prefer CUDA 12.1 on Ubuntu 20.04 and drop PPA.

Ubuntu 18.04 is EOL; PPAs for it are unreliable. CUDA 12.1 images exist for ubuntu20.04, which already provide GCC 9.x so you can skip the PPA and alternatives dance.

Apply this diff to simplify and improve reproducibility:

-FROM nvidia/cuda:12.1.0-devel-ubuntu18.04
+FROM nvidia/cuda:12.1.0-devel-ubuntu20.04
@@
-RUN set -eux; \
-    apt-get update; \
-    # Install gcc-9 and g++-9
-    apt-get install -y software-properties-common; \
-    add-apt-repository ppa:ubuntu-toolchain-r/test -y; \
-    apt-get update; \
-    apt-get install -y wget curl libtinfo-dev zlib1g-dev libssl-dev build-essential \
-                       libedit-dev libxml2-dev git gcc-9 g++-9; \
-    # Switch default gcc/g++ to new version
-    update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100; \
-    update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 100; \
-    update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 100; \
-    update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 100; \
-    gcc --version; g++ --version; \
+RUN set -eux; \
+    export DEBIAN_FRONTEND=noninteractive; \
+    apt-get update; \
+    apt-get install -y --no-install-recommends wget curl ca-certificates \
+        libtinfo-dev zlib1g-dev libssl-dev build-essential libedit-dev libxml2-dev git \
+        gcc g++; \
+    gcc --version; g++ --version; \
@@
-    rm Miniconda3-latest-Linux-x86_64.sh;
+    echo "Verifying Miniconda checksum"; \
+    curl -sSLO https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh.sha256; \
+    sha256sum -c Miniconda3-latest-Linux-x86_64.sh.sha256; \
+    rm Miniconda3-latest-Linux-x86_64.sh Miniconda3-latest-Linux-x86_64.sh.sha256; \
+    rm -rf /var/lib/apt/lists/*

Check the CUDA base tag and avoid surprises:


🏁 Script executed:

#!/bin/bash
# Verify the Docker tag exists
curl -s 'https://registry.hub.docker.com/v2/repositories/nvidia/cuda/tags/?page_size=1000' \
| jq -r '.results[].name' | rg -n '^12\.1\.0-devel-ubuntu20\.04$'

Length of output: 0


Switch base to nvidia/cuda:12.1.0-devel-ubuntu20.04 and drop the gcc PPA/update-alternatives. Ubuntu 18.04 moved to ESM on May 31, 2023; NVIDIA provides CUDA 12.1 devel/runtime images for Ubuntu 20.04 and Focal ships GCC 9 by default — so remove the PPA and simplify installs as in the diff below. (lists.ubuntu.com)

Apply this diff to simplify and improve reproducibility:

-FROM nvidia/cuda:12.1.0-devel-ubuntu18.04
+FROM nvidia/cuda:12.1.0-devel-ubuntu20.04
@@
-RUN set -eux; \
-    apt-get update; \
-    # Install gcc-9 and g++-9
-    apt-get install -y software-properties-common; \
-    add-apt-repository ppa:ubuntu-toolchain-r/test -y; \
-    apt-get update; \
-    apt-get install -y wget curl libtinfo-dev zlib1g-dev libssl-dev build-essential \
-                       libedit-dev libxml2-dev git gcc-9 g++-9; \
-    # Switch default gcc/g++ to new version
-    update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100; \
-    update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 100; \
-    update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 100; \
-    update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 100; \
-    gcc --version; g++ --version; \
+RUN set -eux; \
+    export DEBIAN_FRONTEND=noninteractive; \
+    apt-get update; \
+    apt-get install -y --no-install-recommends wget curl ca-certificates \
+        libtinfo-dev zlib1g-dev libssl-dev build-essential libedit-dev libxml2-dev git \
+        gcc g++; \
+    gcc --version; g++ --version; \
@@
-    rm Miniconda3-latest-Linux-x86_64.sh;
+    echo "Verifying Miniconda checksum"; \
+    curl -sSLO https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh.sha256; \
+    sha256sum -c Miniconda3-latest-Linux-x86_64.sh.sha256; \
+    rm Miniconda3-latest-Linux-x86_64.sh Miniconda3-latest-Linux-x86_64.sh.sha256; \
+    rm -rf /var/lib/apt/lists/*
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# Install gcc-9 and g++-9
apt-get install -y software-properties-common; \
add-apt-repository ppa:ubuntu-toolchain-r/test -y; \
apt-get update; \
apt-get install -y wget curl libtinfo-dev zlib1g-dev libssl-dev build-essential \
libedit-dev libxml2-dev git gcc-9 g++-9; \
# Switch default gcc/g++ to new version
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100; \
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 100; \
update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 100; \
update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 100; \
gcc --version; g++ --version; \
# Install build dependencies (no PPA)
export DEBIAN_FRONTEND=noninteractive; \
apt-get update; \
apt-get install -y --no-install-recommends wget curl ca-certificates \
libtinfo-dev zlib1g-dev libssl-dev build-essential \
libedit-dev libxml2-dev git gcc g++; \
gcc --version; g++ --version; \
🤖 Prompt for AI Agents
In maint/scripts/pypi.Dockerfile around lines 5-16, switch the base image to
nvidia/cuda:12.1.0-devel-ubuntu20.04 and remove the ubuntu-toolchain
PPA/add-apt-repository and the update-alternatives calls: run apt-get update
then apt-get install the required packages (wget curl libtinfo-dev zlib1g-dev
libssl-dev build-essential libedit-dev libxml2-dev git gcc-9 g++-9) directly
(Ubuntu 20.04 provides GCC-9), drop the add-apt-repository and all
update-alternatives lines that force gcc/g++ symlinks, and keep a sanity check
like gcc --version; g++ --version after installation.

curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh; \
bash Miniconda3-latest-Linux-x86_64.sh -b -p /miniconda3; \
rm Miniconda3-latest-Linux-x86_64.sh
rm Miniconda3-latest-Linux-x86_64.sh;
Comment on lines 3 to +19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To reduce the Docker image size, it's a good practice to clean up the apt cache after installing packages. You can add apt-get clean && rm -rf /var/lib/apt/lists/* at the end of this RUN command.

RUN set -eux; \
    apt-get update; \
    # Install gcc-9 and g++-9
    apt-get install -y software-properties-common; \
    add-apt-repository ppa:ubuntu-toolchain-r/test -y; \
    apt-get update; \
    apt-get install -y wget curl libtinfo-dev zlib1g-dev libssl-dev build-essential \
                       libedit-dev libxml2-dev git gcc-9 g++-9; \
    # Switch default gcc/g++ to new version
    update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 100; \
    update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 100; \
    update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 100; \
    update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 100; \
    gcc --version; g++ --version; \
    curl -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh; \
    bash Miniconda3-latest-Linux-x86_64.sh -b -p /miniconda3; \
    rm Miniconda3-latest-Linux-x86_64.sh; \
    apt-get clean; \
    rm -rf /var/lib/apt/lists/*;

Comment on lines 17 to +19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Verify Miniconda integrity.

Currently the installer isn’t verified. Above diff adds a sha256 check.

🤖 Prompt for AI Agents
In maint/scripts/pypi.Dockerfile around lines 17 to 19, the Miniconda installer
is downloaded and executed without verifying integrity; update the Dockerfile to
fetch or embed the expected SHA256 hash for the Miniconda installer, compute the
downloaded file's SHA256 (e.g. using sha256sum), compare it against the expected
value and abort the build if they differ, and only then run the installer;
ensure you still remove the installer file afterward and use robust curl flags
(fail/redirect) so failures are detected.


RUN apt-get update && apt-get install -y ninja-build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This ninja-build installation is redundant because ninja is also being added to requirements-build.txt, which will install it via pip. To avoid duplication and rely on a single package management method for this tool, it's recommended to remove this line and let pip handle the installation.


ENV PATH=/miniconda3/bin/:$PATH

# ✅ Accept Anaconda Terms of Service for both required channels
RUN conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main && \
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r

# Create environments
RUN set -eux; \
conda create -n py38 python=3.8 -y; \
conda create -n py39 python=3.9 -y; \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

With the removal of the Python 3.8 environment, the script maint/scripts/docker_pypi_distribute.sh will fail as it explicitly uses python3.8. Please update that script to use one of the available Python versions (e.g., 3.9) to ensure the build process does not break.

conda create -n py310 python=3.10 -y; \
conda create -n py311 python=3.11 -y; \
conda create -n py312 python=3.12 -y; \
ln -s /miniconda3/envs/py38/bin/python3.8 /usr/bin/python3.8; \
ln -s /miniconda3/envs/py39/bin/python3.9 /usr/bin/python3.9; \
ln -s /miniconda3/envs/py310/bin/python3.10 /usr/bin/python3.10; \
ln -s /miniconda3/envs/py311/bin/python3.11 /usr/bin/python3.11; \
ln -s /miniconda3/envs/py312/bin/python3.12 /usr/bin/python3.12; \
conda install -y cmake patchelf

WORKDIR /tilelang
WORKDIR /tilelang
7 changes: 1 addition & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
[build-system]
requires = [
"build",
"cmake>=3.26",
"packaging",
"setuptools>=61",
"torch",
"wheel",
"tox",
"auditwheel",
"patchelf",
"ninja",
"Cython",
"Cython>=3.0.0",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Build System Dependency Inconsistency

Removing ninja from pyproject.toml's build-system.requires could lead to build failures, especially since cmake often depends on it. Its continued presence in requirements-build.txt also creates an inconsistency, suggesting it's still a required build dependency.

Fix in Cursor Fix in Web

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 Analysis chain

Cython 3 floor: verify migration and avoid runtime coupling.

  • Ensure code is Cython 3–clean (language_level=3, no deprecated 0.x/2.x syntax).
  • Keep Cython only in build env; it should not be a runtime dependency.

Run to confirm no runtime pin and check for language_level usage:


🏁 Script executed:

#!/bin/bash
set -euo pipefail
# 1) Cython must NOT be in runtime reqs
rg -nP '^(Cython|cython)\b' requirements*.txt || true
# 2) Ensure cythonize or language_level is set somewhere
rg -nP '(cythonize\(|language_level\s*=)' -n -S -g '!**/build/**' || true
# 3) Inventory .pyx/.pxd files to scope migration risk
fd -t f -e pyx -e pxd -H || true

Length of output: 421


Remove Cython from runtime requirements; make it build-only and enforce Cython‑3.

  • Cython is listed as a runtime dependency: requirements.txt:2 (Cython>=3.0.0) — remove from runtime requirements and keep it only in build deps (requirements-build.txt:2 or pyproject.build-system.requires).
  • Cython sources exist: tilelang/jit/adapter/cython/cython_wrapper.pyx — ensure all .pyx/.pxd are compiled at build time and set language_level=3 (via cythonize(..., language_level=3) or setup.cfg/pyproject).
  • Verify there are no runtime imports of Cython and add an explicit language_level=3 if missing.
🤖 Prompt for AI Agents
In pyproject.toml around line 9, Cython is incorrectly listed as a runtime
dependency; remove "Cython>=3.0.0" from runtime deps and instead add
Cython>=3.0.0 to build-system.requires (or requirements-build.txt) so it is
build-only; ensure all .pyx/.pxd files under tilelang/jit/adapter/cython are
compiled during package build (use cythonize in setup.py/pyproject build backend
or include build steps in pyproject) and explicitly set language_level=3 (via
cythonize(..., language_level=3) or in setup.cfg/pyproject Cython config); audit
code for any runtime imports of Cython and replace them with imports of the
compiled extensions or guard so there are no runtime Cython dependencies.

]
build-backend = "setuptools.build_meta"

Expand Down
3 changes: 2 additions & 1 deletion requirements-build.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Should be mirrored in pyproject.toml
Cython
Cython>=3.0.0
build
cmake>=3.26
packaging
Expand All @@ -9,3 +9,4 @@ wheel
tox
auditwheel
patchelf
ninja
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# runtime requirements
Cython
Cython>=3.0.0
numpy>=1.23.5
tqdm>=4.62.3
typing_extensions>=4.10.0
Expand Down
6 changes: 6 additions & 0 deletions src/tl_templates/cuda/gemm_sm120.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#pragma once

#include "gemm_mma.h"

namespace tl {
using tl_mma::gemm_rs;
using tl_mma::gemm_sr;
using tl_mma::gemm_ss;
} // namespace tl
6 changes: 6 additions & 0 deletions src/tl_templates/cuda/gemm_sm80.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
#pragma once

#include "gemm_mma.h"

namespace tl {
using tl_mma::gemm_rs;
using tl_mma::gemm_sr;
using tl_mma::gemm_ss;
} // namespace tl
6 changes: 6 additions & 0 deletions src/tl_templates/cuda/gemm_sm89.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,9 @@
#include "cuda_fp8.h"

#include "gemm_mma.h"

namespace tl {
using tl_mma::gemm_rs;
using tl_mma::gemm_sr;
using tl_mma::gemm_ss;
} // namespace tl
Loading