[CI/Build] update .pre-commit-config.yaml && add _pylint.yml && update installation.md (#155)

Signed-off-by: WeiJie_Hong <1462519292@qq.com>
This commit is contained in:
WeiJie_Hong
2026-01-28 17:58:46 +08:00
committed by GitHub
parent 71bd70ad6c
commit d18df18499
4 changed files with 198 additions and 112 deletions

54
.github/workflows/_pylint.yml vendored Normal file
View File

@@ -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<<EOF" >> $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 }}

View File

@@ -1,112 +1,106 @@
default_install_hook_types: # Global configuration
- pre-commit default_install_hook_types: # Default hook types to install
- commit-msg - pre-commit # Pre-commit checks
default_stages: - commit-msg # Commit message checks
- pre-commit # Run locally default_stages: # Default run stages
- manual # Run in CI - pre-commit # Run on local commits
exclude: 'examples/.*' # Exclude examples from all hooks by default - manual # Run manually in CI only
exclude: 'examples/.*' # Path patterns to exclude from checks
repos: repos:
# - repo: https://github.com/codespell-project/codespell # -----------------------
# rev: v2.4.1 # Basic file format checks
# hooks: # -----------------------
# - id: codespell - repo: https://github.com/pre-commit/pre-commit-hooks
# args: [ rev: v4.6.0 # Use fixed version for stability
# --toml, pyproject.toml, hooks:
# '--skip', 'vllm_kunlun/csrc/**,tests/**,.github/**,', - id: end-of-file-fixer # Ensure files end with newline
# '-L', '' - id: trailing-whitespace # Remove trailing whitespace
# ] - id: check-yaml # Check YAML syntax
# additional_dependencies: - id: check-toml # Check TOML syntax
# - tomli - id: check-added-large-files # Prevent accidental addition of large files
- repo: https://github.com/google/yapf args: ["--maxkb=10240"] # Maximum allowed file size (10MB)
rev: v0.43.0
hooks: # -----------------------
- id: yapf # Python import sorting (compatible with black)
args: [--in-place, --verbose] # -----------------------
# Keep the same list from yapfignore here to avoid yapf failing without any inputs - repo: https://github.com/pycqa/isort
exclude: '(.github|benchmarks|examples|docs)/.*' rev: 5.13.2 # Version lock
- repo: https://github.com/astral-sh/ruff-pre-commit hooks:
rev: v0.11.7 - id: isort
hooks: args: ["--profile=black"] # Use black-compatible configuration
- id: ruff # Auto-fix import sorting:
args: [--output-format, github, --fix] # 1. Standard library imports
- id: ruff-format # 2. Third-party library imports
files: ^(benchmarks|examples)/.* # 3. Local application/library specific imports
- repo: https://github.com/crate-ci/typos # Separated by blank lines between groups
rev: v1.32.0
hooks: # -----------------------
- id: typos # Python code formatting (Black)
args: [ # -----------------------
"--force-exclude", - repo: https://github.com/psf/black
"--exclude", "vllm_kunlun/csrc/**" rev: 26.1.0 # Black version
] hooks:
- repo: https://github.com/PyCQA/isort - id: black
rev: 6.0.1 language_version: python3 # Specify Python version
hooks: # Black characteristics:
- id: isort # - Strict code formatting
- repo: https://github.com/jackdewinter/pymarkdown # - Unconfigurable (very few exceptions)
rev: v0.9.29 # - Fast execution
hooks: # - Produces uniform code style
- id: pymarkdown
args: [fix] # -----------------------
- repo: https://github.com/rhysd/actionlint # Python Linting (Ruff)
rev: v1.7.7 # Characteristics: Fast, suitable for CI, replaces flake8/isort/etc.
hooks: # -----------------------
- id: actionlint - repo: https://github.com/astral-sh/ruff-pre-commit
- repo: local rev: v0.14.14 # Ruff version
hooks: hooks:
# - id: mypy-3.10 # TODO: Use https://github.com/pre-commit/mirrors-mypy when mypy setup is less awkward - id: ruff-check # Main linting checks
# name: Run mypy for Python 3.10 types_or: [ python, pyi ] # Check .py and .pyi files
# entry: tools/mypy.sh 1 "3.10" args: [ --fix ] # Auto-fix fixable issues
# # Use system python because vllm installation is required # Checks include:
# language: system # - Unused imports/variables
# types: [python] # - Syntax errors
# stages: [manual] # Only run in CI # - Code style issues
# - id: mypy-3.11 # TODO: Use https://github.com/pre-commit/mirrors-mypy when mypy setup is less awkward # - Potential bugs
# name: Run mypy for Python 3.11 - repo: https://github.com/jackdewinter/pymarkdown
# entry: tools/mypy.sh 1 "3.11" rev: v0.9.29
# # Use system python because vllm installation is required hooks:
# language: system - id: pymarkdown
# types: [python] args: [fix]
# stages: [manual] # Only run in CI - repo: https://github.com/rhysd/actionlint
# - id: mypy-3.12 # TODO: Use https://github.com/pre-commit/mirrors-mypy when mypy setup is less awkward rev: v1.7.7
# name: Run mypy for Python 3.12 hooks:
# entry: tools/mypy.sh 1 "3.12" - id: actionlint
# # Use system python because vllm installation is required
# language: system - repo: local
# types: [python] hooks:
# stages: [manual] # Only run in CI - id: signoff-commit
- id: signoff-commit name: Sign-off Commit
name: Sign-off Commit entry: bash
entry: bash args:
args: - -c
- -c - |
- | if ! grep -q "^Signed-off-by: $(git config user.name) <$(git config user.email)>" "$(git rev-parse --git-path COMMIT_EDITMSG)"; then
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)"
printf "\nSigned-off-by: $(git config user.name) <$(git config user.email)>\n" >> "$(git rev-parse --git-path COMMIT_EDITMSG)" fi
fi language: system
language: system verbose: true
verbose: true stages: [commit-msg]
stages: [commit-msg]
- id: check-filenames - id: check-filenames
name: Check for spaces in all filenames name: Check for spaces in all filenames
entry: bash entry: bash
args: args:
- -c - -c
- 'git ls-files | grep " " && echo "Filenames should not contain spaces!" && exit 1 || exit 0' - 'git ls-files | grep " " && echo "Filenames should not contain spaces!" && exit 1 || exit 0'
language: system language: system
always_run: true always_run: true
pass_filenames: false pass_filenames: false
# - id: python-init
# name: Enforce __init__.py in Python packages - id: suggestion
# entry: python tools/check_python_src_init.py name: Suggestion
# language: python entry: bash -c 'echo "To bypass pre-commit hooks, add --no-verify to git commit."'
# types: [python] language: system
# pass_filenames: false verbose: true
# Keep `suggestion` last 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
# Insert new entries above the `suggestion` entry

View File

@@ -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/ && \ 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/ 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 \ RUN rm -rf \
/root/.cache \ /root/.cache \

View File

@@ -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"
```