[Refactor] Remove dead code in multiple files (#49745)
Signed-off-by: yewentao256 <zhyanwentao@126.com>
This commit is contained in:
@@ -592,37 +592,6 @@ def rocm_fp8_mqa_logits(
|
||||
return fp8_mqa_logits_torch(q, kv, weights, cu_seqlen_ks, cu_seqlen_ke)
|
||||
|
||||
|
||||
def _topk_indices_torch(
|
||||
logits: torch.Tensor,
|
||||
topk_tokens: int,
|
||||
row_starts: torch.Tensor | None = None,
|
||||
) -> torch.Tensor:
|
||||
k = min(topk_tokens, logits.shape[-1])
|
||||
values, indices = torch.topk(logits, k=k, dim=-1)
|
||||
indices = indices.to(torch.int32)
|
||||
indices = torch.where(
|
||||
values == float("-inf"),
|
||||
torch.full_like(indices, -1, dtype=torch.int32),
|
||||
indices,
|
||||
)
|
||||
if row_starts is not None:
|
||||
# Match the CUDA top_k_per_row_prefill contract: indices are local to
|
||||
# each row's valid [row_start, row_end) range, not columns in the
|
||||
# concatenated chunk logits matrix.
|
||||
starts = row_starts.to(dtype=torch.int32).view(-1, 1)
|
||||
indices = torch.where(indices < 0, indices, indices - starts)
|
||||
if k == topk_tokens:
|
||||
return indices
|
||||
padded = torch.full(
|
||||
(logits.shape[0], topk_tokens),
|
||||
-1,
|
||||
dtype=torch.int32,
|
||||
device=logits.device,
|
||||
)
|
||||
padded[:, :k] = indices
|
||||
return padded
|
||||
|
||||
|
||||
def rocm_aiter_sparse_attn_indexer_fake(
|
||||
hidden_states: torch.Tensor,
|
||||
k_cache_prefix: LayerNameType,
|
||||
|
||||
@@ -731,10 +731,6 @@ class GPUModelRunner(LoRAModelRunnerMixin):
|
||||
if self.encoder_cache is not None:
|
||||
self.encoder_cache.reset_encoder_cache()
|
||||
|
||||
def _get_num_input_tokens(self, num_scheduled_tokens: int) -> int:
|
||||
# SP is not supported yet.
|
||||
return num_scheduled_tokens
|
||||
|
||||
def profile_cudagraph_memory(self) -> int:
|
||||
# NOTE(woosuk): It is TBD whether we keep this API or not.
|
||||
return 0
|
||||
|
||||
@@ -495,22 +495,6 @@ class InputBatch:
|
||||
del self._req_ids[self.num_reqs :]
|
||||
del self.req_output_token_ids[self.num_reqs :]
|
||||
|
||||
def _make_prompt_token_ids_tensor(self) -> torch.Tensor:
|
||||
max_prompt_len = self.num_prompt_tokens[: self.num_reqs].max()
|
||||
prompt_token_ids_cpu_tensor = torch.empty(
|
||||
(self.num_reqs, max_prompt_len),
|
||||
device="cpu",
|
||||
dtype=torch.int64,
|
||||
pin_memory=self.pin_memory,
|
||||
)
|
||||
prompt_token_ids = prompt_token_ids_cpu_tensor.numpy()
|
||||
prompt_token_ids[:] = self.token_ids_cpu[: self.num_reqs, :max_prompt_len]
|
||||
# Use the value of vocab_size as a pad since we don't have a
|
||||
# token_id of this value.
|
||||
for i in range(self.num_reqs):
|
||||
prompt_token_ids[i, self.num_prompt_tokens[i] :] = self.vocab_size
|
||||
return prompt_token_ids_cpu_tensor.to(device=self.device, non_blocking=True)
|
||||
|
||||
def make_lora_inputs(
|
||||
self, num_scheduled_tokens: np.ndarray, num_sampled_tokens: np.ndarray
|
||||
) -> tuple[tuple[int, ...], tuple[int, ...], set[LoRARequest]]:
|
||||
|
||||
Reference in New Issue
Block a user