[CI] change spell checker from codespell to typos (#18711)
Signed-off-by: Andy Xie <andy.xning@gmail.com>
This commit is contained in:
+3
-3
@@ -1550,10 +1550,10 @@ def moe_wna16_gemm(input: torch.Tensor, output: torch.Tensor,
|
||||
|
||||
|
||||
def topk_softmax(topk_weights: torch.Tensor, topk_ids: torch.Tensor,
|
||||
token_expert_indicies: torch.Tensor,
|
||||
token_expert_indices: torch.Tensor,
|
||||
gating_output: torch.Tensor) -> None:
|
||||
torch.ops._moe_C.topk_softmax(topk_weights, topk_ids,
|
||||
token_expert_indicies, gating_output)
|
||||
torch.ops._moe_C.topk_softmax(topk_weights, topk_ids, token_expert_indices,
|
||||
gating_output)
|
||||
|
||||
|
||||
def moe_wna16_marlin_gemm(input: torch.Tensor, output: Optional[torch.Tensor],
|
||||
|
||||
@@ -373,7 +373,7 @@ class CommonAttentionState(AttentionState):
|
||||
f"Expected attn_backend name to be either 'XFORMERS'," \
|
||||
f"'ROCM_FLASH', or 'FLASH_ATTN', but " \
|
||||
f"got '{self.runner.attn_backend.get_name()}'"
|
||||
self._add_additonal_input_buffers_for_enc_dec_model(
|
||||
self._add_additional_input_buffers_for_enc_dec_model(
|
||||
attn_metadata=attn_metadata, input_buffers=input_buffers)
|
||||
return input_buffers
|
||||
|
||||
@@ -427,7 +427,7 @@ class CommonAttentionState(AttentionState):
|
||||
attn_metadata.max_encoder_seq_len = self.runner.max_seq_len_to_capture
|
||||
attn_metadata.num_encoder_tokens = 0
|
||||
|
||||
def _add_additonal_input_buffers_for_enc_dec_model(
|
||||
def _add_additional_input_buffers_for_enc_dec_model(
|
||||
self, attn_metadata, input_buffers: Dict[str, Any]):
|
||||
"""
|
||||
Saves additional input buffers specific to the encoder-decoder model
|
||||
|
||||
@@ -40,7 +40,7 @@ class Internlm2ToolParser(ToolParser):
|
||||
request.skip_special_tokens = False
|
||||
return request
|
||||
|
||||
def get_argments(self, obj):
|
||||
def get_arguments(self, obj):
|
||||
if "parameters" in obj:
|
||||
return obj.get("parameters")
|
||||
elif "arguments" in obj:
|
||||
@@ -119,9 +119,9 @@ class Internlm2ToolParser(ToolParser):
|
||||
# now we know we're on the same tool call and we're streaming
|
||||
# arguments
|
||||
else:
|
||||
prev_arguments = self.get_argments(
|
||||
prev_arguments = self.get_arguments(
|
||||
self.prev_tool_call_arr[self.current_tool_id])
|
||||
cur_arguments = self.get_argments(tool_call_arr)
|
||||
cur_arguments = self.get_arguments(tool_call_arr)
|
||||
|
||||
# not arguments generated
|
||||
if not cur_arguments and not prev_arguments:
|
||||
@@ -170,7 +170,7 @@ class Internlm2ToolParser(ToolParser):
|
||||
# check to see if the name is defined and has been sent. if so,
|
||||
# stream the name - otherwise keep waiting
|
||||
# finish by setting old and returning None as base case
|
||||
tool_call_arr["arguments"] = self.get_argments(tool_call_arr)
|
||||
tool_call_arr["arguments"] = self.get_arguments(tool_call_arr)
|
||||
self.prev_tool_call_arr = [tool_call_arr]
|
||||
return delta
|
||||
except Exception:
|
||||
|
||||
+1
-1
@@ -1202,7 +1202,7 @@ class LinearScalingRotaryEmbeddingWithLoRA(BaseLayerWithLoRA):
|
||||
multiple LoRA adapters with a specialized kernel.
|
||||
|
||||
Replace LinearScalingRotaryEmbedding with MultiLinearScalingRotaryEmbedding
|
||||
which can handle multi lora adapters in a specialied kernel.
|
||||
which can handle multi lora adapters in a specialized kernel.
|
||||
"""
|
||||
|
||||
def __init__(self, base_layer: RotaryEmbedding) -> None:
|
||||
|
||||
@@ -68,11 +68,11 @@ def convert_mapping(
|
||||
LoRA indices.
|
||||
sampler_indices: Tensor of shape [batch_size] mapping requests to
|
||||
LoRA indices for sampler. For generation, this will be the
|
||||
same as base_indicies. For prefill, this will map requests
|
||||
same as base_indices. For prefill, this will map requests
|
||||
to LoRA indices.
|
||||
sampler_indices_padded: Tensor of shape [batch_size] mapping
|
||||
requests to LoRA indices for sampler with padding.
|
||||
Same as sampler_indicies, but -1 is replaced with
|
||||
Same as sampler_indices, but -1 is replaced with
|
||||
max_loras.
|
||||
embeddings_indices: Tensor of shape [2, batch_size] mapping
|
||||
requests to embedding indices. First row is for embeddings
|
||||
|
||||
@@ -319,7 +319,7 @@ class MambaMixer2(CustomOp):
|
||||
n_groups == 1, # if there was only one group
|
||||
)
|
||||
intermediate_settings = (intermediate_size, 0, False)
|
||||
head_setings = (self.num_heads, 0, False)
|
||||
head_settings = (self.num_heads, 0, False)
|
||||
|
||||
# - the weight already has a "weight_loader" attribute
|
||||
# which set_weight_attrs will raise if we do not
|
||||
@@ -372,7 +372,7 @@ class MambaMixer2(CustomOp):
|
||||
intermediate_settings,
|
||||
group_shard_settings,
|
||||
group_shard_settings,
|
||||
head_setings, # for dt
|
||||
head_settings, # for dt
|
||||
],
|
||||
self.tp_size,
|
||||
tp_rank,
|
||||
|
||||
@@ -516,7 +516,7 @@ def _chunk_state_varlen_kernel(
|
||||
offs_n[None, :] * stride_chunk_states_dstate)
|
||||
else:
|
||||
|
||||
# - this seems repetitve, buts its to help the compiler
|
||||
# - this seems repetitive, buts its to help the compiler
|
||||
if start_idx < pid_c * chunk_size:
|
||||
past_states_ptrs = chunk_states_ptr + (
|
||||
offs_m[:, None] * stride_chunk_states_hdim +
|
||||
|
||||
@@ -219,7 +219,7 @@ def per_token_group_quant_int8(
|
||||
quantized tensor along with the scaling factor used for quantization.
|
||||
|
||||
Args:
|
||||
x: The input tenosr with ndim >= 2.
|
||||
x: The input tensor with ndim >= 2.
|
||||
group_size: The group size used for quantization.
|
||||
eps: The minimum to avoid dividing zero.
|
||||
dtype: The dype of output tensor. Note that only `torch.int8`
|
||||
|
||||
@@ -401,7 +401,7 @@ class BitsAndBytesModelLoader(BaseModelLoader):
|
||||
self.target_modules.append(
|
||||
name.replace(rep_name, sub_name))
|
||||
# Add original module name even if the module has stacked map,
|
||||
# in case model has a mixture of disk-merged and disk-splitted
|
||||
# in case model has a mixture of disk-merged and disk-split
|
||||
# weights with same last name.
|
||||
self.target_modules.append(name)
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ class BaiChuanAttention(nn.Module):
|
||||
self.num_heads = (self.total_num_heads //
|
||||
tensor_model_parallel_world_size)
|
||||
self.head_dim = hidden_size // self.total_num_heads
|
||||
self.postion_embedding = position_embedding
|
||||
self.position_embedding = position_embedding
|
||||
self.rope_theta = rope_theta
|
||||
self.max_position_embeddings = max_position_embeddings
|
||||
|
||||
@@ -151,7 +151,7 @@ class BaiChuanAttention(nn.Module):
|
||||
quant_config=quant_config,
|
||||
)
|
||||
# Create the alibi slopes and slice them.
|
||||
if self.postion_embedding == "ALIBI":
|
||||
if self.position_embedding == "ALIBI":
|
||||
tp_rank = get_tensor_model_parallel_rank()
|
||||
head_start = tp_rank * self.num_heads
|
||||
head_end = (tp_rank + 1) * self.num_heads
|
||||
@@ -187,7 +187,7 @@ class BaiChuanAttention(nn.Module):
|
||||
) -> torch.Tensor:
|
||||
qkv, _ = self.W_pack(hidden_states)
|
||||
q, k, v = qkv.chunk(chunks=3, dim=-1)
|
||||
if self.postion_embedding != "ALIBI":
|
||||
if self.position_embedding != "ALIBI":
|
||||
q, k = self.rotary_emb(positions, q, k)
|
||||
attn_output = self.attn(q, k, v)
|
||||
output, _ = self.o_proj(attn_output)
|
||||
|
||||
@@ -344,7 +344,7 @@ class DeepseekVLV2ForCausalLM(nn.Module, SupportsMultiModal, SupportsPP):
|
||||
self.image_newline = nn.Parameter(
|
||||
torch.randn(self.projector_config.n_embed) * embed_std)
|
||||
# This is a typo in original implementation
|
||||
self.view_seperator = nn.Parameter(
|
||||
self.view_separator = nn.Parameter(
|
||||
torch.randn(self.projector_config.n_embed) * embed_std)
|
||||
else:
|
||||
raise ValueError(
|
||||
@@ -549,13 +549,13 @@ class DeepseekVLV2ForCausalLM(nn.Module, SupportsMultiModal, SupportsPP):
|
||||
if self.global_view_pos == "head":
|
||||
global_local_features = torch.cat([
|
||||
global_features,
|
||||
self.view_seperator[None, :],
|
||||
self.view_separator[None, :],
|
||||
local_features,
|
||||
])
|
||||
else:
|
||||
global_local_features = torch.cat([
|
||||
local_features,
|
||||
self.view_seperator[None, :],
|
||||
self.view_separator[None, :],
|
||||
global_features,
|
||||
])
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ class EAGLE(nn.Module):
|
||||
return logits
|
||||
|
||||
def load_weights(self, weights: Iterable[tuple[str, torch.Tensor]]):
|
||||
# This implementation is incompitable with https://huggingface.co/yuhuili/EAGLE-LLaMA3-Instruct-8B
|
||||
# This implementation is incompatible with https://huggingface.co/yuhuili/EAGLE-LLaMA3-Instruct-8B
|
||||
# due to missing lm_head weights and its config being that of a
|
||||
# Llama model. Here's a compatible version with the same weights:
|
||||
# https://huggingface.co/abhigoyal/EAGLE-LLaMA3-Instruct-8B-vllm
|
||||
|
||||
@@ -634,13 +634,13 @@ class Gemma3ForConditionalGeneration(nn.Module, SupportsMultiModal, SupportsPP,
|
||||
kwargs["has_images"] = True
|
||||
# NOTE(woosuk): Here, we distinguish the sequences by the position id 0.
|
||||
# This is a HACK. Fix this.
|
||||
start_idices = (positions == 0).cpu().nonzero()
|
||||
num_seqs = len(start_idices)
|
||||
start_indices = (positions == 0).cpu().nonzero()
|
||||
num_seqs = len(start_indices)
|
||||
seq_lens = []
|
||||
for i in range(num_seqs):
|
||||
start_idx = start_idices[i].item()
|
||||
start_idx = start_indices[i].item()
|
||||
if i < num_seqs - 1:
|
||||
end_idx = start_idices[i + 1].item()
|
||||
end_idx = start_indices[i + 1].item()
|
||||
else:
|
||||
end_idx = len(input_ids)
|
||||
seq_lens.append(end_idx - start_idx)
|
||||
|
||||
@@ -52,7 +52,7 @@ class Llama4MoE(nn.Module):
|
||||
renormalize: bool,
|
||||
) -> tuple[torch.Tensor, torch.Tensor]:
|
||||
router_scores, router_indices = fast_topk(gating_output, topk, dim=-1)
|
||||
# psuedo-standard is that the router scores are floats
|
||||
# pseudo-standard is that the router scores are floats
|
||||
router_scores = torch.sigmoid(router_scores.float())
|
||||
return (router_scores, router_indices.to(torch.int32))
|
||||
|
||||
|
||||
@@ -114,9 +114,9 @@ class MixtralMoE(nn.Module):
|
||||
f"Tensor parallel size {self.tp_size} is greater than "
|
||||
f"the number of experts {self.num_total_experts}.")
|
||||
# Split experts equally between ranks
|
||||
self.expert_indicies = np.array_split(range(
|
||||
self.num_total_experts), self.tp_size)[self.rank].tolist()
|
||||
if not self.expert_indicies:
|
||||
self.expert_indices = np.array_split(range(self.num_total_experts),
|
||||
self.tp_size)[self.rank].tolist()
|
||||
if not self.expert_indices:
|
||||
raise ValueError(
|
||||
f"Rank {self.rank} has no experts assigned to it.")
|
||||
|
||||
@@ -125,7 +125,7 @@ class MixtralMoE(nn.Module):
|
||||
config.hidden_size,
|
||||
config.intermediate_size,
|
||||
quant_config=quant_config)
|
||||
if idx in self.expert_indicies else None
|
||||
if idx in self.expert_indices else None
|
||||
for idx in range(self.num_total_experts)
|
||||
])
|
||||
self.gate = ReplicatedLinear(config.hidden_size,
|
||||
@@ -146,7 +146,7 @@ class MixtralMoE(nn.Module):
|
||||
routing_weights /= routing_weights.sum(dim=-1, keepdim=True)
|
||||
|
||||
final_hidden_states = None
|
||||
for expert_idx in self.expert_indicies:
|
||||
for expert_idx in self.expert_indices:
|
||||
expert_layer = self.experts[expert_idx]
|
||||
expert_mask = (selected_experts == expert_idx)
|
||||
expert_weights = (routing_weights * expert_mask).sum(dim=-1,
|
||||
|
||||
@@ -283,7 +283,7 @@ class OvisProcessingInfo(BaseProcessingInfo):
|
||||
def get_image_size_with_most_features(self) -> ImageSize:
|
||||
height, width = self.get_hf_processor().get_image_size()
|
||||
hs = self.get_hf_config().visual_tokenizer_config.hidden_stride
|
||||
# NOTE(Isotr0py): 9 is `max_partion` hardcoded in original code
|
||||
# NOTE(Isotr0py): 9 is `max_partition` hardcoded in original code
|
||||
# https://huggingface.co/AIDC-AI/Ovis2-1B/blob/main/modeling_ovis.py#L96
|
||||
return ImageSize(width=width * hs * 9, height=height * hs * 9)
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ class Phi3SmallSelfAttention(nn.Module):
|
||||
self.num_q_per_kv = self.num_heads // self.num_key_value_heads
|
||||
if self.tp_size > 1:
|
||||
assert self.num_key_value_heads % self.tp_size == 0
|
||||
self.num_kv_heads_per_partion = max(
|
||||
self.num_kv_heads_per_partition = max(
|
||||
1, self.num_key_value_heads // self.tp_size)
|
||||
self.num_heads_per_partition = self.num_heads // self.tp_size
|
||||
|
||||
@@ -212,7 +212,7 @@ class Phi3SmallSelfAttention(nn.Module):
|
||||
bs_params = {
|
||||
'max_seqlen': self.max_position_embeddings,
|
||||
'num_heads': self.num_heads_per_partition,
|
||||
"num_kv_heads": self.num_kv_heads_per_partion,
|
||||
"num_kv_heads": self.num_kv_heads_per_partition,
|
||||
"block_size": self.sparse_block_size,
|
||||
"local_blocks": self.local_blocks,
|
||||
"vert_stride": self.vert_stride,
|
||||
@@ -222,7 +222,7 @@ class Phi3SmallSelfAttention(nn.Module):
|
||||
self.attn = Attention(self.num_heads_per_partition,
|
||||
self.head_dim,
|
||||
self.scale,
|
||||
num_kv_heads=self.num_kv_heads_per_partion,
|
||||
num_kv_heads=self.num_kv_heads_per_partition,
|
||||
cache_config=cache_config,
|
||||
quant_config=quant_config,
|
||||
blocksparse_params=bs_params,
|
||||
@@ -243,8 +243,8 @@ class Phi3SmallSelfAttention(nn.Module):
|
||||
# NOTE: this is required by RotaryEmbed, which indeed does not have to
|
||||
# TODO: allow 3D QK for rotary forward
|
||||
q = q.reshape(-1, self.head_dim * self.num_heads_per_partition)
|
||||
k = k.reshape(-1, self.head_dim * self.num_kv_heads_per_partion)
|
||||
v = v.reshape(-1, self.head_dim * self.num_kv_heads_per_partion)
|
||||
k = k.reshape(-1, self.head_dim * self.num_kv_heads_per_partition)
|
||||
v = v.reshape(-1, self.head_dim * self.num_kv_heads_per_partition)
|
||||
|
||||
q, k = self.rotary_emb(positions, q, k)
|
||||
attn_output = self.attn(q, k, v)
|
||||
|
||||
@@ -41,7 +41,7 @@ class ConformerEncoderLayer(nn.Module):
|
||||
for the last pointwise conv after swish activation.
|
||||
depthwise_seperable_out_channel: int
|
||||
if set different to 0, the number of
|
||||
depthwise_seperable_out_channel will be used as a
|
||||
depthwise_seperable_out_channel will be used as a
|
||||
channel_out of the second conv1d layer.
|
||||
otherwise, it equal to 0, the second conv1d layer is skipped.
|
||||
depthwise_multiplier: int
|
||||
@@ -126,7 +126,7 @@ class ConformerEncoderLayer(nn.Module):
|
||||
(Multi-Head Attention),
|
||||
1 = typical Multi-Head Attention,
|
||||
1 < attn_group_sizes < attention_heads = Grouped-Query Attention
|
||||
attn_group_sizes = attenion_heads = Multi-Query Attention
|
||||
attn_group_sizes = attention_heads = Multi-Query Attention
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
@@ -318,7 +318,7 @@ class TransformerEncoderBase(abc.ABC, nn.Module):
|
||||
1 = typical Multi-Head Attention,
|
||||
1 < attention_group_size < attention_heads = Grouped-Query
|
||||
Attention
|
||||
attention_group_size = attenion_heads = Multi-Query Attention
|
||||
attention_group_size = attention_heads = Multi-Query Attention
|
||||
"""
|
||||
|
||||
def __init__(
|
||||
@@ -744,7 +744,7 @@ class ConformerEncoder(TransformerEncoderBase):
|
||||
1 = typical Multi-Head Attention,
|
||||
1 < attention_group_size < attention_heads = Grouped-Query
|
||||
Attention
|
||||
attention_group_size = attenion_heads = Multi-Query Attention
|
||||
attention_group_size = attention_heads = Multi-Query Attention
|
||||
"""
|
||||
|
||||
extra_multi_layer_output_idxs: list[int]
|
||||
|
||||
@@ -147,15 +147,15 @@ class mp(torch.autograd.Function):
|
||||
|
||||
grad_at_output = grad_at_output * multiplier
|
||||
|
||||
grad_at_scores_expaned = masked_gates * grad_at_output.mul(-1)
|
||||
grad_at_scores_expaned.scatter_add_(
|
||||
grad_at_scores_expanded = masked_gates * grad_at_output.mul(-1)
|
||||
grad_at_scores_expanded.scatter_add_(
|
||||
dim=-1,
|
||||
index=selected_experts,
|
||||
src=grad_at_output,
|
||||
)
|
||||
|
||||
return (
|
||||
grad_at_scores_expaned,
|
||||
grad_at_scores_expanded,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
|
||||
@@ -324,7 +324,7 @@ def merge_and_sort_multimodal_metadata(
|
||||
Returns:
|
||||
list[str]: List of item modalities in order of their positions in the
|
||||
input sequence.
|
||||
list[PlaceholderRange]: Sorted list of all PlaceholdeRanges from
|
||||
list[PlaceholderRange]: Sorted list of all PlaceholderRanges from
|
||||
mm_positions.
|
||||
Optional[list[str]]: Sorted list of all hashes from mm_hashes if given,
|
||||
None otherwise.
|
||||
|
||||
@@ -68,7 +68,7 @@ class OvisProcessor(ProcessorMixin):
|
||||
"""
|
||||
|
||||
attributes = ["image_processor", "tokenizer"]
|
||||
valid_kwargs = ["chat_template", "image_pad_token", "image_segement_len"]
|
||||
valid_kwargs = ["chat_template", "image_pad_token", "image_segment_len"]
|
||||
|
||||
image_processor_class = "AutoImageProcessor"
|
||||
tokenizer_class = "AutoTokenizer"
|
||||
|
||||
@@ -886,7 +886,7 @@ class HPUModelRunnerBase(ModelRunnerBase[TModelInputForHPU]):
|
||||
num_decode_tokens=0,
|
||||
slot_mapping=slot_mapping,
|
||||
multi_modal_placeholder_index_maps=
|
||||
None, # FIXME(kzawora): mutli-modality will not work here
|
||||
None, # FIXME(kzawora): multi-modality will not work here
|
||||
enable_kv_scales_calculation=False,
|
||||
)
|
||||
multi_modal_kwargs = MultiModalKwargs.batch(multi_modal_kwargs_list)
|
||||
|
||||
@@ -277,7 +277,7 @@ class StatefulModelInput(BroadcastableModelInput):
|
||||
assert fmi.input_tokens.shape[0] >= self.num_seqs
|
||||
fmi_new_input_tokens: torch.Tensor = fmi.input_tokens[:self.num_seqs]
|
||||
|
||||
# Update frozen_model_input::input_positons.
|
||||
# Update frozen_model_input::input_positions.
|
||||
assert fmi.input_positions is not None
|
||||
assert fmi.input_positions.shape[0] >= self.num_seqs
|
||||
fmi_new_input_positions: torch.Tensor = fmi.input_positions[:self.
|
||||
|
||||
@@ -798,9 +798,9 @@ class ModelWrapper(nn.Module):
|
||||
"""
|
||||
batch_size, seq_len = token_ids.shape
|
||||
# Calculate the positions to sample from.
|
||||
start_indicies = torch.arange(
|
||||
start_indices = torch.arange(
|
||||
batch_size, dtype=torch.int32, device=input_lens.device) * seq_len
|
||||
logits_indices = start_indicies + input_lens - 1
|
||||
logits_indices = start_indices + input_lens - 1
|
||||
attn_metadata = get_forward_context().attn_metadata
|
||||
|
||||
# FIXME(woosuk): This is a temporary hack to avoid using the existing
|
||||
@@ -822,14 +822,14 @@ class ModelWrapper(nn.Module):
|
||||
num_kv_heads, num_blocks, block_size, _ = kv_caches[0][0].shape
|
||||
slot_mapping = attn_metadata.slot_mapping
|
||||
slot_mapping = slot_mapping.flatten()
|
||||
head_indicies = torch.arange(0,
|
||||
num_kv_heads,
|
||||
device=slot_mapping.device,
|
||||
dtype=slot_mapping.dtype)
|
||||
head_indicies *= block_size * num_blocks
|
||||
head_indices = torch.arange(0,
|
||||
num_kv_heads,
|
||||
device=slot_mapping.device,
|
||||
dtype=slot_mapping.dtype)
|
||||
head_indices *= block_size * num_blocks
|
||||
slot_mapping = slot_mapping.repeat_interleave(num_kv_heads).view(
|
||||
-1, num_kv_heads)
|
||||
slot_mapping = slot_mapping + head_indicies.view(1, -1)
|
||||
slot_mapping = slot_mapping + head_indices.view(1, -1)
|
||||
slot_mapping = slot_mapping.flatten()
|
||||
attn_metadata.slot_mapping = slot_mapping
|
||||
|
||||
|
||||
Reference in New Issue
Block a user