vllm-project / vllm-project/vllm

[Bug]: gpt-oss-20b NVFP4 inference is broken

Open
#46,641 3 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
92.1k
Forks
22.4k
PR merge metrics
PR metrics pending

Description

### Your current environment

The output of python collect_env.py

```text
Collecting environment information...

==============================
System Info
==============================
OS : CentOS Stream 9 (x86_64)
GCC version : (GCC) 11.5.0 20240719 (Red Hat 11.5.0-14)
Clang version : 22.1.3 (CentOS 22.1.3-1.el9)
CMake version : version 3.31.10
Libc version : glibc-2.34

==============================
PyTorch Info
==============================
PyTorch version : 2.13.0.dev20260521+cu130
Is debug build : False
CUDA used to build PyTorch : 13.0
ROCM used to build PyTorch : N/A
XPU used to build PyTorch : N/A

==============================
Python Environment
==============================
Python version : 3.10.20 (main, Mar 11 2026, 17:46:40) [GCC 14.3.0] (64-bit runtime)
Python platform : Linux-6.13.2-0_fbk12_0_g0b66b3635210-x86_64-with-glibc2.34

==============================
CUDA / GPU Info
==============================
Is CUDA available : True
CUDA runtime version : 12.9.86
CUDA_MODULE_LOADING set to :
GPU models and configuration :
GPU 0: NVIDIA B200
GPU 1: NVIDIA B200
GPU 2: NVIDIA B200
GPU 3: NVIDIA B200
GPU 4: NVIDIA B200
GPU 5: NVIDIA B200
GPU 6: NVIDIA B200
GPU 7: NVIDIA B200

Nvidia driver version : 580.82.07
cuDNN version : Could not collect
HIP runtime version : N/A
MIOpen runtime version : N/A
Is XNNPACK available : True

==============================
CPU Info
==============================
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 52 bits physical, 57 bits virtual
Byte Order: Little Endian
CPU(s): 384
On-line CPU(s) list: 0-383
Vendor ID: AuthenticAMD
Model name: AMD EPYC 9654 96-Core Processor
CPU family: 25
Model: 17
Thread(s) per core: 2
Core(s) per socket: 96
Socket(s): 2
Stepping: 1
Frequency boost: enabled
CPU(s) scaling MHz: 100%
CPU max MHz: 2400.0000
CPU min MHz: 1500.0000
BogoMIPS: 4792.85
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good amd_lbr_v2 nopl xtopology nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba perfmon_v2 ibrs ibpb stibp ibrs_enhanced vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local avx512_bf16 clzero irperf xsaveerptr rdpru wbnoinvd amd_ppin cppc arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif x2avic v_spec_ctrl vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid overflow_recov succor smca fsrm flush_l1d debug_swap
Virtualization: AMD-V
L1d cache: 6 MiB (192 instances)
L1i cache: 6 MiB (192 instances)
L2 cache: 192 MiB (192 instances)
L3 cache: 768 MiB (24 instances)
NUMA node(s): 2
NUMA node0 CPU(s): 0-95,192-287
NUMA node1 CPU(s): 96-191,288-383
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit: Not affected
Vulnerability L1tf: Not affected
Vulnerability Mds: Not affected
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Not affected
Vulnerability Reg file data sampling: Not affected
Vulnerability Retbleed: Not affected
Vulnerability Spec rstack overflow: Vulnerable
Vulnerability Spec store bypass: Vulnerable
Vulnerability Spectre v1: Vulnerable: __user pointer sanitization and usercopy barriers only; no swapgs barriers
Vulnerability Spectre v2: Vulnerable; IBPB: disabled; STIBP: disabled; PBRSB-eIBRS: Not affected; BHI: Not affected
Vulnerability Srbds: Not affected
Vulnerability Tsx async abort: Not affected

==============================
Versions of relevant libraries
==============================
[pip3] flashinfer-python==0.6.8.post1
[pip3] numpy==1.26.4
[pip3] nvidia-cublas==13.1.1.3
[pip3] nvidia-cublas-cu12==12.8.4.1
[pip3] nvidia-cuda-cupti==13.0.85
[pip3] nvidia-cuda-cupti-cu12==12.8.90
[pip3] nvidia-cuda-nvrtc==13.0.88
[pip3] nvidia-cuda-nvrtc-cu12==12.8.93
[pip3] nvidia-cuda-runtime==13.0.96
[pip3] nvidia-cuda-runtime-cu12==12.8.90
[pip3] nvidia-cudnn-cu12==9.20.0.48
[pip3] nvidia-cudnn-cu13==9.20.0.48
[pip3] nvidia-cudnn-frontend==1.18.0
[pip3] nvidia-cufft==12.0.0.61
[pip3] nvidia-cufft-cu12==11.3.3.83
[pip3] nvidia-cufile==1.15.1.6
[pip3] nvidia-cufile-cu12==1.13.1.3
[pip3] nvidia-curand==10.4.0.35
[pip3] nvidia-curand-cu12==10.3.9.90
[pip3] nvidia-cusolver==12.0.4.66
[pip3] nvidia-cusolver-cu12==11.7.3.90
[pip3] nvidia-cusparse==12.6.3.3
[pip3] nvidia-cusparse-cu12==12.5.8.93
[pip3] nvidia-cusparselt-cu12==0.7.1
[pip3] nvidia-cusparselt-cu13==0.8.1
[pip3] nvidia-cutlass-dsl==4.4.2
[pip3] nvidia-cutlass-dsl-libs-base==4.4.2
[pip3] nvidia-ml-py==13.595.45
[pip3] nvidia-modelopt==0.42.0
[pip3] nvidia-nccl-cu12==2.29.7
[pip3] nvidia-nccl-cu13==2.29.7
[pip3] nvidia-nvjitlink==13.0.88
[pip3] nvidia-nvjitlink-cu12==12.8.93
[pip3] nvidia-nvshmem-cu12==3.4.5
[pip3] nvidia-nvshmem-cu13==3.4.5
[pip3] nvidia-nvtx==13.0.85
[pip3] nvidia-nvtx-cu12==12.8.90
[pip3] pyzmq==27.1.0
[pip3] torch==2.13.0.dev20260521+cu130
[pip3] torch_c_dlpack_ext==0.1.5
[pip3] torchao==0.17.0+git3a1c12fdb
[pip3] torchaudio==2.10.0
[pip3] torchdata==0.11.0
[pip3] torchtitan==0.2.2
[pip3] torchvision==0.27.0
[pip3] transformers==5.9.0
[pip3] triton==3.7.0+git88b227e2
[conda] blas 1.0 mkl
[conda] flashinfer-python 0.6.8.post1 pypi_0 pypi
[conda] magma-cuda116 2.6.1 1 pytorch
[conda] mkl 2025.0.0 hacee8c2_941
[conda] mkl-include 2025.0.0 hc79277c_941
[conda] mkl-service 2.5.2 py310hacdc0fc_0
[conda] mkl_fft 2.1.1 py310h8fe796d_0
[conda] mkl_random 1.3.0 py310h505adc9_0
[conda] numpy 1.26.4 pypi_0 pypi
[conda] nvidia-cublas 13.1.1.3 pypi_0 pypi
[conda] nvidia-cublas-cu12 12.8.4.1 pypi_0 pypi
[conda] nvidia-cuda-cupti 13.0.85 pypi_0 pypi
[conda] nvidia-cuda-cupti-cu12 12.8.90 pypi_0 pypi
[conda] nvidia-cuda-nvrtc 13.0.88 pypi_0 pypi
[conda] nvidia-cuda-nvrtc-cu12 12.8.93 pypi_0 pypi
[conda] nvidia-cuda-runtime 13.0.96 pypi_0 pypi
[conda] nvidia-cuda-runtime-cu12 12.8.90 pypi_0 pypi
[conda] nvidia-cudnn-cu12 9.20.0.48 pypi_0 pypi
[conda] nvidia-cudnn-cu13 9.20.0.48 pypi_0 pypi
[conda] nvidia-cudnn-frontend 1.18.0 pypi_0 pypi
[conda] nvidia-cufft 12.0.0.61 pypi_0 pypi
[conda] nvidia-cufft-cu12 11.3.3.83 pypi_0 pypi
[conda] nvidia-cufile 1.15.1.6 pypi_0 pypi
[conda] nvidia-cufile-cu12 1.13.1.3 pypi_0 pypi
[conda] nvidia-curand 10.4.0.35 pypi_0 pypi
[conda] nvidia-curand-cu12 10.3.9.90 pypi_0 pypi
[conda] nvidia-cusolver 12.0.4.66 pypi_0 pypi
[conda] nvidia-cusolver-cu12 11.7.3.90 pypi_0 pypi
[conda] nvidia-cusparse 12.6.3.3 pypi_0 pypi
[conda] nvidia-cusparse-cu12 12.5.8.93 pypi_0 pypi
[conda] nvidia-cusparselt-cu12 0.7.1 pypi_0 pypi
[conda] nvidia-cusparselt-cu13 0.8.1 pypi_0 pypi
[conda] nvidia-cutlass-dsl 4.4.2 pypi_0 pypi
[conda] nvidia-cutlass-dsl-libs-base 4.4.2 pypi_0 pypi
[conda] nvidia-ml-py 13.595.45 pypi_0 pypi
[conda] nvidia-modelopt 0.42.0 pypi_0 pypi
[conda] nvidia-nccl-cu12 2.29.7 pypi_0 pypi
[conda] nvidia-nccl-cu13 2.29.7 pypi_0 pypi
[conda] nvidia-nvjitlink 13.0.88 pypi_0 pypi
[conda] nvidia-nvjitlink-cu12 12.8.93 pypi_0 pypi
[conda] nvidia-nvshmem-cu12 3.4.5 pypi_0 pypi
[conda] nvidia-nvshmem-cu13 3.4.5 pypi_0 pypi
[conda] nvidia-nvtx 13.0.85 pypi_0 pypi
[conda] nvidia-nvtx-cu12 12.8.90 pypi_0 pypi
[conda] pyzmq 27.1.0 pypi_0 pypi
[conda] torch 2.13.0.dev20260521+cu130 pypi_0 pypi
[conda] torch-c-dlpack-ext 0.1.5 pypi_0 pypi
[conda] torchao 0.17.0+git3a1c12fdb pypi_0 pypi
[conda] torchaudio 2.10.0 pypi_0 pypi
[conda] torchdata 0.11.0 pypi_0 pypi
[conda] torchtitan 0.2.2 pypi_0 pypi
[conda] torchvision 0.27.0 pypi_0 pypi
[conda] transformers 5.9.0 pypi_0 pypi
[conda] triton 3.7.0+git88b227e2 pypi_0 pypi

==============================
vLLM Info
==============================
ROCM Version : Could not collect
vLLM Version : 0.20.2rc1.dev242+gd7af6b34d.d20260528 (git sha: d7af6b34d, date: 20260528)
vLLM Build Flags:
CUDA Archs: Not Set; ROCm: Disabled; XPU: Disabled
GPU Topology:
GPU0 GPU1 GPU2 GPU3 GPU4 GPU5 GPU6 GPU7 NIC0 NIC1 NIC2 NIC3 NIC4 NIC5 NIC6 NIC7 NIC8 NIC9 NIC10 NIC11 NIC12 NIC13 NIC14 NIC15 CPU Affinity NUMA Affinity GPU NUMA ID
GPU0 X NV18 NV18 NV18 NV18 NV18 NV18 NV18 PIX NODE NODE NODE NODE NODE SYS SYS SYS SYS SYS SYS SYS SYS SYS SYS 0-95,192-287 N/A
GPU1 NV18 X NV18 NV18 NV18 NV18 NV18 NV18 NODE NODE NODE PIX PHB PHB SYS SYS SYS SYS SYS SYS SYS SYS SYS SYS 0-95,192-287 N/A
GPU2 NV18 NV18 X NV18 NV18 NV18 NV18 NV18 NODE NODE PIX NODE NODE NODE SYS SYS SYS SYS SYS SYS SYS SYS SYS SYS 0-95,192-287 N/A
GPU3 NV18 NV18 NV18 X NV18 NV18 NV18 NV18 NODE PIX NODE NODE NODE NODE SYS SYS SYS SYS SYS SYS SYS SYS SYS SYS 0-95,192-287 N/A
GPU4 NV18 NV18 NV18 NV18 X NV18 NV18 NV18 SYS SYS SYS SYS SYS SYS NODE NODE NODE NODE NODE NODE NODE NODE PIX NODE 96-191,288-383N/A
GPU5 NV18 NV18 NV18 NV18 NV18 X NV18 NV18 SYS SYS SYS SYS SYS SYS NODE NODE NODE NODE NODE NODE NODE NODE NODE PIX 96-191,288-383N/A
GPU6 NV18 NV18 NV18 NV18 NV18 NV18 X NV18 SYS SYS SYS SYS SYS SYS NODE NODE NODE NODE NODE PIX PHB PHB NODE NODE 96-191,288-383N/A
GPU7 NV18 NV18 NV18 NV18 NV18 NV18 NV18 X SYS SYS SYS SYS SYS SYS PIX PIX PIX PIX PIX NODE NODE NODE NODE NODE 96-191,288-383N/A
NIC0 PIX NODE NODE NODE SYS SYS SYS SYS X NODE NODE NODE NODE NODE SYS SYS SYS SYS SYS SYS SYS SYS SYS SYS
NIC1 NODE NODE NODE PIX SYS SYS SYS SYS NODE X NODE NODE NODE NODE SYS SYS SYS SYS SYS SYS SYS SYS SYS SYS
NIC2 NODE NODE PIX NODE SYS SYS SYS SYS NODE NODE X NODE NODE NODE SYS SYS SYS SYS SYS SYS SYS SYS SYS SYS
NIC3 NODE PIX NODE NODE SYS SYS SYS SYS NODE NODE NODE X PHB PHB SYS SYS SYS SYS SYS SYS SYS SYS SYS SYS
NIC4 NODE PHB NODE NODE SYS SYS SYS SYS NODE NODE NODE PHB X PIX SYS SYS SYS SYS SYS SYS SYS SYS SYS SYS
NIC5 NODE PHB NODE NODE SYS SYS SYS SYS NODE NODE NODE PHB PIX X SYS SYS SYS SYS SYS SYS SYS SYS SYS SYS
NIC6 SYS SYS SYS SYS NODE NODE NODE PIX SYS SYS SYS SYS SYS SYS X PIX PIX PIX PIX NODE NODE NODE NODE NODE
NIC7 SYS SYS SYS SYS NODE NODE NODE PIX SYS SYS SYS SYS SYS SYS PIX X PIX PIX PIX NODE NODE NODE NODE NODE
NIC8 SYS SYS SYS SYS NODE NODE NODE PIX SYS SYS SYS SYS SYS SYS PIX PIX X PIX PIX NODE NODE NODE NODE NODE
NIC9 SYS SYS SYS SYS NODE NODE NODE PIX SYS SYS SYS SYS SYS SYS PIX PIX PIX X PIX NODE NODE NODE NODE NODE
NIC10 SYS SYS SYS SYS NODE NODE NODE PIX SYS SYS SYS SYS SYS SYS PIX PIX PIX PIX X NODE NODE NODE NODE NODE
NIC11 SYS SYS SYS SYS NODE NODE PIX NODE SYS SYS SYS SYS SYS SYS NODE NODE NODE NODE NODE X PHB PHB NODE NODE
NIC12 SYS SYS SYS SYS NODE NODE PHB NODE SYS SYS SYS SYS SYS SYS NODE NODE NODE NODE NODE PHB X PIX NODE NODE
NIC13 SYS SYS SYS SYS NODE NODE PHB NODE SYS SYS SYS SYS SYS SYS NODE NODE NODE NODE NODE PHB PIX X NODE NODE
NIC14 SYS SYS SYS SYS PIX NODE NODE NODE SYS SYS SYS SYS SYS SYS NODE NODE NODE NODE NODE NODE NODE NODE X NODE
NIC15 SYS SYS SYS SYS NODE PIX NODE NODE SYS SYS SYS SYS SYS SYS NODE NODE NODE NODE NODE NODE NODE NODE NODE X

Legend:

X = Self
SYS = Connection traversing PCIe as well as the SMP interconnect between NUMA nodes (e.g., QPI/UPI)
NODE = Connection traversing PCIe as well as the interconnect between PCIe Host Bridges within a NUMA node
PHB = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU)
PXB = Connection traversing multiple PCIe bridges (without traversing the PCIe Host Bridge)
PIX = Connection traversing at most a single PCIe bridge
NV# = Connection traversing a bonded set of # NVLinks

NIC Legend:

NIC0: mlx5_0
NIC1: mlx5_1
NIC2: mlx5_2
NIC3: mlx5_3
NIC4: mlx5_4
NIC5: mlx5_5
NIC6: mlx5_6
NIC7: mlx5_7
NIC8: mlx5_8
NIC9: mlx5_9
NIC10: mlx5_10
NIC11: mlx5_11
NIC12: mlx5_12
NIC13: mlx5_13
NIC14: mlx5_14
NIC15: mlx5_15

==============================
Environment Variables
==============================
CUDA_CACHE_PATH=/data/users/andrewor/.nv/ComputeCache
MAX_JOBS=48
CUDA_NVCC_EXECUTABLE=/home/andrewor/local/ccache/cuda/nvcc
LD_LIBRARY_PATH=/usr/local/cuda-12.9/lib64:
CUDA_HOME=/usr/local/cuda-12.9
CUDA_HOME=/usr/local/cuda-12.9
PYTORCH_NVML_BASED_CUDA_CHECK=1
TORCHINDUCTOR_COMPILE_THREADS=1
```

### 🐛 Describe the bug

## Summary

Running **gpt-oss-20b quantized to NVFP4** (`quantization=modelopt_fp4`) does not work out of the box — the model loads but emits pure garbage (a single repeated token, e.g. `!!!!!!`), or crashes during loading. There are four distinct gaps:

1. **Expert biases are never registered** — loading GPT-OSS raises `KeyError: ...experts.w2_bias`.
2. **NVFP4 scales are never loaded** — every scale param stays at its init value (0 / NaN) → NaN logits → garbage (this is the cause of `!!!!`).
3. **The FLASHINFER_CUTLASS MoE kernel runs GPT-OSS NVFP4 correctly, but only after code changes** (clamped-SwiGLU params + biases were mxfp4-only, and gate/up interleave needs handling).
4. **The FLASHINFER_TRTLLM MoE kernel cannot run GPT-OSS's clamped-SwiGLU MoE at all** — the TrtllmGen Gemm2 runner fails even at kernel-aligned shapes.

After fixing (1)–(3), gpt-oss-20b NVFP4 runs correctly via the cutlass backend. You can find the draft changes here: [#46645](https://github.com/vllm-project/vllm/pull/46645).

## Environment

- vLLM `v0.20.2rc1.dev242+gd7af6b34d` (recent main), NVIDIA B200 (SM100), FlashInfer FP4 MoE kernels.
- gpt-oss-20b quantized to NVFP4 via ModelOpt 0.42.0 (`quantization=modelopt_fp4`).

## Repro

Step 1 — produce an NVFP4 checkpoint with ModelOpt

`openai/gpt-oss-20b` is an MXFP4 model, so first get a bf16 checkpoint, then quantize it to NVFP4:

```python
import modelopt.torch.quantization as mtq
import torch
from datasets import load_dataset
from modelopt.torch.export import export_hf_checkpoint
from transformers import AutoModelForCausalLM, AutoTokenizer

# Get a bf16 gpt-oss-20b, either:
# (1) dequantize openai/gpt-oss-20b -> /tmp/gpt-oss-20b-bf16 by running
# `python convert_gptoss_mxfp4_to_bf16.py`
# (script: https://gist.github.com/andrewor14/c7457670a68db8c33c6ece6775dac310), or
# (2) use the prebuilt "lmsys/gpt-oss-20b-bf16"
MODEL = "/tmp/gpt-oss-20b-bf16"
model = AutoModelForCausalLM.from_pretrained(MODEL, torch_dtype=torch.bfloat16, device_map="auto")
tok = AutoTokenizer.from_pretrained(MODEL)

# calibrate on 128 real samples
texts = list(load_dataset("openai/gsm8k", "main", split="train[:128]")["question"])
ids = tok(texts, return_tensors="pt", padding=True, truncation=True, max_length=512).input_ids
def calibration_loop(m):
with torch.no_grad():
for i in range(0, len(texts), 8):
m(ids[i:i + 8].to(m.device))

# quantize to NVFP4 and export (export does not save the tokenizer)
mtq.quantize(model, mtq.NVFP4_DEFAULT_CFG, calibration_loop)
export_hf_checkpoint(model, dtype=torch.bfloat16, export_dir="/tmp/gpt-oss-20b-nvfp4")
tok.save_pretrained("/tmp/gpt-oss-20b-nvfp4")
```

Step 2 — run it in vLLM (→ garbage / crash)

```python
from vllm import LLM, SamplingParams
llm = LLM(model="/tmp/gpt-oss-20b-nvfp4", quantization="modelopt_fp4",
dtype="bfloat16", enforce_eager=True)
print(llm.generate(["What is 25 * 17?"], SamplingParams(max_tokens=20, temperature=0))[0].outputs[0].text)
# -> "!!!!!!!!!!!!!!!!!!!!" (or KeyError: ...experts.w2_bias during load)
```

---

## Gap 1 — Expert biases are never registered

`ModelOptNvFp4FusedMoE.create_weights` (`quantization/modelopt.py`) never registers `w13_bias`/`w2_bias`, so loading gpt-oss (which has per-expert biases) raises `KeyError: ...experts.w2_bias` in `gpt_oss.py:_load_weights_other`.

**Fix:** register the biases when `self.moe.has_bias` (as `Mxfp4MoEMethod` already does), and thread them into the MoE quant config so the kernels can read them.

---

## Gap 2 — NVFP4 scales are never loaded (the actual cause of `!!!!`)

After Gap 1 the model loads, but none of the six MoE scale tensors in the checkpoint actually make it into the model — every scale parameter is left at its init value, so the MoE output becomes NaN and the model emits one repeated token. (The weights themselves are fine: dequantizing `gate_up_proj` and comparing to bf16 gives cosine ≈ 0.997 — only the scales are missing.)

Checkpoint keys that fail to load (one set per expert layer) and the vLLM params they should populate

| ModelOpt checkpoint key | target vLLM param | state after load |
|---|---|---|
| `…experts.gate_up_proj_weight_scale` | `…experts.w13_weight_scale` | all zero |
| `…experts.down_proj_weight_scale` | `…experts.w2_weight_scale` | uninitialized (NaN) |
| `…experts.gate_up_proj_weight_scale_2` | `…experts.w13_weight_scale_2` | all zero |
| `…experts.down_proj_weight_scale_2` | `…experts.w2_weight_scale_2` | all zero |
| `…experts.gate_up_proj_input_scale` | `…experts.w13_input_scale` | all zero |
| `…experts.down_proj_input_scale` | `…experts.w2_input_scale` | all zero |

There are two reasons, both in `gpt_oss.py`:

**2a — the name mapper doesn't recognize these keys.** vLLM's gpt_oss weight-name mapper knows the mxfp4 spelling (`gate_up_proj_scales`) and the quark spelling (`gate_up_proj.weight_scale`, dot-separated), but not ModelOpt's underscore spelling (the six keys above). Unrecognized keys are silently skipped, so the params keep their init values. (The weight tensors themselves load fine, since `gate_up_proj`/`down_proj` *are* mapped.) **Fix:** add mappings for the six ModelOpt key names.

**2b — even once mapped, the loader can't place them.** The gpt_oss MoE loader only has explicit handling for the weights and biases; the per-tensor scales (`weight_scale_2`, `input_scale`) aren't handled and error out. On top of that, ModelOpt stores `weight_scale_2`/`input_scale` as a single global scalar, whereas vLLM's parameters are per-expert. **Fix:** add a small handler that broadcasts the scalar to the per-expert parameter.

With Gaps 1+2 fixed the scales load correctly, and the emulation backend already produces correct output (see Gap 5).

---

## Gap 3 — FLASHINFER_CUTLASS works for nvfp4, but needs code changes

The cutlass FP4 MoE backend (`flashinfer_cutlass_moe.py`) advertises `SWIGLUOAI` and `cutlass_fused_moe` accepts biases + `swiglu_alpha/beta/limit`, but the wiring is mxfp4-only, so nvfp4 runs without clamp/bias → coherent-but-wrong output. Three fixes:

- **3a:** `FlashInferExperts.__init__` sets `gemm1_alpha/beta/clamp_limit` only for mxfp4 → set them for any `swigluoai` activation.
- **3b:** `apply` sets bias + swiglu params only in the mxfp4 branch, not the nvfp4 branch → set them in the nvfp4 branch too.
- **3c:** gpt-oss stores gate/up **interleaved**, but `prepare_nvfp4_moe_layer_for_fi_or_cutlass` applies `reorder_w1w3_to_w3w1` (assumes concatenated) → for `swigluoai`, de-interleave to `[w3,w1]` (odd-then-even rows) instead, and reorder the bias to match.

With 3a–3c, cutlass produces correct nvfp4 output matching bf16 (step-50 RL checkpoint: GSM8K 84% = bf16, MATH-500 52% ≈ bf16 49%).

---

## Gap 4 — FLASHINFER_TRTLLM cannot run gpt-oss's clamped-SwiGLU MoE

TRTLLM is selected first by the oracle. Even after wiring the bias + `gemm1_alpha/beta/clamp_limit` args and fixing alignment/bias padding, the TrtllmGen runner fails on **gemm2**:

```
trtllm_batched_gemm_runner.cu:265: Error occurred when running GEMM!
(numBatches: 32, GemmMNK: 16384 3072 3072, Kernel: bmm_..._clmp_swiGlu_..._sm100f)
-> Gemm2::Runner::run -> illegal memory access
```

A `clmp_swiGlu` kernel variant is *selected* but won't run — and it fails even with all dims 256-aligned (`16384×3072×3072`) and at minimal batch, so it's not an M-size or padding issue. There appears to be no working TrtllmGen Gemm2 kernel for gpt-oss's MoE config; this is a FlashInfer-level limitation, not fixable from vLLM.

**Recommendation in vLLM:** exclude `SWIGLUOAI` from `TrtLlmNvFp4Experts._supports_activation` so the oracle falls through to `FLASHINFER_CUTLASS` (which works); otherwise nvfp4 gpt-oss hard-fails by default.

---

## Gap 5 — Emulation works, but needs the loader fixes + a way to select it

The pure-PyTorch `EMULATION` backend handles interleaved gate/up + clamp + bias natively and is a useful correct reference/fallback. It needs: Gaps 1+2 (bias registration + scale loading); the bias threaded into the quant config (shared with cutlass); and a user-facing way to select it (today there's no switch to force `EMULATION` for nvfp4). With those, it produces correct output (GSM8K ≈ 73% @30 samples), confirming the weights/scales/activation are correct.

---

Summary of required changes (see #46645)

| Gap | File | Change |
|-----|------|--------|
| 1 | `quantization/modelopt.py` (`ModelOptNvFp4FusedMoE.create_weights`) | Register `w13_bias`/`w2_bias` when `self.moe.has_bias` |
| 1/3/5 | `quantization/modelopt.py` (`get_fused_moe_quant_config`) + `fused_moe/config.py` + `fused_moe/oracle/nvfp4.py` | Thread `w1_bias`/`w2_bias` + `gemm1_alpha/beta/gemm1_clamp_limit` into the NVFP4 quant config |
| 2a | `models/gpt_oss.py` (`hf_to_vllm_mapper`) | Add ModelOpt underscore scale-key mappings |
| 2b | `models/gpt_oss.py` (`_load_weights_other`) | Broadcast scalar `weight_scale_2`/`input_scale` to per-expert params; order before `.w13_weight` check |
| 3a/3b | `fused_moe/experts/flashinfer_cutlass_moe.py` | Set swiglu clamp params for any `swigluoai`; pass bias + swiglu params in the nvfp4 branch |
| 3c | `fused_moe/quantization/utils/flashinfer_fp4_moe.py` + cutlass `apply` | De-interleave gate/up (odd-then-even) for `swigluoai`; reorder bias to match |
| — | `fused_moe/quantization/utils/flashinfer_utils.py` | Map `SWIGLUOAI → ActivationType.Swiglu` (clamp params make it the OAI variant) |
| 4 | `fused_moe/experts/trtllm_nvfp4_moe.py` (`_supports_activation`) | Exclude `SWIGLUOAI` so the oracle uses cutlass (TrtllmGen Gemm2 unsupported for GPT-OSS) |
| 5 | `fused_moe/oracle/nvfp4.py` | Provide a documented way to select the `EMULATION` backend |

## Validation

- **Weights are correct independent of all this**: dequantizing the ModelOpt NVFP4 `gate_up_proj` and comparing to bf16 → cosine **0.997**.
- **cutlass (after fixes)**: GSM8K **84%** (= bf16), MATH-500 **52%** (≈ bf16 49%) on a 50-sample probe; clean generations.
- **emulation (after fixes)**: GSM8K ≈ **73%** @30 samples; clean generations.
- **trtllm**: still fails (`Gemm2::Runner` GEMM error) — FlashInfer-level.

### Before submitting a new issue...

- [x] Make sure you already searched for relevant issues, and asked the chatbot living at the bottom right corner of the [documentation page](https://docs.vllm.ai/en/latest/), which can answer lots of frequently asked questions.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing gpt-oss-20b NVFP4 inference in the reported vLLM, PyTorch, and NVIDIA B200 environment. The issue does not name source files or tests; done means the inference path runs successfully and produces valid output without the reported failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
backend, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.