Conversation
…amic models) compressed-tensors FP8 W8A8 (RedHatAI/*-FP8-dynamic, e.g. Apertus-8B) crashes on XPU at layer-construction time and, after that, at first forward pass, due to three unrelated CUDA-only assumptions: - CompressedTensorsConfig._check_scheme_supported unconditionally calls torch.cuda.get_device_capability(), raising "AssertionError: Torch not compiled with CUDA enabled" on XPU before any kernel dispatch happens. Only CompressedTensorsW8A8Fp8 has a real XPU kernel path; every other capability-gated scheme is explicitly rejected with a clean error instead of crashing. - fp8_kernel.py's non-CUDA/non-MUSA sgl_per_token_quant_fp8 / sgl_per_tensor_quant_fp8 import was never added for XPU, even though sgl-kernel-xpu registers both natively -- causing a NameError on first use. - apply_fp8_linear's activation-quant padding (num_token_padding=17) is only skipped for cutlass_fp8_supported (CUDA-only); sgl-kernel-xpu's per-token quant kernel requires output_q to exactly match input's shape and doesn't support padded output, raising a shape-mismatch RuntimeError. None of these are gated behind a kernel that's actually missing -- compressed -tensors FP8 W8A8 on XPU runs through sglang's existing device-agnostic _apply_fallback_scaled_mm fallback (torch._scaled_mm + rowwise/colwise scale) once these three assumptions are corrected. Validated end-to-end on Intel Arc Pro (BMG) XPU, TP=1, intel_xpu attention backend: RedHatAI/Apertus-8B-Instruct-2509-FP8-dynamic serves and evaluates gsm8k correctly (exact_match flexible-extract=58.91%, strict-match=53.90%).
vshekhawat-hlab
requested review from
Alisehen,
AniZpZ,
BBuf,
DarkSharpness,
Edwardf0t1,
FlamingoPg,
HaiShaw,
HydraQYH,
OrangeRedeng,
b8zhong,
celve,
ch-wan,
mmangkad and
yuan-luo
as code owners
July 31, 2026 10:16
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
…or job225 - internvl.py: InternVLChatConfig has no top-level num_experts; the MoE config lives on the nested llm_config (Qwen3MoE text backbone). Fixes AttributeError on OpenGVLab/InternVL3_5-30B-A3B. - triton_backend.py: add mamba2_config to the hybrid-linear-model detection used to pick v_head_dim. GraniteMoeHybridConfig models (e.g. RedHatAI/granite-4.0-h-tiny-FP8-dynamic) are handled by mamba2_config() but weren't in this check, so layer_id=0 (a Mamba layer, not full-attention) was used to probe v_head_dim, raising "layer_id=0 not in full attention layers". - fp8.py: Fp8MoEMethod.apply() took the sgl-kernel-xpu native fast path unconditionally on XPU, before ever checking the selected MoE runner backend. This made --moe-runner-backend triton a no-op on XPU for this quant scheme, so FP8 W8A8 MoE models (e.g. Qwen/Qwen3.6-35B-A3B-FP8) still hit "current MoE does not support use_fp8_w8a8" from the native kernel even with the Triton runner explicitly requested. Skip the native XPU path when the runner backend is explicitly triton, falling through to the existing Triton dispatch below. Locally validated in Docker on Intel Arc Pro B60 (XPU): InternVL3_5-30B-A3B (mmmu_val, exit 0), granite-4.0-h-tiny-FP8-dynamic (gsm8k 0.8, exit 0), and Qwen3.6-35B-A3B-FP8 (crash resolved, though a separate reasoning-parser accuracy issue remains open -- see applications.ai.gpu.sglang-cicd CICD repo for details).
vshekhawat-hlab
requested review from
Fridge003,
Qiaolin-Yu,
hebiao064,
ispobock and
merrymercy
as code owners
August 2, 2026 09:50
RuntimeContext.get_stream() always constructed a CUDA stream regardless
of the configured device, which crashed Kimi-Linear-48B-A3B-Instruct on
XPU (kimi_linear.py calls get_stream("alt") unconditionally):
RuntimeError: torch.cuda.Stream requires CUDA support
Use torch.get_device_module(server_args.device).Stream() instead,
matching the device-agnostic pattern already used elsewhere (e.g.
speculative/dflash_info_v2.py, eagle_worker_v2.py).
Validated on XPU: with this fix plus the existing mamba/page_size
workaround flags, Kimi-Linear-48B-A3B-Instruct now clears both crashes
and successfully loads weights and allocates the KV/mamba cache pools.
topk_sigmoid kernel asserts correction_bias must be float32, but the _is_xpu branch of biased_grouped_topk_gpu passed it through unchanged while the CUDA branch a few lines above already does .to(torch.float32). Surfaced when running Kimi-Linear-48B-A3B-Instruct at TP8 on XPU: first generate request crashed with "RuntimeError: correction_bias must be float32". Validated on device: same fix clears the crash and produces a correct completion.
…tensors-fp8-w8a8-rebase # Conflicts: # python/sglang/kernels/ops/quantization/fp8_kernel.py # python/sglang/srt/layers/attention/triton_backend.py # python/sglang/srt/layers/quantization/fp8_utils.py
mingfeima
approved these changes
Aug 18, 2026
longxin9715
added a commit
to longxin9715/sglang
that referenced
this pull request
Aug 24, 2026
…n-transport1 * 'main' of https://github.com/sgl-project/sglang: (326 commits) [diffusion] feat: cache LoRA-merged weights in files the page cache can hold (sgl-project#36062) [diffusion] Speed up LingBot high-quality VAE decode (sgl-project#36024) [diffusion] Honor XDG cache for model overlays (sgl-project#36019) Support streaming session on NPU (sgl-project#32597) fix(xpu): read enable_deterministic_inference from the config bag (sgl-project#36149) xeon ci fail fast strategy change (sgl-project#36146) [diffusion] Fix Hunyuan QKV pack indexing at production video shapes (sgl-project#36009) [diffusion] Refresh quality and BCG benchmark skills (sgl-project#36016) [MoE] Gather the cutlass MoE activation and its scales in one launch (sgl-project#34915) [diffusion] feat: add plain component weight overrides (sgl-project#36086) [diffusion] feat: support loading mixed w4a8 text encoders (sgl-project#36037) [diffusion] Default Hunyuan VAE to tiled decode (sgl-project#36012) fix(xpu): enable compressed-tensors FP8 W8A8 on XPU (RedHatAI FP8-dynamic models) (sgl-project#33057) chore: move cuda_vmm_utils.py under srt/utils/ (sgl-project#36053) [Intel XPU] Add xpu pass for biased_topk and hash_topk (sgl-project#33323) [CPU] Fix NUMA/core binding for DP ranks (sgl-project#32856) [Fix] Harden FlashAttention CUDA graph metadata bounds (sgl-project#35454) [XPU] Use a fused GDN kernel from sgl-kernel for Qwen3.5 (sgl-project#33354) [diffusion] Fuse LongCat-Image QKNorm and interleaved RoPE (sgl-project#35995) [diffusion] Keep LongLive2 components resident on large GPUs (sgl-project#35993) ... # Conflicts: # python/sglang/srt/multimodal/processors/base_processor.py # python/sglang/srt/server_args.py
saturn-acc
pushed a commit
to saturn-acc/sglang
that referenced
this pull request
Aug 31, 2026
jakki-amd
pushed a commit
to jakki-amd/sglang
that referenced
this pull request
Sep 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
compressed-tensors FP8 W8A8 quantized models (e.g. RedHatAI's
*-FP8-dynamicfamily —Apertus-8B-Instruct-2509-FP8-dynamic,Mistral-Small-3.1-24B-Instruct-2503-FP8-dynamic,granite-4.0-h-small-FP8-dynamic,NVIDIA-Nemotron-Nano-9B-v2-FP8-dynamic) currently fail to serve on XPU. The very first failure happens at layer-construction time, before any kernel dispatch:Fixing that surfaces two further, distinct XPU-specific issues before the model actually serves and generates correctly.
Modifications
compressed_tensors.py(CompressedTensorsConfig):_check_scheme_supportedunconditionally calledtorch.cuda.get_device_capability(), which is CUDA-only. OnlyCompressedTensorsW8A8Fp8has a real XPU-usable kernel path today (via the existing device-agnostic_apply_fallback_scaled_mminfp8_utils.py, not a missing native kernel); every other capability-gated scheme (NVFP4/cutlass, Marlin-based W8A16Fp8, WNA16, ...) is explicitly rejected with a cleanRuntimeErroron XPU instead of crashing on the CUDA-only call.fp8_kernel.py: the non-CUDA/non-MUSA branch never importedsgl_per_token_quant_fp8/sgl_per_tensor_quant_fp8for XPU, even though sgl-kernel-xpu registers both natively — this caused aNameErroron the first forward pass once the above crash was fixed.fp8_utils.py(apply_fp8_linear): the activation-quant padding decision (num_token_padding=17, meant to maketorch._scaled_mmmore performant on CUDA for small batches) was only skipped whencutlass_fp8_supported(CUDA-only). sgl-kernel-xpu's per-token quant kernel requiresoutput_qto exactly matchinput's shape and doesn't support padded output, raising a shape-mismatchRuntimeErrorwhenever a forward pass had fewer than 17 rows (e.g. small prefill/decode steps).This made --moe-runner-backend triton a no-op on XPU for this quantization scheme — the native kernel path was still hit and raised "current MoE does not support
use_fp8_w8a8" even when the Triton runner had been explicitly requested. Now skips the native XPU path when the runner backend is explicitly triton, falling through to
the existing Triton dispatch below.
loading MoE-based InternVL variants.
created on whichever device backend is active instead of always assuming CUDA.
XPU branch passed it through unchanged, raising RuntimeError: correction_bias must be float32 on the first generation request for some MoE models. Now cast to float32
before the call, matching the CUDA branch.
Accuracy Tests
Verified locally end-to-end in a docker container (XPU backend, Intel Arc Pro/BMG) with the patched sglang installed in place of the image's baked-in copy:
RedHatAI/Apertus-8B-Instruct-2509-FP8-dynamic(TP=1,--attention-backend intel_xpu) serves and evaluates gsm8k (5-shot) correctly:exact_match,flexible-extract = 0.5891 ± 0.0136strict-match = 0.5390 ± 0.0137if _is_xpu:/elif _is_xpu:branches that are new no-ops on every other platform;cutlass_fp8_supported-driven CUDA behavior is unchanged (verified by re-reading every other call site of the touched functions —scaled_fp8_quant's other callers infp8_utils.pyare gated byif _is_cuda:/if _is_hip:, never reaching the changed XPU branch on other devices)._check_scheme_supportedcrash unconditionally at layer-construction time (before this PR), so none could have been passing beforehand.Speed Tests and Profiling
Not applicable — these are correctness/compatibility fixes for an existing fallback code path (
_apply_fallback_scaled_mm), no new kernel or scheduling changes. The activation-quant padding skip on XPU has a minor performance implication (an extra kernel-launch on small batches that would otherwise reuse a padded buffer), but padding was never functional on XPU before this PR (it crashed), so there's no regression relative to current behavior.Checklist
CI States
Latest PR Test (Base): 🚫 Run #32336898587
Latest PR Test (Extra): ✅ Run #32336898486
Latest PR Test (AMD ROCm 7.2): ❌ Run #32336898668