Skip to content

Commit c5640d8

Browse files
committed
Update
[ghstack-poisoned]
1 parent 56008c8 commit c5640d8

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

torchtitan/models/qwen3_5/model.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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]

torchtitan/models/qwen3_5/vision_encoder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ def forward(
559559
x = x + learned_pos
560560

561561
mask_mod = get_vision_block_mask_mod(num_patch)
562-
with spmd.no_typecheck():
562+
with spmd.no_typecheck(): # hide BlockMask from typechecking; usage in Flex is also blackboxed
563563
attention_mask = _compiled_create_block_mask(
564564
mask_mod,
565565
num_vision,

0 commit comments

Comments
 (0)