From d18df18499c5acb277a8132bad44b53d7e41de4d Mon Sep 17 00:00:00 2001 From: WeiJie_Hong <1462519292@qq.com> Date: Wed, 28 Jan 2026 17:58:46 +0800 Subject: [PATCH] [CI/Build] update .pre-commit-config.yaml && add _pylint.yml && update installation.md (#155) Signed-off-by: WeiJie_Hong <1462519292@qq.com> --- .github/workflows/_pylint.yml | 54 +++++++++ .pre-commit-config.yaml | 216 +++++++++++++++++----------------- docs/Dockerfile.xpu | 2 +- docs/source/installation.md | 38 ++++++ 4 files changed, 198 insertions(+), 112 deletions(-) create mode 100644 .github/workflows/_pylint.yml diff --git a/.github/workflows/_pylint.yml b/.github/workflows/_pylint.yml new file mode 100644 index 0000000..b8fcfdd --- /dev/null +++ b/.github/workflows/_pylint.yml @@ -0,0 +1,54 @@ +name: Code Style Check + +on: + pull_request: + push: + branches: [ main ] + +jobs: + lint: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-python@v5 + with: + python-version: "3.10" + + - name: Install tools + run: | + pip install black isort ruff + + - name: Get changed python files + id: changed + shell: bash + run: | + if [ "${{ github.event_name }}" = "pull_request" ]; then + files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD) + else + files=$(git diff --name-only HEAD~1...HEAD) + fi + + files=$(echo "$files" | grep '\.py$' || true) + + echo "files<> $GITHUB_OUTPUT + echo "$files" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Run black + if: steps.changed.outputs.files != '' + run: | + black --check ${{ steps.changed.outputs.files }} + + - name: Run isort + if: steps.changed.outputs.files != '' + run: | + isort --check-only ${{ steps.changed.outputs.files }} + + - name: Run ruff + if: steps.changed.outputs.files != '' + run: | + ruff check ${{ steps.changed.outputs.files }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d3a2a98..3c11c09 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,112 +1,106 @@ -default_install_hook_types: - - pre-commit - - commit-msg -default_stages: - - pre-commit # Run locally - - manual # Run in CI -exclude: 'examples/.*' # Exclude examples from all hooks by default +# Global configuration +default_install_hook_types: # Default hook types to install + - pre-commit # Pre-commit checks + - commit-msg # Commit message checks +default_stages: # Default run stages + - pre-commit # Run on local commits + - manual # Run manually in CI only +exclude: 'examples/.*' # Path patterns to exclude from checks repos: -# - repo: https://github.com/codespell-project/codespell -# rev: v2.4.1 -# hooks: -# - id: codespell -# args: [ -# --toml, pyproject.toml, -# '--skip', 'vllm_kunlun/csrc/**,tests/**,.github/**,', -# '-L', '' -# ] -# additional_dependencies: -# - tomli -- repo: https://github.com/google/yapf - rev: v0.43.0 - hooks: - - id: yapf - args: [--in-place, --verbose] - # Keep the same list from yapfignore here to avoid yapf failing without any inputs - exclude: '(.github|benchmarks|examples|docs)/.*' -- repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.11.7 - hooks: - - id: ruff - args: [--output-format, github, --fix] - - id: ruff-format - files: ^(benchmarks|examples)/.* -- repo: https://github.com/crate-ci/typos - rev: v1.32.0 - hooks: - - id: typos - args: [ - "--force-exclude", - "--exclude", "vllm_kunlun/csrc/**" - ] -- repo: https://github.com/PyCQA/isort - rev: 6.0.1 - hooks: - - id: isort -- repo: https://github.com/jackdewinter/pymarkdown - rev: v0.9.29 - hooks: - - id: pymarkdown - args: [fix] -- repo: https://github.com/rhysd/actionlint - rev: v1.7.7 - hooks: - - id: actionlint -- repo: local - hooks: - # - id: mypy-3.10 # TODO: Use https://github.com/pre-commit/mirrors-mypy when mypy setup is less awkward - # name: Run mypy for Python 3.10 - # entry: tools/mypy.sh 1 "3.10" - # # Use system python because vllm installation is required - # language: system - # types: [python] - # stages: [manual] # Only run in CI - # - id: mypy-3.11 # TODO: Use https://github.com/pre-commit/mirrors-mypy when mypy setup is less awkward - # name: Run mypy for Python 3.11 - # entry: tools/mypy.sh 1 "3.11" - # # Use system python because vllm installation is required - # language: system - # types: [python] - # stages: [manual] # Only run in CI - # - id: mypy-3.12 # TODO: Use https://github.com/pre-commit/mirrors-mypy when mypy setup is less awkward - # name: Run mypy for Python 3.12 - # entry: tools/mypy.sh 1 "3.12" - # # Use system python because vllm installation is required - # language: system - # types: [python] - # stages: [manual] # Only run in CI - - id: signoff-commit - name: Sign-off Commit - entry: bash - args: - - -c - - | - if ! grep -q "^Signed-off-by: $(git config user.name) <$(git config user.email)>" "$(git rev-parse --git-path COMMIT_EDITMSG)"; then - printf "\nSigned-off-by: $(git config user.name) <$(git config user.email)>\n" >> "$(git rev-parse --git-path COMMIT_EDITMSG)" - fi - language: system - verbose: true - stages: [commit-msg] - - id: check-filenames - name: Check for spaces in all filenames - entry: bash - args: - - -c - - 'git ls-files | grep " " && echo "Filenames should not contain spaces!" && exit 1 || exit 0' - language: system - always_run: true - pass_filenames: false - # - id: python-init - # name: Enforce __init__.py in Python packages - # entry: python tools/check_python_src_init.py - # language: python - # types: [python] - # pass_filenames: false - # Keep `suggestion` last - - id: suggestion - name: Suggestion - entry: bash -c 'echo "To bypass pre-commit hooks, add --no-verify to git commit."' - language: system - verbose: true - pass_filenames: false - # Insert new entries above the `suggestion` entry \ No newline at end of file + # ----------------------- + # Basic file format checks + # ----------------------- + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 # Use fixed version for stability + hooks: + - id: end-of-file-fixer # Ensure files end with newline + - id: trailing-whitespace # Remove trailing whitespace + - id: check-yaml # Check YAML syntax + - id: check-toml # Check TOML syntax + - id: check-added-large-files # Prevent accidental addition of large files + args: ["--maxkb=10240"] # Maximum allowed file size (10MB) + + # ----------------------- + # Python import sorting (compatible with black) + # ----------------------- + - repo: https://github.com/pycqa/isort + rev: 5.13.2 # Version lock + hooks: + - id: isort + args: ["--profile=black"] # Use black-compatible configuration + # Auto-fix import sorting: + # 1. Standard library imports + # 2. Third-party library imports + # 3. Local application/library specific imports + # Separated by blank lines between groups + + # ----------------------- + # Python code formatting (Black) + # ----------------------- + - repo: https://github.com/psf/black + rev: 26.1.0 # Black version + hooks: + - id: black + language_version: python3 # Specify Python version + # Black characteristics: + # - Strict code formatting + # - Unconfigurable (very few exceptions) + # - Fast execution + # - Produces uniform code style + + # ----------------------- + # Python Linting (Ruff) + # Characteristics: Fast, suitable for CI, replaces flake8/isort/etc. + # ----------------------- + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.14.14 # Ruff version + hooks: + - id: ruff-check # Main linting checks + types_or: [ python, pyi ] # Check .py and .pyi files + args: [ --fix ] # Auto-fix fixable issues + # Checks include: + # - Unused imports/variables + # - Syntax errors + # - Code style issues + # - Potential bugs + - repo: https://github.com/jackdewinter/pymarkdown + rev: v0.9.29 + hooks: + - id: pymarkdown + args: [fix] + - repo: https://github.com/rhysd/actionlint + rev: v1.7.7 + hooks: + - id: actionlint + + - repo: local + hooks: + - id: signoff-commit + name: Sign-off Commit + entry: bash + args: + - -c + - | + if ! grep -q "^Signed-off-by: $(git config user.name) <$(git config user.email)>" "$(git rev-parse --git-path COMMIT_EDITMSG)"; then + printf "\nSigned-off-by: $(git config user.name) <$(git config user.email)>\n" >> "$(git rev-parse --git-path COMMIT_EDITMSG)" + fi + language: system + verbose: true + stages: [commit-msg] + + - id: check-filenames + name: Check for spaces in all filenames + entry: bash + args: + - -c + - 'git ls-files | grep " " && echo "Filenames should not contain spaces!" && exit 1 || exit 0' + language: system + always_run: true + pass_filenames: false + + - id: suggestion + name: Suggestion + entry: bash -c 'echo "To bypass pre-commit hooks, add --no-verify to git commit."' + language: system + verbose: true + pass_filenames: false diff --git a/docs/Dockerfile.xpu b/docs/Dockerfile.xpu index 8f50bd6..90a7b9d 100644 --- a/docs/Dockerfile.xpu +++ b/docs/Dockerfile.xpu @@ -79,7 +79,7 @@ COPY xre-Linux-x86_64-5.2.0.0/ /workspace/xre-Linux-x86_64-5.2.0.0/ RUN mv /workspace/xre-Linux-x86_64-5.2.0.0/bin/* /usr/local/bin/ && mv /workspace/xre-Linux-x86_64-5.2.0.0/so/* /lib/x86_64-linux-gnu/ && \ rm -rf /workspace/xre-Linux-x86_64-5.2.0.0/ - ENV LD_LIBRARY_PATH=/opt/vllm_kunlun/lib:/opt/vllm_kunlun/lib64:/lib/x86_64-linux-gnu/:/opt/vllm_kunlun/xcudart/lib/ +ENV LD_LIBRARY_PATH=/opt/vllm_kunlun/lib:/opt/vllm_kunlun/lib64:/lib/x86_64-linux-gnu/:/opt/vllm_kunlun/xcudart/lib/ RUN rm -rf \ /root/.cache \ diff --git a/docs/source/installation.md b/docs/source/installation.md index f954847..fab5284 100644 --- a/docs/source/installation.md +++ b/docs/source/installation.md @@ -112,3 +112,41 @@ python -m vllm.entrypoints.openai.api_server \ ``` :::: ::::: + + +### xpytorch and ops install +We also provide xpytorch and ops link for custom installation. + +### Replace eval_frame.py +Copy the eval_frame.py patch: +``` +cp vllm_kunlun/patches/eval_frame.py /root/miniconda/envs/vllm_kunlun_0.10.1.1/lib/python3.10/site-packages/torch/_dynamo/eval_frame.py +``` +## Install the KL3-customized build of PyTorch +``` +wget -O xpytorch-cp310-torch251-ubuntu2004-x64.run https://baidu-kunlun-public.su.bcebos.com/v1/baidu-kunlun-share/1130/xpytorch-cp310-torch251-ubuntu2004-x64.run?authorization=bce-auth-v1%2FALTAKypXxBzU7gg4Mk4K4c6OYR%2F2025-12-02T05%3A01%3A27Z%2F-1%2Fhost%2Ff3cf499234f82303891aed2bcb0628918e379a21e841a3fac6bd94afef491ff7 +bash xpytorch-cp310-torch251-ubuntu2004-x64.run +``` +## Install the KL3-customized build of PyTorch(Only MIMO V2) +``` +wget -O xpytorch-cp310-torch251-ubuntu2004-x64.run https://klx-sdk-release-public.su.bcebos.com/kunlun2aiak_output/1231/xpytorch-cp310-torch251-ubuntu2004-x64.run +bash xpytorch-cp310-torch251-ubuntu2004-x64.run +``` + +## Install custom ops +``` +pip install "https://baidu-kunlun-public.su.bcebos.com/v1/baidu-kunlun-share/1130/xtorch_ops-0.1.2209%2B6752ad20-cp310-cp310-linux_x86_64.whl?authorization=bce-auth-v1%2FALTAKypXxBzU7gg4Mk4K4c6OYR%2F2025-12-05T06%3A18%3A00Z%2F-1%2Fhost%2F14936c2b7e7c557c1400e4c467c79f7a9217374a7aa4a046711ac4d948f460cd" +``` +## Install custom ops(Only MIMO V2) +``` +pip install "https://vllm-ai-models.bj.bcebos.com/v1/vLLM-Kunlun/ops/swa/xtorch_ops-0.1.2109%252B523cb26d-cp310-cp310-linux_x86_64.whl" +``` + +## Install the KLX3 custom Triton build +``` +pip install "https://cce-ai-models.bj.bcebos.com/v1/vllm-kunlun-0.11.0/triton-3.0.0%2Bb2cde523-cp310-cp310-linux_x86_64.whl" +``` +## Install the AIAK custom ops library +``` +pip install "https://cce-ai-models.bj.bcebos.com/XSpeedGate-whl/release_merge/20251219_152418/xspeedgate_ops-0.0.0-cp310-cp310-linux_x86_64.whl" +```