@@ -4551,7 +4551,11 @@ def aten_ops_nonzero(
45514551 )
45524552
45534553
4554- @dynamo_tensorrt_converter (torch .ops .aten .linear .default , supports_dynamic_shapes = True )
4554+ @dynamo_tensorrt_converter (
4555+ torch .ops .aten .linear .default ,
4556+ capability_validator = gemm_capability_validator ,
4557+ supports_dynamic_shapes = True ,
4558+ )
45554559def aten_ops_linear (
45564560 ctx : ConversionContext ,
45574561 target : Target ,
@@ -4570,9 +4574,43 @@ def aten_ops_linear(
45704574 )
45714575
45724576
4577+ def attention_capability_validator (
4578+ node : Node , settings : Optional [CompilationSettings ] = None
4579+ ) -> bool :
4580+ """Reject fused attention TensorRT-RTX cannot serve when Turing (SM 7.5) is a target.
4581+
4582+ A fused attention op carries the same FP32 GEMMs ``gemm_capability_validator``
4583+ rejects, but inside the converter, so the graph holds one node and no ``mm``/``bmm``
4584+ for that guard to see. On Turing TRT-RTX this results in failure. Only the q/k/v
4585+ dtypes matter, so FP16 attention keeps running on TensorRT.
4586+ """
4587+ if not trt_rtx_targets_turing (settings ):
4588+ return True
4589+
4590+ unsupported_dtypes = (torch .float32 ,)
4591+
4592+ def is_unsupported (operand : Argument ) -> bool :
4593+ val = operand .meta .get ("val" ) if hasattr (operand , "meta" ) else None
4594+ return bool (getattr (val , "dtype" , None ) in unsupported_dtypes )
4595+
4596+ qkv = node .args [:3 ] # query, key, value
4597+ if any (map (is_unsupported , qkv )):
4598+ _LOGGER .debug (
4599+ "Attention '%s' is not supported on TensorRT-RTX for Turing (SM 7.5). "
4600+ "Falling back to PyTorch." ,
4601+ node .name ,
4602+ )
4603+ return False
4604+
4605+ return True
4606+
4607+
45734608def scaled_dot_product_attention_validator (
45744609 node : Node , settings : Optional [CompilationSettings ] = None
45754610) -> bool :
4611+ if not attention_capability_validator (node , settings ):
4612+ return False
4613+
45764614 attn_mask = args_bounds_check (node .args , 3 , None )
45774615 is_causal = args_bounds_check (node .args , 5 , False )
45784616 if is_causal and attn_mask is not None :
@@ -4671,6 +4709,9 @@ def aten_ops_scaled_dot_product_attention(
46714709def scaled_dot_product_flash_attention_validator (
46724710 node : Node , settings : Optional [CompilationSettings ] = None
46734711) -> bool :
4712+ if not attention_capability_validator (node , settings ):
4713+ return False
4714+
46744715 if args_bounds_check (node .args , 5 , False ):
46754716 _LOGGER .debug ("return_debug_mask is not yet supported." )
46764717 return False
@@ -4765,6 +4806,9 @@ def aten_ops_scaled_dot_product_flash_attention(
47654806def scaled_dot_product_efficient_attention_validator (
47664807 node : Node , settings : Optional [CompilationSettings ] = None
47674808) -> bool :
4809+ if not attention_capability_validator (node , settings ):
4810+ return False
4811+
47684812 if args_bounds_check (node .args , 4 , False ):
47694813 _LOGGER .debug ("compute_log_sumexp is not yet supported." )
47704814 return False
@@ -4851,6 +4895,7 @@ def scaled_dot_product_cudnn_attention_validator(
48514895 _LOGGER .debug ("return_debug_mask is not yet supported." )
48524896 return False
48534897
4898+ # Delegating also picks up the Turing (SM 7.5) dtype guard.
48544899 return scaled_dot_product_efficient_attention_validator (node , settings )
48554900
48564901
0 commit comments