[Kernel] Remove unused fake implementation (#55535)

Signed-off-by: Jee Jee Li <jeejeelee@inferact.ai>
This commit is contained in:
Jee Jee Li
2026-09-06 17:54:32 -07:00
committed by GitHub
parent 4df80187b5
commit 199cb9b964
39 changed files with 7 additions and 956 deletions
@@ -139,20 +139,8 @@ def _fp8_gemm_nt_op(
)
def _fp8_gemm_nt_op_fake(
q_input: torch.Tensor,
input_scale: torch.Tensor,
weight: torch.Tensor,
weight_scale: torch.Tensor,
output: torch.Tensor,
use_deep_gemm_e8m0: bool,
) -> None:
return None
direct_register_custom_op(
"fp8_gemm_nt_op",
_fp8_gemm_nt_op,
mutates_args=["output"],
fake_impl=_fp8_gemm_nt_op_fake,
)
@@ -777,22 +777,8 @@ def unified_attention_with_output(
)
def unified_attention_with_output_fake(
query: torch.Tensor,
key: torch.Tensor,
value: torch.Tensor,
output: torch.Tensor,
layer_name: LayerNameType,
output_scale: torch.Tensor | None = None,
output_block_scale: torch.Tensor | None = None,
kv_cache_dummy_dep: torch.Tensor | None = None,
) -> None:
return
direct_register_custom_op(
op_name="unified_attention_with_output",
op_func=unified_attention_with_output,
mutates_args=["output", "output_block_scale"],
fake_impl=unified_attention_with_output_fake,
)
@@ -1424,29 +1424,10 @@ def unified_mla_attention_with_output(
)
def unified_mla_attention_with_output_fake(
q: torch.Tensor,
kv_c_normed: torch.Tensor,
k_pe: torch.Tensor,
output: torch.Tensor,
layer_name: LayerNameType,
output_scale: torch.Tensor | None = None,
output_block_scale: torch.Tensor | None = None,
kv_cache_dummy_dep: torch.Tensor | None = None,
quant_group_size: int | None = None,
quant_scale_ue8m0: bool | None = None,
quant_col_major: bool | None = None,
quant_tma_aligned: bool | None = None,
q_dcp_replicated: torch.Tensor | None = None,
) -> None:
return
direct_register_custom_op(
op_name="unified_mla_attention_with_output",
op_func=unified_mla_attention_with_output,
mutates_args=["output", "output_block_scale"],
fake_impl=unified_mla_attention_with_output_fake,
dispatch_key=current_platform.dispatch_key,
tags=(torch.Tag.flexible_layout,),
)
@@ -241,16 +241,8 @@ def maybe_populate_sink(
self.populate_sink_kv(self_kv_cache)
def maybe_populate_sink_fake(
self_kv_cache: torch.Tensor,
layer_name: LayerNameType,
) -> None:
return
direct_register_custom_op(
op_name="maybe_populate_sink",
op_func=maybe_populate_sink,
mutates_args=["self_kv_cache"],
fake_impl=maybe_populate_sink_fake,
)
@@ -78,20 +78,10 @@ def hpc_rope_norm_forward(
rope_norm._forward_impl(qkv, kv_cache, attn_metadata, attn_layer, output)
def hpc_rope_norm_forward_fake(
qkv: torch.Tensor,
output: torch.Tensor,
layer_name: str,
) -> None:
"""Fake impl for torch.compile trace; output is a mutated arg."""
return
direct_register_custom_op(
op_name="hpc_rope_norm_forward",
op_func=hpc_rope_norm_forward,
mutates_args=["output"],
fake_impl=hpc_rope_norm_forward_fake,
)
@@ -546,20 +546,10 @@ def olmo_hybrid_gdn_full_forward(
)
def olmo_hybrid_gdn_full_forward_fake(
hidden_states: torch.Tensor,
output: torch.Tensor,
layer_name: str,
) -> None:
"""Fake implementation for torch.compile."""
return
direct_register_custom_op(
op_name="olmo_hybrid_gdn_full_forward",
op_func=olmo_hybrid_gdn_full_forward,
mutates_args=["output"],
fake_impl=olmo_hybrid_gdn_full_forward_fake,
)
@@ -1949,23 +1949,10 @@ def qwen_gdn_attention_core(
)
def gdn_attention_core_fake(
qkv_or_qkvz: torch.Tensor,
b_or_ba: torch.Tensor,
a_or_z_out: torch.Tensor,
core_attn_out: torch.Tensor,
layer_name: LayerNameType,
use_aiter: bool = False,
) -> None:
"""Fake implementation for torch.compile."""
return
direct_register_custom_op(
op_name="qwen_gdn_attention_core",
op_func=qwen_gdn_attention_core,
mutates_args=["a_or_z_out", "core_attn_out"],
fake_impl=gdn_attention_core_fake,
)
@@ -1985,20 +1972,10 @@ def qwen_gdn_attention_core_fused_norm_packed(
)
def gdn_attention_core_fused_norm_packed_fake(
mixed_qkvz: torch.Tensor,
ba: torch.Tensor,
core_attn_out: torch.Tensor,
layer_name: LayerNameType,
) -> None:
return
direct_register_custom_op(
op_name="qwen_gdn_attention_core_fused_norm_packed",
op_func=qwen_gdn_attention_core_fused_norm_packed,
mutates_args=["core_attn_out"],
fake_impl=gdn_attention_core_fused_norm_packed_fake,
)
@@ -336,18 +336,8 @@ def linear_attention(
self._forward(hidden_states=hidden_states, output=output, positions=positions)
def linear_attention_fake(
hidden_states: torch.Tensor,
output: torch.Tensor,
positions: torch.Tensor,
layer_name: str,
) -> None:
return
direct_register_custom_op(
op_name="linear_attention",
op_func=linear_attention,
mutates_args=["output"],
fake_impl=linear_attention_fake,
)
@@ -532,17 +532,8 @@ def mamba_mixer(
self.forward_impl(hidden_states=hidden_states, output=output)
def mamba_mixer_fake(
hidden_states: torch.Tensor,
output: torch.Tensor,
layer_name: LayerNameType,
) -> None:
return
direct_register_custom_op(
op_name="mamba_mixer",
op_func=mamba_mixer,
mutates_args=["output"],
fake_impl=mamba_mixer_fake,
)
@@ -1271,17 +1271,8 @@ def mamba_mixer2(
self.conv_ssm_forward(projected_states=projected_states, output=output)
def mamba_mixer2_fake(
projected_states: torch.Tensor,
output: torch.Tensor,
layer_name: LayerNameType,
) -> None:
return
direct_register_custom_op(
op_name="mamba_mixer2",
op_func=mamba_mixer2,
mutates_args=["output"],
fake_impl=mamba_mixer2_fake,
)
@@ -718,17 +718,6 @@ def _spec_aware_nonspec_subset(
return attn_out.squeeze(0)
def cpu_gdn_attention_core_fake(
mixed_qkv: torch.Tensor,
b: torch.Tensor,
a: torch.Tensor,
core_attn_out: torch.Tensor,
layer_name: LayerNameType,
) -> None:
"""Fake implementation for torch.compile."""
return
def register_cpu_gdn_attention_ops() -> None:
global _CPU_GDN_ATTENTION_OPS_REGISTERED
if _CPU_GDN_ATTENTION_OPS_REGISTERED:
@@ -738,6 +727,5 @@ def register_cpu_gdn_attention_ops() -> None:
op_name="cpu_gdn_attention_core",
op_func=cpu_gdn_attention_core,
mutates_args=["core_attn_out"],
fake_impl=cpu_gdn_attention_core_fake,
)
_CPU_GDN_ATTENTION_OPS_REGISTERED = True
@@ -373,17 +373,8 @@ def short_conv(
self.forward_native(hidden_states=hidden_states, output=output)
def short_conv_fake(
hidden_states: torch.Tensor,
output: torch.Tensor,
layer_name: str,
) -> None:
return
direct_register_custom_op(
op_name="short_conv",
op_func=short_conv,
mutates_args=["output"],
fake_impl=short_conv_fake,
)
@@ -100,23 +100,11 @@ def _flashinfer_rotary_embedding(
)
def _flashinfer_rotary_embedding_fake(
positions: torch.Tensor,
query: torch.Tensor,
key: torch.Tensor,
head_size: int,
cos_sin_cache: torch.Tensor,
is_neox: bool,
) -> None:
return
# Register flashinfer rotary embedding custom op
direct_register_custom_op(
op_name="flashinfer_rotary_embedding",
op_func=_flashinfer_rotary_embedding,
mutates_args=["query", "key"], # These tensors are modified in-place
fake_impl=_flashinfer_rotary_embedding_fake,
)
@@ -115,23 +115,10 @@ def bailing_v3_kda_attention(
)
def bailing_v3_kda_attention_fake(
q_proj_states: torch.Tensor,
k_proj_states: torch.Tensor,
v_proj_states: torch.Tensor,
g1: torch.Tensor,
beta: torch.Tensor,
core_attn_out: torch.Tensor,
layer_name: str,
) -> None:
return
direct_register_custom_op(
op_name="bailing_v3_kda_attention",
op_func=bailing_v3_kda_attention,
mutates_args=["core_attn_out"],
fake_impl=bailing_v3_kda_attention_fake,
)
@@ -33,14 +33,6 @@ def _wait_prefetch_impl(
get_offloader()._wait_for_layer(layer_idx)
def _wait_prefetch_fake(
input_tensor: torch.Tensor,
layer_idx: int,
) -> None:
"""Fake implementation for torch.compile tracing."""
return
# --- start_prefetch op ---
@@ -61,14 +53,6 @@ def _start_prefetch_impl(
get_offloader()._start_prefetch(layer_idx)
def _start_prefetch_fake(
output_tensor: torch.Tensor,
layer_idx: int,
) -> None:
"""Fake implementation for torch.compile tracing."""
return
def register_prefetch_offloader_ops() -> None:
"""Register custom ops for prefetch offloader.
@@ -79,14 +63,12 @@ def register_prefetch_offloader_ops() -> None:
op_name="wait_prefetch",
op_func=_wait_prefetch_impl,
mutates_args=["input_tensor"],
fake_impl=_wait_prefetch_fake,
)
direct_register_custom_op(
op_name="start_prefetch",
op_func=_start_prefetch_impl,
mutates_args=["output_tensor"],
fake_impl=_start_prefetch_fake,
)