7575
7676import unittest
7777
78+ import pytest
7879import torch
7980import torch .nn as nn
8081import torch .nn .functional as F
82+ import torch_tensorrt
8183from parameterized import parameterized
8284from torch .testing ._internal .common_utils import run_tests
8385
@@ -321,7 +323,7 @@ class TestQwen2StyleMoE(DispatchTestCase):
321323 ("b1_s32_e4_k2_norm_fp16" , 1 , 32 , 64 , 128 , 256 , 4 , 2 , True , torch .float16 , 1e-2 ),
322324 # Larger shared expert intermediate size
323325 ("b1_s32_e4_k2_bigshared_fp16" , 1 , 32 , 64 , 128 , 512 , 4 , 2 , False , torch .float16 , 1e-2 ),
324- # FP32
326+ # FP32 (xfail on TRT-RTX only — handled in test body)
325327 ("b1_s32_e4_k2_fp32" , 1 , 32 , 64 , 128 , 256 , 4 , 2 , False , torch .float32 , 1e-3 ),
326328 # Qwen2-realistic proxy
327329 ("qwen2_proxy_fp16" , 1 , 64 , 64 , 128 , 256 , 8 , 2 , False , torch .float16 , 1e-2 ),
@@ -343,16 +345,27 @@ def test_qwen2_style(
343345 disable_tf32 = True
344346 else :
345347 disable_tf32 = False
346- self .run_test (
347- mod ,
348- [x ],
349- rtol = 1e-2 ,
350- atol = atol ,
351- enable_passes = True ,
352- use_dynamo_tracer = True ,
353- require_full_compilation = True ,
354- disable_tf32 = disable_tf32 ,
355- )
348+ try :
349+ self .run_test (
350+ mod ,
351+ [x ],
352+ rtol = 1e-2 ,
353+ atol = atol ,
354+ enable_passes = True ,
355+ use_dynamo_tracer = True ,
356+ require_full_compilation = True ,
357+ disable_tf32 = disable_tf32 ,
358+ )
359+ except AssertionError :
360+ if (
361+ name == "b1_s32_e4_k2_fp32"
362+ and torch_tensorrt .ENABLED_FEATURES .tensorrt_rtx
363+ ):
364+ pytest .xfail (
365+ "TF32 vs FP32 MoE top-k divergence on TensorRT-RTX; "
366+ "disable_tf32 is not effective on TRT-RTX."
367+ )
368+ raise
356369
357370
358371# ---------------------------------------------------------------------------
0 commit comments