[Refactor] Remove dead code multiple places (#60120)
Signed-off-by: yewentao256 <zhyanwentao@126.com>
This commit is contained in:
@@ -564,9 +564,6 @@ class BertMLMHead(nn.Module):
|
||||
self.layer_norm = nn.LayerNorm(hidden_size, eps=layer_norm_eps)
|
||||
self.decoder = nn.Linear(hidden_size, vocab_size, bias=True)
|
||||
|
||||
def tie_weights_with_embeddings(self, embeddings_weight: torch.Tensor):
|
||||
self.decoder.weight = embeddings_weight
|
||||
|
||||
def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
|
||||
x = self.dense(hidden_states)
|
||||
x = self.activation(x)
|
||||
|
||||
@@ -129,13 +129,6 @@ class BlipAttention(nn.Module):
|
||||
prefix=f"{prefix}.attn",
|
||||
)
|
||||
|
||||
def _shape(self, tensor: torch.Tensor, seq_len: int, bsz: int):
|
||||
return (
|
||||
tensor.view(bsz, seq_len, self.num_heads, self.head_dim)
|
||||
.transpose(1, 2)
|
||||
.contiguous()
|
||||
)
|
||||
|
||||
def forward(
|
||||
self,
|
||||
hidden_states: torch.Tensor,
|
||||
|
||||
@@ -269,17 +269,6 @@ class DiffusionGemmaForConditionalGeneration(
|
||||
eps=getattr(text_config, "rms_norm_eps", 1e-6),
|
||||
)
|
||||
|
||||
def compute_self_conditioning(
|
||||
self,
|
||||
inputs_embeds: torch.Tensor,
|
||||
probs: torch.Tensor,
|
||||
) -> torch.Tensor:
|
||||
embed_weight = self.model.embed_tokens.weight
|
||||
soft_embeds = torch.matmul(
|
||||
probs.to(embed_weight.dtype), embed_weight
|
||||
) * self.model.normalizer.to(inputs_embeds.dtype)
|
||||
return self.self_conditioning(inputs_embeds, soft_embeds)
|
||||
|
||||
# ------------------------------------------------------------------ #
|
||||
# Multimodal: reuse Gemma4's image parsing, processing & embedding
|
||||
# ------------------------------------------------------------------ #
|
||||
|
||||
@@ -255,25 +255,6 @@ class KeyeVisionEmbeddings(nn.Module):
|
||||
patch_pos_embed = patch_pos_embed.permute(0, 2, 3, 1).view(1, -1, dim)
|
||||
return patch_pos_embed
|
||||
|
||||
def fetch_position_embedding_lfu_cache(self, embeddings, h, w, max_cache: int = 20):
|
||||
grid = (h, w)
|
||||
if grid in self.cache_position_embedding:
|
||||
self.cache_position_count[grid] += 1
|
||||
return self.cache_position_embedding[grid]
|
||||
|
||||
if len(self.cache_position_embedding) >= max_cache:
|
||||
min_hit_grid = min(
|
||||
self.cache_position_count,
|
||||
key=self.cache_position_count.__getitem__,
|
||||
)
|
||||
self.cache_position_count.pop(min_hit_grid)
|
||||
self.cache_position_embedding.pop(min_hit_grid)
|
||||
|
||||
position_embedding = self.interpolate_pos_encoding(embeddings, h, w, True)
|
||||
self.cache_position_count[grid] = 1
|
||||
self.cache_position_embedding[grid] = position_embedding
|
||||
return position_embedding
|
||||
|
||||
def forward(
|
||||
self,
|
||||
pixel_values: torch.FloatTensor,
|
||||
|
||||
@@ -455,27 +455,6 @@ class SiglipVisionEmbeddings(nn.Module):
|
||||
patch_pos_embed = patch_pos_embed.permute(0, 2, 3, 1).view(1, -1, dim)
|
||||
return patch_pos_embed
|
||||
|
||||
def fetch_position_embedding_lfu_cache(
|
||||
self, embeddings: torch.Tensor, h: int, w: int, max_cache: int = 20
|
||||
):
|
||||
grid = (h, w)
|
||||
if grid in self.cache_position_embedding:
|
||||
self.cache_position_count[grid] += 1
|
||||
return self.cache_position_embedding[grid]
|
||||
|
||||
if len(self.cache_position_embedding) >= max_cache:
|
||||
min_hit_grid = min(
|
||||
self.cache_position_count,
|
||||
key=self.cache_position_count.__getitem__,
|
||||
)
|
||||
self.cache_position_count.pop(min_hit_grid)
|
||||
self.cache_position_embedding.pop(min_hit_grid)
|
||||
|
||||
position_embedding = self.interpolate_pos_encoding(embeddings, h, w, True)
|
||||
self.cache_position_count[grid] = 1
|
||||
self.cache_position_embedding[grid] = position_embedding
|
||||
return position_embedding
|
||||
|
||||
def forward(
|
||||
self,
|
||||
pixel_values: torch.FloatTensor,
|
||||
|
||||
@@ -1256,12 +1256,6 @@ class AudioEmbedding(nn.Module):
|
||||
self.input_embeds = None
|
||||
self.audio_embed_sizes = None
|
||||
|
||||
def set_audio_embeds(self, input_embeds: torch.Tensor) -> None:
|
||||
self.input_embeds = input_embeds
|
||||
|
||||
def set_audio_embed_sizes(self, audio_embed_sizes: torch.Tensor) -> None:
|
||||
self.audio_embed_sizes = audio_embed_sizes
|
||||
|
||||
def get_audio_features(
|
||||
self,
|
||||
input_embeds: torch.Tensor,
|
||||
|
||||
@@ -17,7 +17,6 @@ from vllm.distributed import (
|
||||
get_pp_group,
|
||||
get_tensor_model_parallel_rank,
|
||||
get_tensor_model_parallel_world_size,
|
||||
get_tp_group,
|
||||
)
|
||||
from vllm.logger import init_logger
|
||||
from vllm.model_executor.layers.activation import SiluAndMul, SwigluStepAndMul
|
||||
@@ -459,7 +458,6 @@ class Step3p5DecoderLayer(nn.Module):
|
||||
f"Unsupported attention implementation: {config.att_impl_type}"
|
||||
)
|
||||
self.use_moe = False
|
||||
self.tp_group = get_tp_group()
|
||||
self.use_fused_all_reduce = (
|
||||
get_tensor_model_parallel_world_size() > 1
|
||||
and get_dp_group().world_size == 1
|
||||
@@ -496,13 +494,6 @@ class Step3p5DecoderLayer(nn.Module):
|
||||
)
|
||||
self.prefix = prefix
|
||||
|
||||
def add_and_maybe_inplace_all_reduce(
|
||||
self, in1: torch.Tensor, in2: torch.Tensor
|
||||
) -> torch.Tensor:
|
||||
if not self.use_fused_all_reduce:
|
||||
return in1 + in2
|
||||
return self.tp_group.all_reduce(in1 + in2)
|
||||
|
||||
def forward(
|
||||
self, positions: torch.Tensor, hidden_states: torch.Tensor
|
||||
) -> torch.Tensor:
|
||||
|
||||
Reference in New Issue
Block a user