@@ -431,8 +431,15 @@ def pack_fp8(vals):
431431 v_elem = vector .extract (v_e , static_position = [vi ], dynamic_position = [])
432432 buffer_ops .buffer_store (v_elem , vc_rsrc , vc_nf_off )
433433
434+ def _mark_token_layout_dynamic (tensor ):
435+ if hasattr (tensor , "mark_layout_dynamic" ):
436+ shape = getattr (tensor , "_orig_shape" , None )
437+ leading_dim = len (shape ) - 1 if shape is not None else - 1
438+ return tensor .mark_layout_dynamic (leading_dim = leading_dim )
439+ return flyc .from_dlpack (tensor ).mark_layout_dynamic (leading_dim = tensor .ndim - 1 )
440+
434441 @flyc .jit
435- def launch_fused_rope_cache (
442+ def _jit_launch_fused_rope_cache (
436443 Q : fx .Tensor ,
437444 K : fx .Tensor ,
438445 V : fx .Tensor ,
@@ -459,4 +466,39 @@ def launch_fused_rope_cache(
459466 stream = stream ,
460467 )
461468
469+ def launch_fused_rope_cache (
470+ Q ,
471+ K ,
472+ V ,
473+ Positions ,
474+ CosCache ,
475+ SinCache ,
476+ SlotMapping ,
477+ KeyCache ,
478+ ValueCache ,
479+ Q_out ,
480+ K_out ,
481+ num_tokens ,
482+ KScale ,
483+ VScale ,
484+ stream = fx .Stream (None ),
485+ ):
486+ return _jit_launch_fused_rope_cache (
487+ _mark_token_layout_dynamic (Q ),
488+ _mark_token_layout_dynamic (K ),
489+ _mark_token_layout_dynamic (V ),
490+ _mark_token_layout_dynamic (Positions ),
491+ CosCache ,
492+ SinCache ,
493+ _mark_token_layout_dynamic (SlotMapping ),
494+ KeyCache ,
495+ ValueCache ,
496+ _mark_token_layout_dynamic (Q_out ),
497+ _mark_token_layout_dynamic (K_out ),
498+ num_tokens ,
499+ KScale ,
500+ VScale ,
501+ stream = stream ,
502+ )
503+
462504 return launch_fused_rope_cache
0 commit comments