[NVIDIA] Support TF32 matmul to improve MiniMax gate gemm performance (#22744)
This commit is contained in:
@@ -394,6 +394,12 @@ Please consult the documentation below and [server_args.py](https://github.com/s
|
|||||||
<td style={{padding: "9px 12px", backgroundColor: "rgba(255,255,255,0.02)"}}>`False`</td>
|
<td style={{padding: "9px 12px", backgroundColor: "rgba(255,255,255,0.02)"}}>`False`</td>
|
||||||
<td style={{padding: "9px 12px", backgroundColor: "rgba(255,255,255,0.05)"}}>bool flag (set to enable)</td>
|
<td style={{padding: "9px 12px", backgroundColor: "rgba(255,255,255,0.05)"}}>bool flag (set to enable)</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style={{padding: "9px 12px", fontWeight: 500, backgroundColor: "rgba(255,255,255,0.02)"}}>`--enable-tf32-matmul`</td>
|
||||||
|
<td style={{padding: "9px 12px", backgroundColor: "rgba(255,255,255,0.05)"}}>Enable float32 matmuls to use TensorFloat32 precision for better performance (via torch.set_float32_matmul_precision). CUDA only. Automatically enabled for MiniMax-M2 and GLM-4 models.</td>
|
||||||
|
<td style={{padding: "9px 12px", backgroundColor: "rgba(255,255,255,0.02)"}}>`False`</td>
|
||||||
|
<td style={{padding: "9px 12px", backgroundColor: "rgba(255,255,255,0.05)"}}>bool flag (set to enable)</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|||||||
@@ -533,6 +533,10 @@ class ModelRunner(ModelRunnerKVCacheMixin):
|
|||||||
if self.device == "cpu":
|
if self.device == "cpu":
|
||||||
self.init_threads_binding()
|
self.init_threads_binding()
|
||||||
|
|
||||||
|
# Set float32 matmul precision
|
||||||
|
if server_args.enable_tf32_matmul:
|
||||||
|
torch.set_float32_matmul_precision("high")
|
||||||
|
|
||||||
# Get available memory before model loading.
|
# Get available memory before model loading.
|
||||||
# Stored for later use by alloc_memory_pool().
|
# Stored for later use by alloc_memory_pool().
|
||||||
self.pre_model_load_memory = self.init_torch_distributed()
|
self.pre_model_load_memory = self.init_torch_distributed()
|
||||||
|
|||||||
@@ -649,6 +649,10 @@ class ServerArgs:
|
|||||||
Optional[str],
|
Optional[str],
|
||||||
"Path to the FlashRL quantization profile. Required when using --load-format flash_rl.",
|
"Path to the FlashRL quantization profile. Required when using --load-format flash_rl.",
|
||||||
] = None # For flash_rl load format
|
] = None # For flash_rl load format
|
||||||
|
enable_tf32_matmul: A[
|
||||||
|
bool,
|
||||||
|
"Enable float32 matmuls to use TensorFloat32 precision for better performance (via torch.set_float32_matmul_precision). CUDA only.",
|
||||||
|
] = False
|
||||||
|
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
# Memory and scheduling
|
# Memory and scheduling
|
||||||
@@ -4259,6 +4263,10 @@ class ServerArgs:
|
|||||||
logger.info(
|
logger.info(
|
||||||
"Use flashinfer_trtllm as MoE runner backend on sm100 for Glm4MoeForCausalLM"
|
"Use flashinfer_trtllm as MoE runner backend on sm100 for Glm4MoeForCausalLM"
|
||||||
)
|
)
|
||||||
|
self.enable_tf32_matmul = True
|
||||||
|
logger.info(
|
||||||
|
"Enable TF32 matmul for Glm4MoeForCausalLM model to improve gate gemm performance."
|
||||||
|
)
|
||||||
|
|
||||||
elif model_arch in [
|
elif model_arch in [
|
||||||
"FalconH1ForCausalLM",
|
"FalconH1ForCausalLM",
|
||||||
@@ -4292,6 +4300,12 @@ class ServerArgs:
|
|||||||
elif model_arch in ["ZayaForCausalLM"]:
|
elif model_arch in ["ZayaForCausalLM"]:
|
||||||
self._handle_mamba_radix_cache(model_arch=model_arch)
|
self._handle_mamba_radix_cache(model_arch=model_arch)
|
||||||
|
|
||||||
|
elif model_arch in ["MiniMaxM2ForCausalLM"]:
|
||||||
|
self.enable_tf32_matmul = True
|
||||||
|
logger.info(
|
||||||
|
"Enable TF32 matmul for MiniMaxM2ForCausalLM model to improve gate gemm performance."
|
||||||
|
)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
model_arch in ["Qwen3VLForConditionalGeneration"]
|
model_arch in ["Qwen3VLForConditionalGeneration"]
|
||||||
and is_hip()
|
and is_hip()
|
||||||
|
|||||||
Reference in New Issue
Block a user