vLLM注意力输入的融合FP8量化算子
该算子把最多三路注意力输入合并为两次内核启动完成动态逐张量FP8量化,每路各自计算amax与FP32缩放因子,支持任意步长与不同token数,并可在CUDA图中安全使用。
## `vllm.v1.attention.ops.triton_per_tensor_fp8_quant` [¶](<https://docs.vllm.ai/en/latest/api/vllm/v1/attention/ops/triton_per_tensor_fp8_quant/#vllm.v1.attention.ops.triton_per_tensor_fp8_quant>) Fused 动态 per- tensor FP8 将最多3个注意力输入量量化. 每一个 `[tokens, heads, dim]` 输入(可能是按顺序排列的,例如,将V作为 `kv_b_proj` 输出)获得自己的amax和 FP32 解码。在两次发射中,一个部分-amax通过和一个reduce-and-quantize通过覆盖所有输入;内核边界是唯一的全球屏障,因此不需要做动画或零初始化,操作是 CUDA-graph 安全。编译时的专门性不依赖于符号计数(只有网格大小才有),所以不同的批次形状不重编 。 一个网格覆盖了每次发射中的所有输入,所以一个程序可以降落在较小输入的结尾。这样的程序没有工作,也没有计算地址,不管怎样,每个负荷和存储都是蒙蔽的,所以没有形成out-of-range指针或调试. 改编自ROCm/ATOM(原子/model_ops / triton_fused_qkv_quant.py,MIT许可证)的已熔化的QKV量子. 函数 : - **`[fused_per_tensor_fp8_quant](<https://docs.vllm.ai/en/latest/api/vllm/v1/attention/ops/triton_per_tensor_fp8_quant/#vllm.v1.attention.ops.triton_per_tensor_fp8_quant.fused_per_tensor_fp8_quant>)`** – 将每个输入量用自己的动态每分压尺度对FP8进行量化. ## `fused_per_tensor_fp8_quant(*tensors, fp8_dtype=torch.float8_e4m3fn)` [¶](<https://docs.vllm.ai/en/latest/api/vllm/v1/attention/ops/triton_per_tensor_fp8_quant/#vllm.v1.attention.ops.triton_per_tensor_fp8_quant.fused_per_tensor_fp8_quant>) 将每个输入量用自己的动态每分压尺度对FP8进行量化. 参数: - ### **`tensors`** [¶](<https://docs.vllm.ai/en/latest/api/vllm/v1/attention/ops/triton_per_tensor_fp8_quant/#vllm.v1.attention.ops.triton_per_tensor_fp8_quant.fused_per_tensor_fp8_quant(tensors)>) (`[Tensor](<https://pytorch.org/docs/stable/tensors.html#torch.Tensor>)`,默认值 : `()` ) – 1至3个BF16 / FP16 `[tokens, heads, dim]` 在同一设备上显示的百分数。 任意的脚步被支持; 符号计数可能不同, 也可能是零 。 - ### **`fp8_dtype`** [¶](<https://docs.vllm.ai/en/latest/api/vllm/v1/attention/ops/triton_per_tensor_fp8_quant/#vllm.v1.attention.ops.triton_per_tensor_fp8_quant.fused_per_tensor_fp8_quant(fp8_dtype)>) (`[dtype](<https://pytorch.org/docs/stable/tensor_attributes.html#torch.dtype>)`,默认值 : `float8_e4m3fn` ) – FP8输出D型. 回返情况: - `[tuple](<https://docs.python.org/3/builtins/stdtypes.html#tuple>)[[Tensor](<https://pytorch.org/docs/stable/tensors.html#torch.Tensor>), ...]` – `(outputs, descales)`:带有输入形状的相接式FP8 伸缩器 - `[tuple](<https://docs.python.org/3/builtins/stdtypes.html#tuple>)[[Tensor](<https://pytorch.org/docs/stable/tensors.html#torch.Tensor>), ...]` – 和FP32形状 -`[1]` 缩放( 缩放)`amax / fp8_max`,或 1e- 6 用于 - `[tuple](<https://docs.python.org/3/builtins/stdtypes.html#tuple>)[[tuple](<https://docs.python.org/3/builtins/stdtypes.html#tuple>)[[Tensor](<https://pytorch.org/docs/stable/tensors.html#torch.Tensor>), ...], [tuple](<https://docs.python.org/3/builtins/stdtypes.html#tuple>)[[Tensor](<https://pytorch.org/docs/stable/tensors.html#torch.Tensor>), ...]]` – )),全零或空输入. 12月 1, 2026 (英语).
查看原始来源