Fix per file ruff ignores related to typing (#26254)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com>
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import ClassVar, Optional, Union
|
||||
from typing import ClassVar, Union
|
||||
|
||||
import numpy as np
|
||||
import torch
|
||||
@@ -254,12 +254,12 @@ class FlashInferMetadata:
|
||||
# For cascade attention (CPU for planning).
|
||||
use_cascade: bool
|
||||
|
||||
prefill_wrapper: Optional[BatchPrefillWithPagedKVCacheWrapper] = None
|
||||
decode_wrapper: Optional[BatchDecodeWithPagedKVCacheWrapper] = None
|
||||
cascade_wrapper: Optional[MultiLevelCascadeAttentionWrapper] = None
|
||||
prefill_wrapper: BatchPrefillWithPagedKVCacheWrapper | None = None
|
||||
decode_wrapper: BatchDecodeWithPagedKVCacheWrapper | None = None
|
||||
cascade_wrapper: MultiLevelCascadeAttentionWrapper | None = None
|
||||
|
||||
qo_indptr_gpu: Optional[torch.Tensor] = None
|
||||
paged_kv_indptr_gpu: Optional[torch.Tensor] = None
|
||||
qo_indptr_gpu: torch.Tensor | None = None
|
||||
paged_kv_indptr_gpu: torch.Tensor | None = None
|
||||
|
||||
|
||||
class FlashInferMetadataBuilder(AttentionMetadataBuilder[FlashInferMetadata]):
|
||||
@@ -727,13 +727,13 @@ class FlashInferImpl(AttentionImpl):
|
||||
head_size: int,
|
||||
scale: float,
|
||||
num_kv_heads: int,
|
||||
alibi_slopes: Optional[list[float]],
|
||||
sliding_window: Optional[int],
|
||||
alibi_slopes: list[float] | None,
|
||||
sliding_window: int | None,
|
||||
kv_cache_dtype: str,
|
||||
logits_soft_cap: Optional[float] = None,
|
||||
logits_soft_cap: float | None = None,
|
||||
attn_type: AttentionType = AttentionType.DECODER,
|
||||
kv_sharing_target_layer_name: Optional[int] = None,
|
||||
sinks: Optional[torch.Tensor] = None,
|
||||
kv_sharing_target_layer_name: int | None = None,
|
||||
sinks: torch.Tensor | None = None,
|
||||
) -> None:
|
||||
self.num_heads = num_heads
|
||||
self.head_size = head_size
|
||||
@@ -763,7 +763,7 @@ class FlashInferImpl(AttentionImpl):
|
||||
"FlashInferImpl"
|
||||
)
|
||||
|
||||
self.sinks: Optional[torch.Tensor] = None
|
||||
self.sinks: torch.Tensor | None = None
|
||||
if sinks is not None:
|
||||
if sinks.shape[0] != num_heads:
|
||||
raise ValueError(
|
||||
@@ -776,9 +776,9 @@ class FlashInferImpl(AttentionImpl):
|
||||
self.support_trtllm_attn = (
|
||||
supports_trtllm_attention() and num_heads % num_kv_heads == 0
|
||||
)
|
||||
self.bmm1_scale: Optional[float] = None
|
||||
self.bmm2_scale: Optional[float] = None
|
||||
self.o_sf_scale: Optional[float] = None
|
||||
self.bmm1_scale: float | None = None
|
||||
self.bmm2_scale: float | None = None
|
||||
self.o_sf_scale: float | None = None
|
||||
|
||||
def fused_output_quant_supported(self, quant_key: QuantKey):
|
||||
return (
|
||||
@@ -795,9 +795,9 @@ class FlashInferImpl(AttentionImpl):
|
||||
value: torch.Tensor,
|
||||
kv_cache: torch.Tensor,
|
||||
attn_metadata: FlashInferMetadata,
|
||||
output: Optional[torch.Tensor] = None,
|
||||
output_scale: Optional[torch.Tensor] = None,
|
||||
output_block_scale: Optional[torch.Tensor] = None,
|
||||
output: torch.Tensor | None = None,
|
||||
output_scale: torch.Tensor | None = None,
|
||||
output_block_scale: torch.Tensor | None = None,
|
||||
) -> torch.Tensor:
|
||||
"""Forward pass with FlashInfer.
|
||||
|
||||
@@ -1093,13 +1093,13 @@ def fast_plan_decode(
|
||||
page_size: int,
|
||||
pos_encoding_mode: str = "NONE",
|
||||
window_left: int = -1,
|
||||
logits_soft_cap: Optional[float] = None,
|
||||
q_data_type: Optional[Union[str, torch.dtype]] = "float16",
|
||||
kv_data_type: Optional[Union[str, torch.dtype]] = None,
|
||||
data_type: Optional[Union[str, torch.dtype]] = None,
|
||||
sm_scale: Optional[float] = None,
|
||||
rope_scale: Optional[float] = None,
|
||||
rope_theta: Optional[float] = None,
|
||||
logits_soft_cap: float | None = None,
|
||||
q_data_type: Union[str, torch.dtype] | None = "float16",
|
||||
kv_data_type: Union[str, torch.dtype] | None = None,
|
||||
data_type: Union[str, torch.dtype] | None = None,
|
||||
sm_scale: float | None = None,
|
||||
rope_scale: float | None = None,
|
||||
rope_theta: float | None = None,
|
||||
non_blocking: bool = True,
|
||||
) -> None:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user