Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
117 changes: 78 additions & 39 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,77 +1,116 @@
# Offline-friendly config: all hooks are `repo: local` and install via pip
# (internal PyPI / mirrors). Avoids cloning github.com which is unreachable
# on many GPU clusters.
files: >
(?x)^(
xtuner/v1/.* |
autotest/.*
)$
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
- repo: local
hooks:
- id: check-yaml
name: check-yaml
entry: check-yaml
language: python
types: [yaml]
additional_dependencies: ["pre-commit-hooks==5.0.0"]
- id: requirements-txt-fixer
name: requirements-txt-fixer
entry: requirements-txt-fixer
language: python
types: [text]
files: requirements.*\.txt$
additional_dependencies: ["pre-commit-hooks==5.0.0"]
- id: check-merge-conflict
name: check-merge-conflict
entry: check-merge-conflict
language: python
additional_dependencies: ["pre-commit-hooks==5.0.0"]
- id: mixed-line-ending
name: mixed-line-ending
entry: mixed-line-ending
language: python
args: ["--fix=lf"]
- repo: https://github.com/codespell-project/codespell
rev: v2.2.1
hooks:
additional_dependencies: ["pre-commit-hooks==5.0.0"]

- id: codespell
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.9
hooks:
name: codespell
entry: codespell
language: python
types: [text]
additional_dependencies: ["codespell==2.2.1"]

- id: mdformat
name: mdformat
entry: mdformat
language: python
types: [markdown]
args: ["--number"]
additional_dependencies:
- mdformat==0.7.9
- mdformat-openmmlab
- mdformat_frontmatter
- linkify-it-py
exclude: 'docs/zh_cn/user_guides/sequence_parallel.md'
- repo: https://github.com/myint/docformatter
rev: 06907d0
hooks:

- id: docformatter
name: docformatter
entry: docformatter
language: python
types: [python]
args: ["--in-place", "--wrap-descriptions", "119"]
- repo: https://github.com/asottile/pyupgrade
rev: v3.20.0
hooks:
additional_dependencies: ["docformatter==1.7.5"]

- id: pyupgrade
name: pyupgrade
entry: pyupgrade
language: python
types: [python]
args: ["--py36-plus"]
additional_dependencies: ["pyupgrade==3.20.0"]

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.9.10
hooks:
# Run the linter.
- id: ruff
types_or: [ python, pyi ]
args: [ --diff ]
- id: ruff
types_or: [ python, pyi ]
args: [ --fix ]
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi ]
args: [ --diff ]
name: ruff
entry: ruff check --force-exclude
language: python
types_or: [python, pyi]
args: [--diff]
additional_dependencies: ["ruff==0.9.10"]
- id: ruff-fix
name: ruff-fix
entry: ruff check --force-exclude
language: python
types_or: [python, pyi]
args: [--fix]
additional_dependencies: ["ruff==0.9.10"]
- id: ruff-format-diff
name: ruff-format
entry: ruff format --force-exclude
language: python
types_or: [python, pyi]
args: [--diff]
additional_dependencies: ["ruff==0.9.10"]
- id: ruff-format
types_or: [ python, pyi ]
- repo: local
# We do not use pre-commit/mirrors-mypy,
# as it comes with opinionated defaults
# (like --ignore-missing-imports)
# and is difficult to configure to run
# with the dependencies correctly installed.
hooks:
name: ruff-format
entry: ruff format --force-exclude
language: python
types_or: [python, pyi]
additional_dependencies: ["ruff==0.9.10"]

# We do not use pre-commit/mirrors-mypy (opinionated defaults).
# Torch is intentionally not pinned here: installing it into the hook
# env is heavy; missing third-party imports are ignored via pyproject.
- id: mypy
name: mypy
entry: .dev_scripts/mypy_entrypoint.sh
language: python
# For 3rd party lib, we only do type check for torch
additional_dependencies: ["mypy==1.16.1", "torch==2.6.0", "types-requests"]
additional_dependencies: ["mypy==1.16.1", "types-requests"]
require_serial: true
verbose: true
types: [python]
- id: pydantic-extra-check
name: pydantic-extra-check
name: pydantic-extra-check
language: system
entry: .dev_scripts/test_pydantic.py
verbose: false
59 changes: 47 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1.10.0
# builder
ARG BASE_IMAGE=nvcr.io/nvidia/pytorch:25.03-py3
ARG BASE_IMAGE=nvcr.io/nvidia/pytorch:25.11-py3

## build base env
FROM ${BASE_IMAGE} AS setup_env
Expand All @@ -21,14 +21,24 @@ RUN if [ -d /etc/pip ] && [ -f /etc/pip/constraint.txt ]; then echo > /etc/pip/c
RUN pip uninstall flash_attn opencv -y && rm -rf /usr/local/lib/python3.12/dist-packages/cv2
RUN git config --system --add safe.directory "*"

ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
ffmpeg \
libavutil-dev \
libavcodec-dev \
libavformat-dev \
libswscale-dev


# torch
ARG TORCH_VERSION
ARG PYTORCH_WHEELS_URL
RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
--mount=type=secret,id=NO_PROXY,env=no_proxy \
if [ -n "${TORCH_VERSION}" ]; then \
pip install torchvision torch==${TORCH_VERSION} \
-i ${PYTORCH_WHEELS_URL}/cu128 \
-i ${PYTORCH_WHEELS_URL}/cu130 \
--extra-index-url ${PYTORCH_WHEELS_URL}/cu128 \
--extra-index-url ${PYTORCH_WHEELS_URL}/cu126 \
--no-cache-dir; \
fi
Expand Down Expand Up @@ -58,17 +68,31 @@ ARG FLASH_ATTN_URL
# force hopper for now, you change it throught build args
ARG FLASH_ATTN_CUDA_ARCHS="90"
ARG FLASH_ATTENTION_DISABLE_SM80="TRUE"
ARG FLASH_ATTENTION_OFFLINE_BUILD="TRUE"

RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
git clone $(echo ${FLASH_ATTN_URL} | cut -d '@' -f 1) && \
cd ${CODESPACE}/flash-attention && \
mkdir -p ${CODESPACE}/flash-attention/third_party/nvidia/backend/bin && \
ln -snf ${CUDA_HOME:-/usr/local/cuda}/bin/nvcc ${CODESPACE}/flash-attention/third_party/nvidia/backend/bin/nvcc && \
git checkout $(echo ${FLASH_ATTN_URL} | cut -d '@' -f 2) && \
git submodule update --init --recursive --force

WORKDIR ${CODESPACE}/flash-attention

RUN cd hopper && FLASH_ATTENTION_FORCE_BUILD=TRUE pip wheel -w ${FLASH_ATTN3_DIR} -v --no-deps .
RUN FLASH_ATTENTION_FORCE_BUILD=TRUE pip wheel -w ${FLASH_ATTN_DIR} -v --no-deps .
# CUDA 13 moves CCCL headers into include/cccl, which is missing from default host include paths
# nvcc 13 falls back to PATH lookup for cicc when invoked from third_party/nvidia/backend
RUN export PATH="${CUDA_HOME:-/usr/local/cuda}/nvvm/bin:${PATH}" && \
CUDA_MAJOR="$(python -c 'import torch; print(torch.version.cuda.split(".", 1)[0])')" && \
if [ "${CUDA_MAJOR}" = "13" ]; then \
export CPLUS_INCLUDE_PATH="${CUDA_HOME:-/usr/local/cuda}/include/cccl":${CPLUS_INCLUDE_PATH}; \
fi && \
cd hopper && FLASH_ATTENTION_FORCE_BUILD=TRUE pip wheel --no-build-isolation -w ${FLASH_ATTN3_DIR} -v --no-deps .
RUN CUDA_MAJOR="$(python -c 'import torch; print(torch.version.cuda.split(".", 1)[0])')" && \
if [ "${CUDA_MAJOR}" = "13" ]; then \
export CPLUS_INCLUDE_PATH="${CUDA_HOME:-/usr/local/cuda}/include/cccl":${CPLUS_INCLUDE_PATH}; \
fi && \
FLASH_ATTENTION_FORCE_BUILD=TRUE pip wheel --no-build-isolation -w ${FLASH_ATTN_DIR} -v --no-deps .

# compile adaptive_gemm
FROM setup_env AS adaptive_gemm
Expand All @@ -85,7 +109,7 @@ RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \

WORKDIR ${CODESPACE}/AdaptiveGEMM

RUN pip wheel -w ${ADAPTIVE_GEMM_DIR} -v --no-deps .
RUN pip wheel --no-build-isolation -w ${ADAPTIVE_GEMM_DIR} -v --no-deps .

# compile grouped_gemm(permute and unpermute)
FROM setup_env AS grouped_gemm
Expand All @@ -102,7 +126,7 @@ RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \

WORKDIR ${CODESPACE}/GroupedGEMM

RUN pip wheel -w ${GROUPED_GEMM_DIR} -v --no-deps .
RUN pip wheel --no-build-isolation -w ${GROUPED_GEMM_DIR} -v --no-deps .

# compile causal_conv1d
FROM setup_env AS causal_conv1d
Expand All @@ -119,7 +143,7 @@ RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \

WORKDIR ${CODESPACE}/causal-conv1d

RUN CAUSAL_CONV1D_FORCE_BUILD=TRUE pip wheel -w ${CAUSAL_CONV1D_DIR} -v --no-deps --no-build-isolation .
RUN CAUSAL_CONV1D_FORCE_BUILD=TRUE pip wheel --no-build-isolation -w ${CAUSAL_CONV1D_DIR} -v --no-deps .

# compile nvshmem and deepep
FROM setup_env AS deep_ep
Expand Down Expand Up @@ -156,8 +180,17 @@ RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
WORKDIR ${CODESPACE}/DeepEP

RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
(pip show nvidia-nvshmem-cu12 >/dev/null 2>&1 || pip install nvidia-nvshmem-cu12==3.4.5) && \
pip wheel -w ${DEEP_EP_DIR} -v --no-deps .
CUDA_MAJOR="$(python -c 'import torch; print(torch.version.cuda.split(".", 1)[0])')" && \
if [ "${CUDA_MAJOR}" = "13" ]; then \
pip show nvidia-nvshmem-cu13 >/dev/null 2>&1 || pip install nvidia-nvshmem-cu13==3.4.5; \
export CPLUS_INCLUDE_PATH="${CUDA_HOME:-/usr/local/cuda}/include/cccl":${CPLUS_INCLUDE_PATH}; \
elif [ "${CUDA_MAJOR}" = "12" ]; then \
pip show nvidia-nvshmem-cu12 >/dev/null 2>&1 || pip install nvidia-nvshmem-cu12==3.4.5; \
else \
echo "Unsupported CUDA major version: ${CUDA_MAJOR}" >&2; \
exit 1; \
fi && \
pip wheel --no-build-isolation -w ${DEEP_EP_DIR} -v --no-deps .

# compile deep_gemm
FROM setup_env AS deep_gemm
Expand All @@ -174,7 +207,7 @@ RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \

WORKDIR ${CODESPACE}/DeepGEMM

RUN pip wheel -w ${DEEP_GEMM_DIR} -v --no-deps .
RUN pip wheel --no-build-isolation -w ${DEEP_GEMM_DIR} -v --no-deps .

# integration xtuner
FROM setup_env AS xtuner_dev
Expand Down Expand Up @@ -259,13 +292,15 @@ RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \

# nccl update for torch 2.6.0
# RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
RUN if [ "x${TORCH_VERSION}" = "x2.6.0" ]; then \
RUN if [ "x${TORCH_VERSION}" = "x2.6.0" ] && \
pip show nvidia-nccl-cu12 >/dev/null 2>&1; then \
pip install nvidia-nccl-cu12==2.25.1 --no-cache-dir -i ${DEFAULT_PYPI_URL}; \
fi

# cudnn update for torch 2.9.1
# RUN --mount=type=secret,id=HTTPS_PROXY,env=https_proxy \
RUN if [ "x${TORCH_VERSION}" = "x2.9.1" ]; then \
RUN if [ "x${TORCH_VERSION}" = "x2.9.1" ] && \
pip show nvidia-cudnn-cu12 >/dev/null 2>&1; then \
pip install nvidia-cudnn-cu12==9.15.1.9 --no-cache-dir -i ${DEFAULT_PYPI_URL}; \
fi

Expand Down
2 changes: 1 addition & 1 deletion autotest/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ case:
output_path: /mnt/shared-storage-user/llmrazor-share/qa-llm-cicd/test_output
resource:
memory_per_task: 1200
pip_package: pip install sglang==0.5.10.post1 --timeout 600 --retries 5;pip install transformers==5.2.0 apache-tvm-ffi==0.1.9 nvidia-cudnn-cu12==9.15.1.9;pip uninstall -y nvidia-cutlass-dsl;rm -rf /usr/local/lib/python3.12/dist-packages/nvidia_cutlass_dsl
pip_package: pip install sglang==0.5.10.post1 --timeout 600 --retries 5;pip install transformers==5.14.1 apache-tvm-ffi==0.1.9 nvidia-cudnn-cu12==9.15.1.9;pip uninstall -y nvidia-cutlass-dsl;rm -rf /usr/local/lib/python3.12/dist-packages/nvidia_cutlass_dsl
envs:
- MODEL_PATH=/mnt/shared-storage-user/llmrazor-share/model/Qwen3-30B-A3B
- DATA_PATH=/mnt/shared-storage-user/llmrazor-share/data/gsm8k/train-mini.jsonl
Expand Down
19 changes: 8 additions & 11 deletions image_build.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
export HTTPS_PROXY=$HTTPS_PROXY

export BASE_IMAGE=nvcr.io/nvidia/pytorch:25.03-py3
export BASE_IMAGE=nvcr.io/nvidia/pytorch:25.11-py3
export XTUNER_COMMIT=$(git rev-parse HEAD)
export XTUNER_URL=https://github.com/InternLM/xtuner@${XTUNER_COMMIT}
export FLASH_ATTN_URL=https://github.com/Dao-AILab/flash-attention@060c9188beec3a8b62b33a3bfa6d5d2d44975fab
export ADAPTIVE_GEMM_URL=https://github.com/InternLM/AdaptiveGEMM@10411e08b182e853d0f3ecec4c68bf90c90e309f # fix fp8 dw k_grouped_gemm bug
export ADAPTIVE_GEMM_URL=https://github.com/InternLM/AdaptiveGEMM@c1a0650d3c82a626378fcc76f0022d88b6688245 # fix fp8 dw k_grouped_gemm bug
export GROUPED_GEMM_URL=https://github.com/InternLM/GroupedGEMM@aa5ffb21cb626d6cd61d99fc42958127b0b99be7
export DEEP_EP_URL=https://github.com/deepseek-ai/DeepEP@9af0e0d0e74f3577af1979c9b9e1ac2cad0104ee # v1.2.1
export DEEP_GEMM_URL=https://github.com/deepseek-ai/DeepGEMM@c9f8b34dcdacc20aa746b786f983492c51072870 # v2.1.1.post3
export CAUSAL_CONV1D_URL=https://github.com/Dao-AILab/causal-conv1d@da6dbaa9fd5a919967f14d3fd031da1288ad5025 # v1.6.0
export FLA_URL="${FLA_URL-https://github.com/HAOCHENYE/flash-linear-attention@tmp-tensor-cache}"

export TORCH_VERSION=${TORCH_VERSION:-"2.9.1"}
export LMDEPLOY_URL="${LMDEPLOY_URL:-https://github.com/RunningLeon/lmdeploy@c14f389e9b2346f9835954ed90aefc0a0aac7ad4}"
# export LMDEPLOY_VERSION="0.15.0"
export TORCH_VERSION=${TORCH_VERSION:-"2.12.1"}
export LMDEPLOY_VERSION="0.14.0"
# export LMDEPLOY_URL=https://github.com/InternLM/lmdeploy@efe3b88607756a7ad9411b89627b5ac6ebaa540e
export PPA_SOURCE="https://mirrors.aliyun.com"
export DEFAULT_PYPI_URL=${DEFAULT_PYPI_URL:-"https://mirrors.aliyun.com/pypi/simple"}
# mirror https://download.pytorch.org/whl
Expand All @@ -40,7 +40,7 @@ docker build . \
--build-arg DEEP_GEMM_URL=$DEEP_GEMM_URL \
--build-arg XTUNER_URL=$XTUNER_URL \
--build-arg XTUNER_COMMIT=$XTUNER_COMMIT \
--build-arg LMDEPLOY_URL="$LMDEPLOY_URL" \
--build-arg LMDEPLOY_VERSION=$LMDEPLOY_VERSION \
--progress=plain \
--label "BASE_IMAGE=$BASE_IMAGE" \
--label "XTUNER_URL=${XTUNER_URL/@/\/tree\/}" \
Expand All @@ -52,8 +52,5 @@ docker build . \
--label "FLA_URL=${FLA_URL/@/\/tree\/}" \
--label "DEEP_EP_URL=${DEEP_EP_URL/@/\/tree\/}" \
--label "DEEP_GEMM_URL=${DEEP_GEMM_URL/@/\/tree\/}" \
--label "LMDEPLOY_URL=${LMDEPLOY_URL/@/\/tree\/}"

echo "===== pip list in ${image_name}:${image_tag} ====="
docker run --rm --entrypoint pip "${image_name}:${image_tag}" list

--label "LMDEPLOY_VERSION=$LMDEPLOY_VERSION"
# --label "LMDEPLOY_URL=${LMDEPLOY_URL/@/\/tree\/}"
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ classifiers = [
]
dependencies = [
"astor",
"bitsandbytes==0.45.0",
"datasets<4.0.0",
"einops",
"loguru",
Expand Down Expand Up @@ -77,11 +76,13 @@ rl = [
"pylatexenc"
]
video = [
"torchcodec==0.15.0",
"decord",
"av",
]
all = [
"jsonlines",
"torchcodec==0.15.0",
"decord",
"av",
"ray[default]",
Expand Down
3 changes: 1 addition & 2 deletions requirements/runtime.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
bitsandbytes==0.45.0
datasets<4.0.0
einops
loguru
Expand All @@ -11,7 +10,7 @@ SentencePiece
tiktoken
torch>=2.6.0
torchvision
transformers==4.56.0
transformers==5.14.1
cyclopts
transformers_stream_generator
opencv-python-headless
Expand Down
Loading
Loading