diff --git a/.github/workflows/release-whl-kernel.yml b/.github/workflows/release-whl-kernel.yml index 9e6cb3717..3a19fa260 100644 --- a/.github/workflows/release-whl-kernel.yml +++ b/.github/workflows/release-whl-kernel.yml @@ -18,6 +18,7 @@ on: - 'cu129' - 'cu130' - 'rocm700' + - 'rocm720' - 'musa43' tag_name: type: string @@ -223,15 +224,15 @@ jobs: git commit -m "update whl index" git push - build-rocm700: + build-rocm-matrix: if: | github.repository == 'sgl-project/sglang' && - (github.event.inputs.target == 'all' || github.event.inputs.target == 'rocm700') + (github.event.inputs.target == 'all' || github.event.inputs.target == 'rocm700' || github.event.inputs.target == 'rocm720') runs-on: amd-docker-scale strategy: matrix: python-version: ["3.10"] - rocm-version: ["700"] + rocm-version: ["700", "720"] steps: - uses: actions/checkout@v4 with: @@ -245,7 +246,7 @@ jobs: - name: Build wheels run: | - cp 3rdparty/amd/sgl-kernel/* sgl-kernel/ + cp 3rdparty/amd/wheel/sgl-kernel/* sgl-kernel/ cd sgl-kernel chmod +x ./build_rocm.sh ./build_rocm.sh "${{ matrix.rocm-version }}" @@ -257,7 +258,7 @@ jobs: path: sgl-kernel/dist/* release-rocm700: - needs: build-rocm700 + needs: build-rocm-matrix runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -269,7 +270,7 @@ jobs: with: path: sgl-kernel/dist/ merge-multiple: true - pattern: wheel-* + pattern: wheel-*-rocm700 - name: Set tag name id: set_tag_name @@ -307,6 +308,57 @@ jobs: git commit -m "update whl index" git push + release-rocm720: + needs: build-rocm-matrix + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ inputs.pr_number && format('refs/pull/{0}/head', inputs.pr_number) || '' }} + + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + path: sgl-kernel/dist/ + merge-multiple: true + pattern: wheel-*-rocm720 + + - name: Set tag name + id: set_tag_name + run: | + if [ -z "${{ inputs.tag_name }}" ]; then + TAG_NAME="v$(cat sgl-kernel/python/sgl_kernel/version.py | cut -d'"' -f2)" + echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT + else + echo "tag_name=${{ inputs.tag_name }}" >> $GITHUB_OUTPUT + fi + + - name: Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.set_tag_name.outputs.tag_name }} + repository: sgl-project/whl + token: ${{ secrets.GH_PAT_FOR_WHL_RELEASE }} + files: | + sgl-kernel/dist/* + + - name: Clone wheel index + run: git clone https://oauth2:${WHL_TOKEN}@github.com/sgl-project/whl.git sgl-whl + env: + WHL_TOKEN: ${{ secrets.GH_PAT_FOR_WHL_RELEASE }} + + - name: Update wheel index + run: python3 scripts/update_kernel_whl_index.py --rocm 720 + + - name: Push wheel index + run: | + cd sgl-whl + git config --local user.name "sglang-bot" + git config --local user.email "sglangbot@gmail.com" + git add -A + git commit -m "update whl index" + git push + build-musa43: if: | github.repository == 'sgl-project/sglang' && diff --git a/3rdparty/amd/sgl-kernel/build_rocm.sh b/3rdparty/amd/sgl-kernel/build_rocm.sh deleted file mode 100755 index 1022d8bb5..000000000 --- a/3rdparty/amd/sgl-kernel/build_rocm.sh +++ /dev/null @@ -1,123 +0,0 @@ -#!/bin/bash -set -euo pipefail -ROCM_VERSION=$1 - -PYTHON_ROOT_PATH="/opt/venv/bin" -AMDGPU_TARGET="gfx942;gfx950" - -echo "Python root path is: $PYTHON_ROOT_PATH" - -# Get version from git tags -SGLANG_VERSION="v0.5.6" # Default version, will be overridden if git tags are found - -# Fetch tags from origin to ensure we have the latest -if git fetch --tags origin; then - # Get the latest version tag sorted by version number (e.g., v0.5.7) - VERSION_FROM_TAG=$(git tag -l 'v[0-9]*' --sort=-v:refname | head -1) - if [ -n "$VERSION_FROM_TAG" ]; then - SGLANG_VERSION="$VERSION_FROM_TAG" - echo "Using SGLang version from git tags: $SGLANG_VERSION" - else - echo "Warning: No version tags found; using default $SGLANG_VERSION" >&2 - fi -else - echo "Warning: Failed to fetch tags from origin; using default $SGLANG_VERSION" >&2 -fi - -# Default base tags (can be overridden by command line arguments) -DEFAULT_MI30X_BASE_TAG="${SGLANG_VERSION}-rocm700-mi30x" -DEFAULT_MI35X_BASE_TAG="${SGLANG_VERSION}-rocm700-mi35x" - -# Parse command line arguments -MI30X_BASE_TAG="${DEFAULT_MI30X_BASE_TAG}" -MI35X_BASE_TAG="${DEFAULT_MI35X_BASE_TAG}" - -# Detect GPU architecture from the Kubernetes runner hostname -HOSTNAME_VALUE=$(hostname) -GPU_ARCH="mi30x" # default - -# Host names look like: linux-mi35x-gpu-1-xxxxx-runner-zzzzz -if [[ "${HOSTNAME_VALUE}" =~ ^linux-(mi[0-9]+[a-z]*)-gpu-[0-9]+ ]]; then - GPU_ARCH="${BASH_REMATCH[1]}" - echo "Detected GPU architecture from hostname: ${GPU_ARCH}" -else - echo "Warning: could not parse GPU architecture from '${HOSTNAME_VALUE}', defaulting to ${GPU_ARCH}" -fi - -case "${GPU_ARCH}" in - mi35x) - echo "Runner uses ${GPU_ARCH}; will fetch mi35x image." - ;; - mi30x|mi300|mi325) - echo "Runner uses ${GPU_ARCH}; will fetch mi30x image." - GPU_ARCH="mi30x" - ;; - *) - echo "Runner architecture '${GPU_ARCH}' unrecognised; defaulting to mi30x image." >&2 - GPU_ARCH="mi30x" - ;; -esac - -if [[ -f /etc/podinfo/gha-render-devices ]]; then - DEVICE_FLAG=$(cat /etc/podinfo/gha-render-devices) -else - DEVICE_FLAG="--device /dev/dri" -fi - -# Find the latest image -find_latest_image() { - local gpu_arch=$1 - local base_tag days_back image_tag - - case "${gpu_arch}" in - mi30x) base_tag="${MI30X_BASE_TAG}" ;; - mi35x) base_tag="${MI35X_BASE_TAG}" ;; - *) echo "Error: unsupported GPU architecture '${gpu_arch}'" >&2; return 1 ;; - esac - - for days_back in {0..6}; do - image_tag="${base_tag}-$(date -d "${days_back} days ago" +%Y%m%d)" - echo "Checking for image: rocm/sgl-dev:${image_tag}" >&2 - if docker manifest inspect "rocm/sgl-dev:${image_tag}" >/dev/null 2>&1; then - echo "Found available image: rocm/sgl-dev:${image_tag}" >&2 - echo "rocm/sgl-dev:${image_tag}" - return 0 - fi - done - - echo "Error: no ${gpu_arch} image found in the last 7 days for base ${base_tag}" >&2 - echo "Using hard-coded fallback…" >&2 - if [[ "${gpu_arch}" == "mi35x" ]]; then - echo "rocm/sgl-dev:v0.5.3-rocm700-mi35x-20251009" - else - echo "rocm/sgl-dev:v0.5.3-rocm700-mi30x-20251009" - fi -} - -# Pull and run the latest image -IMAGE=$(find_latest_image "${GPU_ARCH}") -echo "Pulling Docker image: ${IMAGE}" -docker pull "${IMAGE}" - -docker run --rm \ - -v $(pwd):/sgl-kernel \ - -e AMDGPU_TARGET="${AMDGPU_TARGET}" \ - ${IMAGE} \ - bash -c " - # Install CMake (version >= 3.26) - Robust Installation - export CMAKE_VERSION_MAJOR=3.31 - export CMAKE_VERSION_MINOR=1 - echo \"Downloading CMake from: https://cmake.org/files/v\${CMAKE_VERSION_MAJOR}/cmake-\${CMAKE_VERSION_MAJOR}.\${CMAKE_VERSION_MINOR}-linux-x86_64.tar.gz\" - wget https://cmake.org/files/v\${CMAKE_VERSION_MAJOR}/cmake-\${CMAKE_VERSION_MAJOR}.\${CMAKE_VERSION_MINOR}-linux-x86_64.tar.gz - tar -xzf cmake-\${CMAKE_VERSION_MAJOR}.\${CMAKE_VERSION_MINOR}-linux-x86_64.tar.gz - mv cmake-\${CMAKE_VERSION_MAJOR}.\${CMAKE_VERSION_MINOR}-linux-x86_64 /opt/cmake - export PATH=/opt/cmake/bin:\$PATH - - ${PYTHON_ROOT_PATH}/pip install --no-cache-dir ninja setuptools wheel numpy uv scikit-build-core && \ - - cd /sgl-kernel && \ - rm -rf CMakeLists.txt && mv CMakeLists_rocm.txt CMakeLists.txt && \ - ${PYTHON_ROOT_PATH}/python rocm_hipify.py && \ - ${PYTHON_ROOT_PATH}/python -m uv build --wheel -Cbuild-dir=build . --color=always --no-build-isolation && \ - ./rename_wheels_rocm.sh -" diff --git a/3rdparty/amd/wheel/README.md b/3rdparty/amd/wheel/README.md new file mode 100644 index 000000000..53d118e44 --- /dev/null +++ b/3rdparty/amd/wheel/README.md @@ -0,0 +1,97 @@ +# sgl-kernel + +Building and releasing sgl-kernel as a wheel is a part of the release workflow. Check [release-whl-kernel.yml](https://github.com/sgl-project/sglang/blob/main/.github/workflows/release-whl-kernel.yml) for details. + +# sglang + +`3rdparty/amd/wheel/sglang/pyproject.toml` is the AMD-specific pyproject for building the `amd-sglang` wheel. It extends `python/pyproject_other.toml` with two ROCm-version extras (`rocm700`, `rocm720`) that pin the matching torch/triton/torchaudio/torchvision/sgl-kernel wheels, and renames the package to `amd-sglang`. + +## Operation to build sglang wheel + +``` +$ git clone https://github.com/sgl-project/sglang.git && cd sglang +$ cp 3rdparty/amd/wheel/sglang/pyproject.toml python/pyproject.toml +$ cd python && python -m build +``` + +## Installation + +### v0.5.9 + +ROCm 7.0.0: +``` +pip uninstall sgl-kernel sglang amd-sglang +pip install "amd-sglang[all-hip,rocm700]" -i https://pypi.amd.com/rocm-7.0.0/simple --extra-index-url https://pypi.org/simple +``` + +ROCm 7.2.0: +``` +pip uninstall sgl-kernel sglang amd-sglang +pip install "amd-sglang[all-hip,rocm720]" -i https://pypi.amd.com/rocm-7.2.0/simple --extra-index-url https://pypi.org/simple +``` + +Note: You must resolve the two dependencies, AITER and triton, below. Others are optional depending on your applications. + +## Manual Dependency Resolution + +### Resolving AITER + +[AITER](https://github.com/ROCm/aiter) is a fundamental dependency. Wheel-izing it is ongoing. +Until we can pin it reliably, install it manually (typically following the [ROCm docker recipe](https://github.com/sgl-project/sglang/blob/main/docker/rocm.Dockerfile#L106). + +### Revolving triton + +To avoid known issues in triton 3.5.1 installed by default, we recommend upgrading triton after installation. In ROCm 7.0.0 environment, +``` +pip install triton==3.6.0 +``` +or ROCm 7.2.0, +``` +pip install https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/triton-3.6.0%2Brocm7.2.0.gitba5c1517-cp310-cp310-linux_x86_64.whl +``` + +#### `torch._inductor.exc.InductorError: AttributeError: 'KernelMetadata' object has no attribute 'cluster_dims'` + +After upgrading, you may hit this error during inference when PyTorch Inductor interacts with Triton metadata. + +A pragmatic workaround is to guard the metadata access in Inductor's Triton heuristics so it only reads `cluster_dims` when the attribute exists: + +```diff +--- a/opt/venv/lib/python3.10/site-packages/torch/_inductor/runtime/triton_heuristics.py ++++ b/opt/venv/lib/python3.10/site-packages/torch/_inductor/runtime/triton_heuristics.py +@@ -1759,6 +1759,8 @@ + else ( + (binary.metadata.num_ctas, *binary.metadata.cluster_dims) + if hasattr(binary, "metadata") ++ and hasattr(binary.metadata, "num_ctas") ++ and hasattr(binary.metadata, "cluster_dims") + else () + ) + ), +``` + +### Resolving Dependencies for Distributed Inference + +#### sgl-model-gateway + +Install sgl-model-gateway as follows: + +``` +$ apt install openssl libssl-dev protobuf +$ export PATH="/$HOME/.cargo/bin:${PATH}" \ + && curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \ + && rustc --version && cargo --version # Prepare for a rust toolchain +$ python3 -m pip install --no-cache-dir setuptools-rust \ + && cd /sgl-workspace/sglang/sgl-model-gateway/bindings/python \ + && cargo build --release \ + && python3 -m pip install --no-cache-dir . \ + && rm -rf /root/.cache # Build and install sgl-model-gateway +``` + +#### [Mori](https://github.com/sgl-project/sglang/blob/main/docker/rocm.Dockerfile#L381) + +### Resolving Dependencies for DeepSeek-V3.2 + +#### [TileLang](https://github.com/sgl-project/sglang/blob/main/docker/rocm.Dockerfile#L216) + +#### [FHT (fast-hadamard-transform)](https://github.com/sgl-project/sglang/blob/main/docker/rocm.Dockerfile#L300) diff --git a/3rdparty/amd/sgl-kernel/CMakeLists_rocm.txt b/3rdparty/amd/wheel/sgl-kernel/CMakeLists_rocm.txt similarity index 97% rename from 3rdparty/amd/sgl-kernel/CMakeLists_rocm.txt rename to 3rdparty/amd/wheel/sgl-kernel/CMakeLists_rocm.txt index 86ba249c1..eb9f1e40d 100644 --- a/3rdparty/amd/sgl-kernel/CMakeLists_rocm.txt +++ b/3rdparty/amd/wheel/sgl-kernel/CMakeLists_rocm.txt @@ -36,6 +36,7 @@ endif() # ROCm/HIP enable_language(HIP) +list(APPEND CMAKE_PREFIX_PATH "/opt/rocm/lib/cmake/hip-lang") find_package(hip REQUIRED CONFIG) # Determine AMDGPU target from environment variable or default to gfx942 @@ -106,6 +107,7 @@ ${PROJ_ROOT}/csrc/elementwise/pos_enc.hip ${PROJ_ROOT}/csrc/elementwise/topk.hip ${PROJ_ROOT}/csrc/grammar/apply_token_bitmask_inplace_hip.hip ${PROJ_ROOT}/csrc/kvcacheio/transfer.hip +${PROJ_ROOT}/csrc/memory/weak_ref_tensor.cpp ${PROJ_ROOT}/csrc/moe/moe_align_kernel.hip ${PROJ_ROOT}/csrc/moe/moe_topk_softmax_kernels.hip ${PROJ_ROOT}/csrc/moe/moe_topk_sigmoid_kernels.hip diff --git a/3rdparty/amd/wheel/sgl-kernel/build_rocm.sh b/3rdparty/amd/wheel/sgl-kernel/build_rocm.sh new file mode 100755 index 000000000..4347737fa --- /dev/null +++ b/3rdparty/amd/wheel/sgl-kernel/build_rocm.sh @@ -0,0 +1,50 @@ +#!/bin/bash +set -euo pipefail + +ROCM_VERSION=${1:-} + +if [[ "${ROCM_VERSION}" == "700" ]]; then + IMAGE="lmsysorg/sglang:v0.5.8.post1-rocm700-mi35x" +elif [[ "${ROCM_VERSION}" == "720" ]]; then + IMAGE="rocm/pytorch:rocm7.2_ubuntu22.04_py3.10_pytorch_release_2.9.1" +else + echo "ERROR: Unsupported ROCM_VERSION='${ROCM_VERSION}'. Only '700' and '720' are supported." >&2 + exit 1 +fi + +PYTHON_ROOT_PATH="/opt/venv/bin" +AMDGPU_TARGET="gfx942;gfx950" + +# Pull and run the latest image +echo "Pulling Docker image: ${IMAGE}" +docker pull "${IMAGE}" + +docker run --rm \ + -v $(pwd):/sgl-kernel \ + -e AMDGPU_TARGET="${AMDGPU_TARGET}" \ + -e PYTORCH_ROCM_ARCH="${AMDGPU_TARGET}" \ + ${IMAGE} \ + bash -c " + # Install torch, triton, and friends, depending on the ROCm version + if [[ "${ROCM_VERSION}" == "700" ]]; then + ${PYTHON_ROOT_PATH}/pip install https://repo.radeon.com/rocm/manylinux/rocm-rel-7.0.2/torch-2.9.1.dev20251204%2Brocm7.0.2.lw.git351ff442-cp310-cp310-linux_x86_64.whl https://repo.radeon.com/rocm/manylinux/rocm-rel-7.0.2/triton-3.5.1%2Brocm7.0.2.gita272dfa8-cp310-cp310-linux_x86_64.whl https://repo.radeon.com/rocm/manylinux/rocm-rel-7.0.2/torchaudio-2.9.0%2Brocm7.0.2.gite3c6ee2b-cp310-cp310-linux_x86_64.whl https://repo.radeon.com/rocm/manylinux/rocm-rel-7.0.2/torchvision-0.24.0%2Brocm7.0.2.gitb919bd0c-cp310-cp310-linux_x86_64.whl + elif [[ "${ROCM_VERSION}" == "720" ]]; then + ${PYTHON_ROOT_PATH}/pip install https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torch-2.9.1%2Brocm7.2.0.lw.git7e1940d4-cp310-cp310-linux_x86_64.whl https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/triton-3.5.1%2Brocm7.2.0.gita272dfa8-cp310-cp310-linux_x86_64.whl https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchaudio-2.9.0%2Brocm7.2.0.gite3c6ee2b-cp310-cp310-linux_x86_64.whl https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchvision-0.24.0%2Brocm7.2.0.gitb919bd0c-cp310-cp310-linux_x86_64.whl + fi + # Install CMake (version >= 3.26) - Robust Installation + export CMAKE_VERSION_MAJOR=3.31 + export CMAKE_VERSION_MINOR=1 + echo \"Downloading CMake from: https://cmake.org/files/v\${CMAKE_VERSION_MAJOR}/cmake-\${CMAKE_VERSION_MAJOR}.\${CMAKE_VERSION_MINOR}-linux-x86_64.tar.gz\" + wget https://cmake.org/files/v\${CMAKE_VERSION_MAJOR}/cmake-\${CMAKE_VERSION_MAJOR}.\${CMAKE_VERSION_MINOR}-linux-x86_64.tar.gz + tar -xzf cmake-\${CMAKE_VERSION_MAJOR}.\${CMAKE_VERSION_MINOR}-linux-x86_64.tar.gz + mv cmake-\${CMAKE_VERSION_MAJOR}.\${CMAKE_VERSION_MINOR}-linux-x86_64 /opt/cmake + export PATH=/opt/cmake/bin:\$PATH + + ${PYTHON_ROOT_PATH}/pip install --no-cache-dir ninja setuptools wheel numpy uv scikit-build-core && \ + + cd /sgl-kernel && \ + rm -rf CMakeLists.txt && mv CMakeLists_rocm.txt CMakeLists.txt && \ + ${PYTHON_ROOT_PATH}/python rocm_hipify.py && \ + ${PYTHON_ROOT_PATH}/python -m uv build --wheel -Cbuild-dir=build . --color=always --no-build-isolation && \ + ./rename_wheels_rocm.sh +" diff --git a/3rdparty/amd/sgl-kernel/rename_wheels_rocm.sh b/3rdparty/amd/wheel/sgl-kernel/rename_wheels_rocm.sh similarity index 75% rename from 3rdparty/amd/sgl-kernel/rename_wheels_rocm.sh rename to 3rdparty/amd/wheel/sgl-kernel/rename_wheels_rocm.sh index 691407a3e..3c8fb2a63 100755 --- a/3rdparty/amd/sgl-kernel/rename_wheels_rocm.sh +++ b/3rdparty/amd/wheel/sgl-kernel/rename_wheels_rocm.sh @@ -6,6 +6,7 @@ WHEEL_DIR="dist" wheel_files=($WHEEL_DIR/*.whl) for wheel in "${wheel_files[@]}"; do intermediate_wheel="${wheel/linux/manylinux2014}" + [[ "$intermediate_wheel" == *"+rocm"* ]] && continue # Extract the current python version from the wheel name if [[ $intermediate_wheel =~ -cp([0-9]+)- ]]; then @@ -16,11 +17,8 @@ for wheel in "${wheel_files[@]}"; do fi # Detect ROCm version and add appropriate suffix - if ls /opt | grep -q "7.0"; then - new_wheel="${intermediate_wheel/-cp${cp_version}/+rocm700-cp${cp_version}}" - else - new_wheel="$intermediate_wheel" - fi + ver_abrv=$(realpath /opt/rocm-* | sed -e 's/.*-//' -e 's/\.//g') + new_wheel=${intermediate_wheel/-cp${cp_version}/+rocm${ver_abrv}-cp${cp_version}} if [[ "$wheel" != "$new_wheel" ]]; then echo "Renaming $wheel to $new_wheel" diff --git a/3rdparty/amd/sgl-kernel/rocm_hipify.py b/3rdparty/amd/wheel/sgl-kernel/rocm_hipify.py similarity index 96% rename from 3rdparty/amd/sgl-kernel/rocm_hipify.py rename to 3rdparty/amd/wheel/sgl-kernel/rocm_hipify.py index 8373f741d..7383408be 100644 --- a/3rdparty/amd/sgl-kernel/rocm_hipify.py +++ b/3rdparty/amd/wheel/sgl-kernel/rocm_hipify.py @@ -21,6 +21,7 @@ sources = [ "csrc/elementwise/topk.cu", "csrc/grammar/apply_token_bitmask_inplace_cuda.cu", "csrc/kvcacheio/transfer.cu", + "csrc/memory/weak_ref_tensor.cpp", "csrc/moe/moe_align_kernel.cu", "csrc/moe/moe_topk_softmax_kernels.cu", "csrc/moe/moe_topk_sigmoid_kernels.cu", diff --git a/3rdparty/amd/wheel/sglang/pyproject.toml b/3rdparty/amd/wheel/sglang/pyproject.toml new file mode 100644 index 000000000..6c2fc153a --- /dev/null +++ b/3rdparty/amd/wheel/sglang/pyproject.toml @@ -0,0 +1,215 @@ +[build-system] +requires = ["setuptools>=61.0", "setuptools-scm>=8.0", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "amd-sglang" +dynamic = ["version"] +description = "SGLang is a fast serving framework for large language models and vision language models." +readme = "README.md" +requires-python = ">=3.10" +license = { file = "LICENSE" } +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: Apache Software License", +] +dependencies = ["aiohttp", "requests", "tqdm", "numpy", "IPython", "setproctitle"] + +[project.optional-dependencies] +runtime_common = [ + "IPython", + "aiohttp", + "anthropic>=0.20.0", + "blobfile==3.0.0", + "build", + "compressed-tensors", + "decord2", + "datasets", + "einops", + "fastapi", + "gguf", + "hf_transfer", + "huggingface_hub", + "interegular", + "llguidance>=0.7.11,<0.8.0", + "modelscope", + "msgspec", + "ninja", + "numpy", + "openai-harmony==0.0.4", + "openai==2.6.1", + "orjson", + "outlines==0.1.11", + "packaging", + "partial_json_parser", + "pillow", + "prometheus-client>=0.20.0", + "psutil", + "py-spy", + "pybase64", + "pydantic", + "python-multipart", + "pyzmq>=25.1.2", + "requests", + "scipy", + "sentencepiece", + "setproctitle", + "soundfile==0.13.1", + "tiktoken", + "timm==1.0.16", + "torchao==0.9.0", + "tqdm", + "transformers==4.57.1", + "uvicorn", + "uvloop", + "xgrammar==0.1.27", + "smg-grpc-proto>=0.3.3", + "grpcio>=1.78.0", + "grpcio-reflection>=1.78.0", +] + +# ROCm specific packages (https://repo.radeon.com/rocm/manylinux/) +# Existing practice for daily rocm700 docker images relies on 700-rc +# versions of software that are not public available. Here we pin some +# from rocm702 as the closest set as daily rocm700 images. +rocm700 = [ + "torch @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.0.2/torch-2.9.1.dev20251204%2Brocm7.0.2.lw.git351ff442-cp310-cp310-linux_x86_64.whl", + "triton @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.0.2/triton-3.5.1%2Brocm7.0.2.gita272dfa8-cp310-cp310-linux_x86_64.whl", + "torchaudio @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.0.2/torchaudio-2.9.0%2Brocm7.0.2.gite3c6ee2b-cp310-cp310-linux_x86_64.whl", + "torchvision @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.0.2/torchvision-0.24.0%2Brocm7.0.2.gitb919bd0c-cp310-cp310-linux_x86_64.whl", + "mooncake-transfer-engine-non-cuda==0.3.8.post1", + "sgl-kernel @ https://github.com/sgl-project/whl/releases/download/v0.3.21/sgl_kernel-0.3.21+rocm700-cp310-abi3-manylinux2014_x86_64.whl#sha256=2d56ee97d8e6dae29d35a2524de4bffb8e07752bcc74e73313462496427832bf", +] + +rocm720 = [ + "torch @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torch-2.9.1%2Brocm7.2.0.lw.git7e1940d4-cp310-cp310-linux_x86_64.whl", + "triton @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/triton-3.5.1%2Brocm7.2.0.gita272dfa8-cp310-cp310-linux_x86_64.whl", + "torchaudio @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchaudio-2.9.0%2Brocm7.2.0.gite3c6ee2b-cp310-cp310-linux_x86_64.whl", + "torchvision @ https://repo.radeon.com/rocm/manylinux/rocm-rel-7.2/torchvision-0.24.0%2Brocm7.2.0.gitb919bd0c-cp310-cp310-linux_x86_64.whl", + "mooncake-transfer-engine-non-cuda==0.3.8.post1", + "sgl-kernel @ https://github.com/sgl-project/whl/releases/download/v0.3.21/sgl_kernel-0.3.21+rocm720-cp310-abi3-manylinux2014_x86_64.whl#sha256=91a3f50ef0b9d2a140dbf6e2aabff45a50c45a4782b9215997bce6f71749180f", +] + +# HIP (Heterogeneous-computing Interface for Portability) for AMD +# Install with one of: +# pip install "amd-sglang[srt_hip,rocm700]" +# pip install "amd-sglang[srt_hip,rocm720]" +srt_hip = [ + "amd-sglang[runtime_common]", + "petit_kernel==0.0.2", + "wave-lang==3.8.2", +] + +diffusion_hip = [ + "PyYAML==6.0.1", + "cloudpickle", + "diffusers==0.36.0", + "imageio==2.36.0", + "imageio-ffmpeg==0.5.1", + "moviepy>=2.0.0", + "opencv-python-headless==4.10.0.84", + "remote-pdb", + "st_attn==0.0.7", + "vsa==0.0.4", + "runai_model_streamer>=0.15.5", + "cache-dit==1.1.8", + "addict", +] + +# For Intel Gaudi(device : hpu) follow the installation guide +# https://docs.vllm.ai/en/latest/getting_started/gaudi-installation.html +srt_hpu = ["sglang[runtime_common]"] + +# https://docs.sglang.io/platforms/mthreads_gpu.md +srt_musa = [ + "sglang[runtime_common]", + "torch", + "torch_musa", + "torchada>=0.1.25", + "mthreads-ml-py", + "numpy<2.0", +] + +diffusion_musa = [ + "PyYAML==6.0.1", + "cloudpickle", + "diffusers==0.36.0", + "imageio==2.36.0", + "imageio-ffmpeg==0.5.1", + "moviepy>=2.0.0", + "opencv-python-headless==4.10.0.84", + "remote-pdb", + "st_attn==0.0.7", + "vsa==0.0.4", + "runai_model_streamer>=0.15.5", + "cache-dit==1.1.8", + "addict", +] + +tracing = [ + "opentelemetry-sdk", + "opentelemetry-api", + "opentelemetry-exporter-otlp", + "opentelemetry-exporter-otlp-proto-grpc", +] + +test = [ + "accelerate", + "expecttest", + "gguf", + "jsonlines", + "matplotlib", + "pandas", + "peft", + "pytest", + "sentence_transformers", + "tabulate", +] + +all_hip = ["amd-sglang[srt_hip]", "amd-sglang[diffusion_hip]"] +all_hpu = ["sglang[srt_hpu]"] +all_musa = ["sglang[srt_musa]", "sglang[diffusion_musa]"] + +dev_hip = ["amd-sglang[all_hip]", "amd-sglang[test]"] +dev_hpu = ["sglang[all_hpu]", "sglang[test]"] +dev_musa = ["sglang[all_musa]", "sglang[test]"] + +[project.urls] +"Homepage" = "https://github.com/sgl-project/sglang" +"Bug Tracker" = "https://github.com/sgl-project/sglang/issues" + +[project.scripts] +sglang = "sglang.cli.main:main" + +[tool.setuptools.package-data] +"sglang" = [ + "srt/**/*", + "jit_kernel/**/*", +] + +[tool.setuptools.packages.find] +exclude = [ + "assets*", + "benchmark*", + "docs*", + "dist*", + "playground*", + "scripts*", + "tests*", +] + +[tool.wheel] +exclude = [ + "assets*", + "benchmark*", + "docs*", + "dist*", + "playground*", + "scripts*", + "tests*", +] + +[tool.setuptools_scm] +root = ".." +version_file = "sglang/_version.py" +git_describe_command = ["git", "describe", "--tags", "--long", "--match", "v*"]