Repository navigation
multi device support - #527
mkumargarg wants to merge 4 commits into
Conversation
7d4aaa9 to
3be21fd
Compare
1d11d81 to
3a61097
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The unguarded CRI enum breaks supported older-toolchain builds, and relative output paths can prevent the build helper from locating merged wheels.
2 open issues
What changed in this PR
This PR enables a single sgl-kernel-xpu wheel to support BMG and CRI GPUs by packaging separate architecture backends and selecting one at import time.
Changes:
- Adds shared architecture detection and runtime backend loading.
- Moves compiled libraries into per-architecture package directories.
- Adds scripts to build and merge architecture-specific wheels.
| File | Description |
|---|---|
src/sycl/Device.cpp |
Delegates device queries to the shared helper. |
src/BuildOnLinux.cmake |
Builds the probe and installs libraries by architecture. |
src/arch/sgl_arch_probe.cpp |
Exposes a C entry point for architecture detection. |
scripts/build_multiarch_wheel.py |
Orchestrates builds, merging, and optional installation. |
scripts/build_fat_wheel.py |
Merges wheel payloads and regenerates RECORD. |
python/sgl_kernel/_xe35/__init__.py |
Adds the CRI backend package stub. |
python/sgl_kernel/_xe20/__init__.py |
Adds the BMG backend package stub. |
python/sgl_kernel/_arch.py |
Detects the architecture and loads its backend. |
python/sgl_kernel/__init__.py |
Adds fallback loading for per-architecture backends. |
include/sgl_arch_query.h |
Centralizes architecture-to-capability mapping. |
CMakeLists.txt |
Selects backend install paths and checks Torch import failures. |
Review effort: Balanced
| case syclex::architecture::intel_gpu_cri: | ||
| return std::make_tuple(3, 5); |
| run([sys.executable, str(MERGE_SCRIPT), str(args.out_dir), *map(str, wheels)]) | ||
| merged = sorted(args.out_dir.glob("*.whl")) |
Signed-off-by: Manoj Kumar <manoj1.kumar@intel.com>
3a61097 to
20aa428
Compare
This commit adds a script which clubs many commands into one so that user needs to give only a single command to generate the multiarch wheel. Signed-off-by: Manoj Kumar <manoj1.kumar@intel.com>
airMeng
left a comment
There was a problem hiding this comment.
Reviewed the latest revision. The older-toolchain CRI enum guard is fixed, and the actual architecture probe builds with the production CMake/GNU-host path on oneAPI 2026.1 and correctly detects BMG. Requesting changes for the relative output-directory issue described inline, confirming the existing Copilot finding. I reproduced it with actual merger subprocesses and synthetic architecture wheel payloads; an absolute output directory succeeds. Full dual-architecture wheel installation and CRI execution were not tested.
| final = wheels[0] | ||
| else: | ||
| run([sys.executable, str(MERGE_SCRIPT), str(args.out_dir), *map(str, wheels)]) | ||
| merged = sorted(args.out_dir.glob("*.whl")) |
There was a problem hiding this comment.
[P2] Resolve the output directory before invoking the merger.
run() executes the merger with cwd=PROJECT_ROOT, whereas this glob resolves a relative args.out_dir against the caller's working directory. Invoking python /path/to/repo/scripts/build_multiarch_wheel.py --skip-build --out-dir result from outside the repository creates repo/result/<wheel>.whl, then searches caller/result and exits with expected one merged wheel ... found []; --install is never reached. I confirmed this with the actual merger subprocess: the relative path reproduces the failure and an absolute path succeeds. Please normalize the output directory to an absolute path once and reuse it for merging, discovery and installation.
There was a problem hiding this comment.
Fixed: args.out_dir (and args.build_dir, which had the same problem with -C build-dir=) are now converted to absolute paths once, right after parse_args(). The merger, the wheel lookup and --install all use that path.
Signed-off-by: Manoj Kumar <manoj1.kumar@intel.com>
Signed-off-by: Manoj Kumar <manoj1.kumar@intel.com>


Multi-Device Support - PR #527
Overview
This PR implements multi-architecture wheel support for the sgl-kernel-xpu project, enabling a single wheel to run on multiple Intel GPU architectures (Xe2/BMG and Xe3P/CRI) without requiring separate architecture-specific builds per deployment.
Problem Statement
Previously, each build was architecture-specific due to
SYCL_INTEL_TARGETbeing a compile-time switch that affects common kernel sources. This meant:Solution
Implement a "fat wheel" strategy that:
_xe20for BMG,_xe35for CRI)Key Changes
1. Architecture Detection System
include/sgl_arch_query.h(NEW): Unified header shared by probe and torch opsdevice_architecture(): Gets raw device architecture via SYCL APIdevice_capability(): Maps architecture → (major, minor) version tuplesrc/arch/sgl_arch_probe.cpp(NEW): Lightweight probe librarySYCL_INTEL_TARGETsgl_probe_device_capability()src/sycl/Device.cpp(REFACTORED):sgl_arch_query.h2. Per-Architecture Package Layout
python/sgl_kernel/_xe20/__init__.py(NEW): Xe2/BMG backend stubpython/sgl_kernel/_xe35/__init__.py(NEW): Xe3P/CRI backend stub*.so) install into respective architecture directories3. Runtime Backend Selection
python/sgl_kernel/_arch.py(NEW): Architecture detection and backend loaderprobe_capability(): Calls C probe to get device (major, minor)select_backend(): Maps capability to backend subpackage nameload_backend(): Imports and registers architecture-appropriate backendSGL_KERNEL_ARCHenv var override for debugging/CIpython/sgl_kernel/__init__.py(MODIFIED):_arch.load_backend()for multi-arch wheels4. Wheel Merging Tool
scripts/build_fat_wheel.py(NEW): Merges per-architecture wheelsscripts/build_multiarch_wheel.py(NEW): build and merge multiple wheels in single command5. Build System Updates
CMakeLists.txt(MODIFIED):--no-isolation)SGL_ARCH_PKG_DIRvariable controls per-arch install locationsrc/BuildOnLinux.cmake(MODIFIED):sgl_arch_probeindependentlycommon_opsand kernel libraries to per-arch directoriesBuild & Test Instructions
Building Multi-Architecture Wheel