Repository navigation
[BugFix] Handle CPU-only and XPU environments in check_env - #37037
CharlesXu-HQ wants to merge 1 commit into
Conversation
chrikrah
left a comment
There was a problem hiding this comment.
#38873 is open on this file and fixes the same NameError, from the XPU side. It landed 2026-09-10,
twelve days after this one, adds an XPUEnv with its own package lists and an elif is_xpu() in the same
chain, and ends it with else: raise RuntimeError. Neither pull request mentions the other. This one is
the earlier and the wider of the two: it covers CPU as well, moves the selection into _get_env(), and
carries test/registered/unit/test_check_env.py, which #38873 has no equivalent of.
Both are stuck on the same thing, and it is not the code. pr-gate exits on the label:
PR Labels: []
...
Missing required label 'run-ci'. See https://docs.sglang.io/developer_guide/contribution_guide.html#how-to-trigger-ci-tests
/tag-and-rerun-ci adds it, from any account in .github/CI_PERMISSIONS.json. Neither of us is among
those 251, so somebody who is has to say it before any suite starts. Sixteen days of red checks here are
that label.
One confirmation for the CPU half: on origin/main a CPU-only host raises NameError: name 'env' is not defined at check_env.py:594, and the bug template asks every reporter for that command's output.
Motivation
python -m sglang.check_envleavesenvundefined when no existing accelerator predicate matches. This crashes on CPU-only installations and on Intel XPU hosts because the dispatcher has neither a CPU fallback nor an XPU branch.Related to #35144, which reports the XPU form of this failure.
The closed, unmerged draft #29568 previously proposed the CPU fallback. This PR carries that fallback forward and additionally adds Intel XPU selection and device reporting, with tests following the current
CustomTestCaserequirement.Modifications
CPUEnvto report CPU architecture and logical CPU count.XPUEnvto report XPU availability, device count, and grouped device names.is_xpu()platform predicate in environment selection._get_env()and always return a checker, falling back toCPUEnv.Accuracy Tests
N/A. This only changes environment diagnostics and does not affect model outputs.
Speed Tests and Profiling
N/A. No inference or performance-critical path is changed.
Tests
python3 -m py_compile python/sglang/check_env.py test/registered/unit/test_check_env.pyruff check --select=F401,F821,UP037 python/sglang/check_env.py test/registered/unit/test_check_env.pyblack --check python/sglang/check_env.py test/registered/unit/test_check_env.pyisort --check-only --settings-path .isort.cfg python/sglang/check_env.py test/registered/unit/test_check_env.pybase-a-test-cpu, main entry present.git diff origin/main...HEAD --checkChecklist
Review and Merge Process
/tag-and-rerun-ci,/tag-run-ci-label,/rerun-failed-ciCI States
Latest PR Test (Base): ❌ Run #33253812907
Latest PR Test (Extra): ❌ Run #33253812700
Latest PR Test (AMD ROCm 7.2): ❌ Run #33253812977