@@ -198,8 +198,10 @@ def forward(
198198 if self .backend == "torch_native" :
199199 return _torch_native_gated_delta (q , k , v , g , beta )
200200
201- if self .backend == "fla_chunked" :
202- with spmd .no_typecheck ():
201+ with spmd .no_typecheck ():
202+ # FLA kernels call into third-party custom autograd functions; we can't typecheck.
203+ # ShardingConfig handles output re-annotation.
204+ if self .backend == "fla_chunked" :
203205 result = _fla_chunk_gated_delta_rule (
204206 q ,
205207 k ,
@@ -208,8 +210,7 @@ def forward(
208210 beta ,
209211 use_qk_l2norm_in_kernel = True ,
210212 )
211- elif self .backend == "fla_fused_recurrent" :
212- with spmd .no_typecheck ():
213+ elif self .backend == "fla_fused_recurrent" :
213214 result = _fla_fused_recurrent_gated_delta_rule (
214215 q ,
215216 k ,
@@ -218,11 +219,11 @@ def forward(
218219 beta = beta ,
219220 use_qk_l2norm_in_kernel = True ,
220221 )
221- else :
222- raise ValueError (
223- f"Unknown fla_backend '{ self .backend } '. "
224- "Valid: 'fla_chunked', 'fla_fused_recurrent', 'torch_native'."
225- )
222+ else :
223+ raise ValueError (
224+ f"Unknown fla_backend '{ self .backend } '. "
225+ "Valid: 'fla_chunked', 'fla_fused_recurrent', 'torch_native'."
226+ )
226227
227228 # FLA kernels return (output, final_state); we only need output
228229 return result [0 ]
0 commit comments