vllm.model_executor.layers.quantization.online.nvfp4
¶
Classes:
-
Nvfp4OnlineMoEMethod–Online NVFP4 MoE quantization with per-token activation scales.
-
Nvfp4WeightOnlyOnlineLinearMethod–Online weight-only NVFP4 (W4A16) linear method.
Nvfp4OnlineMoEMethod
¶
Bases: OnlineMoEMethodBase
Online NVFP4 MoE quantization with per-token activation scales.
Quantizes fp16/bf16 expert weights to NVFP4 at load time; the FlashInfer TRTLLM kernel computes per-token activation scales at runtime. Blackwell (SM100) only.
Source code in vllm/model_executor/layers/quantization/online/nvfp4.py
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | |
Nvfp4WeightOnlyOnlineLinearMethod
¶
Bases: OnlineLinearBase
Online weight-only NVFP4 (W4A16) linear method.
Quantizes fp16/bf16 weights to NVFP4 during loading, with one global scale per weight shared across TP ranks, and runs them on the platform's W4A16 kernel. Activations stay in the model dtype.
Source code in vllm/model_executor/layers/quantization/online/nvfp4.py
_quantize_moe_weight_to_nvfp4(weight, moe_tp_size=1)
¶
Quantize stacked MoE expert weights (E, N, K) to NVFP4.
One FP32 global scale per expert plus per-block (group-16) FP8 scales,
matching the ModelOpt NVFP4 checkpoint layout. Returns packed FP4 weights
(E, N, K // 2), block scales (E, N, K // 16), and the per-expert
global scale (E,) stored as amax / (fp4_max * fp8_max).
weight may be staged on the CPU: experts then move to the accelerator
one at a time, where all outputs are returned.
Source code in vllm/model_executor/layers/quantization/online/nvfp4.py
_quantize_nvfp4(weight, amax, chunk_rows=8192)
¶
NVFP4-quantize the rows of weight, with the native quant kernel where
the GPU has one and a PyTorch reference elsewhere (the W4A16 kernels also
run on GPUs without it).
amax sets the global scale. Returns packed E2M1 codes (low nibble first),
E4M3 scales per 16 values and the fp32 dequantization global scale, in the
checkpoint layout.