vllm.model_executor.layers.quantization.utils.mxfp8_utils ¶
Mxfp8LinearOp ¶
Source code in vllm/model_executor/layers/quantization/utils/mxfp8_utils.py
208 209 210 211 212 213 214 215 216 217 218 219 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 390 391 392 393 394 395 396 | |
_process_weights_emulation ¶
_process_weights_emulation(layer: Module) -> None
Keep scales as 2D uint8 for dequant-to-BF16 emulation.
Source code in vllm/model_executor/layers/quantization/utils/mxfp8_utils.py
_process_weights_flashinfer_cutlass ¶
_process_weights_flashinfer_cutlass(layer: Module) -> None
Swizzle scales to F8_128x4 layout for flashinfer CUTLASS.
Source code in vllm/model_executor/layers/quantization/utils/mxfp8_utils.py
_process_weights_marlin ¶
_process_weights_marlin(layer: Module) -> None
Repack MXFP8 weights and scales into Marlin kernel format.
Source code in vllm/model_executor/layers/quantization/utils/mxfp8_utils.py
process_weights ¶
process_weights(layer: Module) -> None
Process MXFP8 weights after loading into backend-specific format.
Source code in vllm/model_executor/layers/quantization/utils/mxfp8_utils.py
_mxfp8_e4m3_quantize_torch ¶
_mxfp8_e4m3_quantize_torch(
x: Tensor, is_sf_swizzled_layout: bool = False
) -> tuple[Tensor, Tensor]
Naive MXFP8 quantization. For each block of 32 elements along the last dimension, compute a shared e8m0 scale (the biased exponent of the block-wise amax) and quantize each element to float8_e4m3fn.
Returns (quantized_values [same shape, fp8], scales uint8). Scale shape depends on is_sf_swizzled_layout: False -> [..., K//32] (row-major 2D) True -> [flat swizzled 1D]
Source code in vllm/model_executor/layers/quantization/utils/mxfp8_utils.py
dequant_mxfp8_to_bf16 ¶
Dequantize MXFP8 tensor to BF16.
Source code in vllm/model_executor/layers/quantization/utils/mxfp8_utils.py
mxfp8_e4m3_quantize_fake ¶
Fake implementation for torch.compile tracing.
Source code in vllm/model_executor/layers/quantization/utils/mxfp8_utils.py
select_mxfp8_linear_backend ¶
Select the best MXFP8 linear backend for the current device.
- SM100+ (Blackwell): FLASHINFER_CUTLASS (native MXFP8 W8A8 GEMM)
- SM80+ (Ampere/Ada): MARLIN (MXFP8 W8A16 GEMM)
- Otherwise: EMULATION (dequant to BF16 fallback)
Source code in vllm/model_executor/layers/quantization/utils/mxfp8_utils.py
swizzle_mxfp8_scale ¶
Swizzle MXFP8 scales from row-major 2D to F8_128x4 layout.