[Kernel] Move sgl-kernel under sglang.kernels.aot (#32648)
This commit is contained in:
@@ -128,7 +128,7 @@ else
|
||||
# Also clear cache in sglang-checkout
|
||||
docker exec ci_sglang find /sglang-checkout -name "*.pyc" -delete || true
|
||||
docker exec ci_sglang find /sglang-checkout -name "__pycache__" -type d -exec rm -rf {} + || true
|
||||
docker exec -w /sglang-checkout/sgl-kernel ci_sglang bash -c "rm -f pyproject.toml && mv pyproject_rocm.toml pyproject.toml && python3 setup_rocm.py install"
|
||||
docker exec -w /sglang-checkout/python/sglang/kernels/aot ci_sglang bash -c "rm -f pyproject.toml && mv pyproject_rocm.toml pyproject.toml && python3 setup_rocm.py install"
|
||||
|
||||
docker exec ci_sglang bash -c 'rm -rf python/pyproject.toml && mv python/pyproject_other.toml python/pyproject.toml'
|
||||
install_with_retry docker exec ci_sglang pip install --cache-dir=/sgl-data/pip-cache -e "python[${EXTRAS}]"
|
||||
|
||||
@@ -304,28 +304,28 @@ install_sglang() {
|
||||
}
|
||||
|
||||
install_sglang_kernel() {
|
||||
SGL_KERNEL_VERSION_FROM_KERNEL=$(grep -Po '(?<=^version = ")[^"]*' sgl-kernel/pyproject.toml)
|
||||
SGL_KERNEL_VERSION_FROM_KERNEL=$(grep -Po '(?<=^version = ")[^"]*' python/sglang/kernels/aot/pyproject.toml)
|
||||
SGL_KERNEL_VERSION_FROM_SRT=$(grep -Po -m1 '(?<=sglang-kernel==)[0-9A-Za-z\.\-]+' python/pyproject.toml)
|
||||
echo "SGL_KERNEL_VERSION_FROM_KERNEL=${SGL_KERNEL_VERSION_FROM_KERNEL} SGL_KERNEL_VERSION_FROM_SRT=${SGL_KERNEL_VERSION_FROM_SRT}"
|
||||
|
||||
if [ "${CUSTOM_BUILD_SGL_KERNEL:-}" = "true" ] && [ -d "sgl-kernel/dist" ]; then
|
||||
ls -alh sgl-kernel/dist
|
||||
if [ "${CUSTOM_BUILD_SGL_KERNEL:-}" = "true" ] && [ -d "python/sglang/kernels/aot/dist" ]; then
|
||||
ls -alh python/sglang/kernels/aot/dist
|
||||
if [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then
|
||||
WHEEL_ARCH="aarch64"
|
||||
else
|
||||
WHEEL_ARCH="x86_64"
|
||||
fi
|
||||
KERNEL_WHL=$(ls sgl-kernel/dist/sglang_kernel-${SGL_KERNEL_VERSION_FROM_KERNEL}+${CU_VERSION}-cp310-abi3-manylinux2014_${WHEEL_ARCH}.whl 2>/dev/null | head -1 || true)
|
||||
KERNEL_WHL=$(ls python/sglang/kernels/aot/dist/sglang_kernel-${SGL_KERNEL_VERSION_FROM_KERNEL}+${CU_VERSION}-cp310-abi3-manylinux2014_${WHEEL_ARCH}.whl 2>/dev/null | head -1 || true)
|
||||
if [ -z "$KERNEL_WHL" ]; then
|
||||
echo "ERROR: No matching sgl-kernel wheel found in sgl-kernel/dist/ for version ${SGL_KERNEL_VERSION_FROM_KERNEL} arch ${WHEEL_ARCH} cuda ${CU_VERSION}"
|
||||
ls -alh sgl-kernel/dist/
|
||||
echo "ERROR: No matching sgl-kernel wheel found in python/sglang/kernels/aot/dist/ for version ${SGL_KERNEL_VERSION_FROM_KERNEL} arch ${WHEEL_ARCH} cuda ${CU_VERSION}"
|
||||
ls -alh python/sglang/kernels/aot/dist/
|
||||
exit 1
|
||||
fi
|
||||
echo "Installing sgl-kernel wheel: $KERNEL_WHL"
|
||||
$PIP_CMD install "$KERNEL_WHL" --force-reinstall $PIP_INSTALL_SUFFIX
|
||||
else
|
||||
if [ "${CUSTOM_BUILD_SGL_KERNEL:-}" = "true" ] && [ ! -d "sgl-kernel/dist" ]; then
|
||||
echo "ERROR: CUSTOM_BUILD_SGL_KERNEL=true but sgl-kernel/dist not found."
|
||||
if [ "${CUSTOM_BUILD_SGL_KERNEL:-}" = "true" ] && [ ! -d "python/sglang/kernels/aot/dist" ]; then
|
||||
echo "ERROR: CUSTOM_BUILD_SGL_KERNEL=true but python/sglang/kernels/aot/dist not found."
|
||||
echo "This usually happens when rerunning a stage without the sgl-kernel-build-wheels job."
|
||||
echo "Please re-run the full workflow using /tag-and-rerun-ci to rebuild the kernel."
|
||||
exit 1
|
||||
|
||||
@@ -84,7 +84,7 @@ else
|
||||
|
||||
cd "${REPO_ROOT}" && ${PIP_INSTALL} -v -e "python[dev_musa]" --user
|
||||
|
||||
cd "${REPO_ROOT}/sgl-kernel"
|
||||
cd "${REPO_ROOT}/python/sglang/kernels/aot"
|
||||
rm -f pyproject.toml && mv pyproject_musa.toml pyproject.toml && MTGPU_TARGET=mp_31 python3 setup_musa.py install --user
|
||||
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
|
||||
fi
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
# Usage:
|
||||
# rename_wheels_musa.sh <musa_suffix> [wheel_dir]
|
||||
# Example:
|
||||
# rename_wheels_musa.sh 43 sgl-kernel/dist
|
||||
# rename_wheels_musa.sh 43 python/sglang/kernels/aot/dist
|
||||
set -euxo pipefail
|
||||
|
||||
if [[ $# -lt 1 || $# -gt 2 ]]; then
|
||||
|
||||
@@ -8,7 +8,7 @@ get_version() {
|
||||
[ -f "$1" ] && python3 -c 'import re, sys; print(sys.argv[2] + " version: v" + re.search(r"__version__\s*=\s*[\"'"'"'](.*?)[\"'"'"']", open(sys.argv[1]).read()).group(1))' "$1" "$2" 2>/dev/null || echo "$2 version: unknown"
|
||||
}
|
||||
get_version "./python/sglang/version.py" "sglang"
|
||||
get_version "./sgl-kernel/python/sgl_kernel/version.py" "sgl_kernel"
|
||||
get_version "./python/sglang/kernels/aot/python/sgl_kernel/version.py" "sgl_kernel"
|
||||
SGLANG_URL="https://github.com/sgl-project/sglang.git"
|
||||
SGL_KERNEL_URL="https://github.com/sgl-project/sgl-kernel-npu.git"
|
||||
SGLANG_BRANCH="main"
|
||||
|
||||
@@ -289,14 +289,14 @@ def load_permissions(user_login):
|
||||
|
||||
def has_sgl_kernel_changes(pr):
|
||||
"""
|
||||
Check if the PR has changes to the sgl-kernel directory.
|
||||
Check if the PR has changes to the AOT kernel directory.
|
||||
This is used to determine if we need a full workflow rerun
|
||||
(to rebuild the kernel) vs just rerunning failed jobs.
|
||||
"""
|
||||
try:
|
||||
files = pr.get_files()
|
||||
for f in files:
|
||||
if f.filename.startswith("sgl-kernel/"):
|
||||
if f.filename.startswith("python/sglang/kernels/aot/"):
|
||||
return True
|
||||
return False
|
||||
except Exception as e:
|
||||
|
||||
@@ -576,7 +576,7 @@ def _infer_related_paths(test_file: str) -> List[str]:
|
||||
"specul": ["python/sglang/srt/speculative/"],
|
||||
"vision": ["python/sglang/srt/models/"],
|
||||
"embed": ["python/sglang/srt/layers/"],
|
||||
"kernel": ["sgl-kernel/", "python/sglang/srt/layers/"],
|
||||
"kernel": ["python/sglang/kernels/aot/", "python/sglang/srt/layers/"],
|
||||
"bench": ["benchmark/"],
|
||||
"constrained": ["python/sglang/srt/constrained/"],
|
||||
}
|
||||
|
||||
@@ -109,11 +109,11 @@ python scripts/release/bump_kernel_version.py 0.4.0
|
||||
```
|
||||
|
||||
**Files updated:**
|
||||
- `sgl-kernel/pyproject.toml`
|
||||
- `sgl-kernel/pyproject_cpu.toml`
|
||||
- `sgl-kernel/pyproject_rocm.toml`
|
||||
- `sgl-kernel/pyproject_musa.toml`
|
||||
- `sgl-kernel/python/sgl_kernel/version.py`
|
||||
- `python/sglang/kernels/aot/pyproject.toml`
|
||||
- `python/sglang/kernels/aot/pyproject_cpu.toml`
|
||||
- `python/sglang/kernels/aot/pyproject_rocm.toml`
|
||||
- `python/sglang/kernels/aot/pyproject_musa.toml`
|
||||
- `python/sglang/kernels/aot/python/sgl_kernel/version.py`
|
||||
|
||||
## Manual Testing Instructions
|
||||
|
||||
@@ -155,8 +155,8 @@ python scripts/release/bump_kernel_version.py 0.4.0
|
||||
|
||||
3. **Check specific files contain the new version:**
|
||||
```bash
|
||||
grep -r "0.4.0" sgl-kernel/python/sgl_kernel/version.py
|
||||
grep -r "0.4.0" sgl-kernel/pyproject.toml
|
||||
grep -r "0.4.0" python/sglang/kernels/aot/python/sgl_kernel/version.py
|
||||
grep -r "0.4.0" python/sglang/kernels/aot/pyproject.toml
|
||||
```
|
||||
|
||||
4. **Reset changes (if testing):**
|
||||
|
||||
@@ -16,14 +16,14 @@ def main():
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
version_file = Path("sgl-kernel/python/sgl_kernel/version.py")
|
||||
version_file = Path("python/sglang/kernels/aot/python/sgl_kernel/version.py")
|
||||
|
||||
files_to_update = [
|
||||
Path("sgl-kernel/pyproject.toml"),
|
||||
Path("sgl-kernel/pyproject_cpu.toml"),
|
||||
Path("sgl-kernel/pyproject_rocm.toml"),
|
||||
Path("sgl-kernel/pyproject_musa.toml"),
|
||||
Path("sgl-kernel/python/sgl_kernel/version.py"),
|
||||
Path("python/sglang/kernels/aot/pyproject.toml"),
|
||||
Path("python/sglang/kernels/aot/pyproject_cpu.toml"),
|
||||
Path("python/sglang/kernels/aot/pyproject_rocm.toml"),
|
||||
Path("python/sglang/kernels/aot/pyproject_musa.toml"),
|
||||
Path("python/sglang/kernels/aot/python/sgl_kernel/version.py"),
|
||||
]
|
||||
|
||||
bump_version(args.new_version, version_file, files_to_update)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Bump sglang-kernel version in SGLang files to match the version in sgl-kernel/pyproject.toml.
|
||||
Bump SGLang's kernel dependencies to match the AOT source pyproject.
|
||||
Updates:
|
||||
- python/pyproject.toml
|
||||
- python/sglang/srt/entrypoints/engine.py
|
||||
@@ -18,8 +18,8 @@ except ImportError:
|
||||
|
||||
|
||||
def get_kernel_version_from_source() -> str:
|
||||
"""Extract version from sgl-kernel/pyproject.toml"""
|
||||
pyproject_path = Path("sgl-kernel/pyproject.toml")
|
||||
"""Extract the version from the AOT source pyproject."""
|
||||
pyproject_path = Path("python/sglang/kernels/aot/pyproject.toml")
|
||||
|
||||
if not pyproject_path.exists():
|
||||
print(f"Error: {pyproject_path} not found")
|
||||
@@ -30,7 +30,9 @@ def get_kernel_version_from_source() -> str:
|
||||
|
||||
version = data.get("project", {}).get("version")
|
||||
if not version:
|
||||
print("Error: Could not find version in sgl-kernel/pyproject.toml")
|
||||
print(
|
||||
"Error: Could not find version in python/sglang/kernels/aot/pyproject.toml"
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
return version
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Check if sglang-kernel version from sgl-kernel/pyproject.toml matches the versions
|
||||
used in SGLang files (python/pyproject.toml, engine.py, and Dockerfile).
|
||||
Check whether SGLang's kernel dependencies match the AOT source pyproject.
|
||||
|
||||
The dependent versions are read from python/pyproject.toml, engine.py, and
|
||||
Dockerfile.
|
||||
Sets GitHub Actions output variables to indicate if sync is needed.
|
||||
"""
|
||||
|
||||
@@ -17,8 +19,8 @@ except ImportError:
|
||||
|
||||
|
||||
def get_kernel_version_from_source() -> str:
|
||||
"""Extract version from sgl-kernel/pyproject.toml (line 11)"""
|
||||
pyproject_path = Path("sgl-kernel/pyproject.toml")
|
||||
"""Extract the version from the AOT source pyproject."""
|
||||
pyproject_path = Path("python/sglang/kernels/aot/pyproject.toml")
|
||||
|
||||
if not pyproject_path.exists():
|
||||
print(f"Error: {pyproject_path} not found")
|
||||
@@ -29,7 +31,9 @@ def get_kernel_version_from_source() -> str:
|
||||
|
||||
version = data.get("project", {}).get("version")
|
||||
if not version:
|
||||
print("Error: Could not find version in sgl-kernel/pyproject.toml")
|
||||
print(
|
||||
"Error: Could not find version in python/sglang/kernels/aot/pyproject.toml"
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
return version
|
||||
@@ -101,7 +105,9 @@ def main():
|
||||
engine_version = get_kernel_version_from_engine()
|
||||
dockerfile_version = get_kernel_version_from_dockerfile()
|
||||
|
||||
print(f"Kernel version in sgl-kernel/pyproject.toml: {kernel_version}")
|
||||
print(
|
||||
f"Kernel version in python/sglang/kernels/aot/pyproject.toml: {kernel_version}"
|
||||
)
|
||||
print(
|
||||
f"SGLang kernel dependency version in python/pyproject.toml: {pyproject_version}"
|
||||
)
|
||||
|
||||
@@ -28,7 +28,7 @@ git add -A
|
||||
git commit -m "chore: bump sglang-kernel version to ${KERNEL_VERSION} in SGLang
|
||||
|
||||
This commit updates the sglang-kernel version across SGLang files to match
|
||||
the version defined in sgl-kernel/pyproject.toml.
|
||||
the version defined in python/sglang/kernels/aot/pyproject.toml.
|
||||
|
||||
Files updated:
|
||||
${COMMIT_FILES}
|
||||
@@ -45,7 +45,7 @@ PR_URL=$(gh pr create \
|
||||
--title "chore: bump sglang-kernel version to ${KERNEL_VERSION}" \
|
||||
--body "## Summary
|
||||
|
||||
This PR bumps the \`sglang-kernel\` version to \`${KERNEL_VERSION}\` across SGLang files to match the version defined in \`sgl-kernel/pyproject.toml\`.
|
||||
This PR bumps the \`sglang-kernel\` version to \`${KERNEL_VERSION}\` across SGLang files to match the version defined in \`python/sglang/kernels/aot/pyproject.toml\`.
|
||||
|
||||
**Kernel Version:** \`${KERNEL_VERSION}\`
|
||||
|
||||
@@ -54,7 +54,7 @@ ${FILES_LIST}
|
||||
|
||||
## Context
|
||||
|
||||
The kernel version in \`sgl-kernel/pyproject.toml\` has been updated. This PR ensures that all SGLang files referencing the \`sglang-kernel\` dependency are updated accordingly:
|
||||
The kernel version in \`python/sglang/kernels/aot/pyproject.toml\` has been updated. This PR ensures that all SGLang files referencing the \`sglang-kernel\` dependency are updated accordingly:
|
||||
- \`python/pyproject.toml\` - dependency specification
|
||||
- \`python/sglang/srt/entrypoints/engine.py\` - version check
|
||||
- \`docker/Dockerfile\` - Docker build argument
|
||||
|
||||
@@ -34,7 +34,7 @@ def update_wheel_index(cuda_version=DEFAULT_CUDA_VERSION, rocm_version=None):
|
||||
index_dir.mkdir(exist_ok=True, parents=True)
|
||||
base_url = "https://github.com/sgl-project/whl/releases/download"
|
||||
|
||||
for path in sorted(pathlib.Path("sgl-kernel/dist").glob("*.whl")):
|
||||
for path in sorted(pathlib.Path("python/sglang/kernels/aot/dist").glob("*.whl")):
|
||||
# Skip the wheel if mismatches the passed in cuda_version
|
||||
if not check_wheel_cuda_version(path.name, cuda_version):
|
||||
continue
|
||||
@@ -53,7 +53,7 @@ def _update_non_cuda_wheel_index(backend, version):
|
||||
index_dir.mkdir(exist_ok=True, parents=True)
|
||||
base_url = "https://github.com/sgl-project/whl/releases/download"
|
||||
|
||||
for path in sorted(pathlib.Path("sgl-kernel/dist").glob("*.whl")):
|
||||
for path in sorted(pathlib.Path("python/sglang/kernels/aot/dist").glob("*.whl")):
|
||||
# Skip the wheel if not for this backend
|
||||
if re.search(f"{backend}", path.name) is None:
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user