Add pydocstyle to the ruff rules (#52136)
Signed-off-by: Harry Mellor <19981378+hmellor@users.noreply.github.com> Signed-off-by: Harry Mellor <hej.mellor@gmail.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
804e5377aa
commit
8c1557a79c
+14
-6
@@ -64,7 +64,7 @@ class DeepGemmQuantScaleFMT(Enum):
|
||||
|
||||
@classmethod
|
||||
def init_oracle_cache(cls) -> None:
|
||||
"""Initialize the oracle decision and store it in the class cache"""
|
||||
"""Initialize the oracle decision and store it in the class cache."""
|
||||
cached = getattr(cls, "_oracle_cache", None)
|
||||
if cached is not None:
|
||||
return
|
||||
@@ -426,7 +426,7 @@ def mk_alignment_scope(value: int):
|
||||
|
||||
|
||||
def get_col_major_tma_aligned_tensor(x: torch.Tensor) -> torch.Tensor:
|
||||
"""Wrapper for DeepGEMM's get_mn_major_tma_aligned_tensor"""
|
||||
"""Wrapper for DeepGEMM's get_mn_major_tma_aligned_tensor."""
|
||||
_lazy_init()
|
||||
if _get_mn_major_tma_aligned_tensor_impl is None:
|
||||
return _missing()
|
||||
@@ -568,6 +568,7 @@ def fp8_fp4_mqa_logits(
|
||||
|
||||
Returns:
|
||||
Logits tensor of shape [M, N], dtype `torch.float32`.
|
||||
|
||||
"""
|
||||
_lazy_init()
|
||||
if _fp8_fp4_mqa_logits_impl is None:
|
||||
@@ -623,6 +624,7 @@ def get_paged_mqa_logits_metadata(
|
||||
Returns:
|
||||
Tensor of shape [slots + 1, 2] consumed by `fp8_fp4_paged_mqa_logits`
|
||||
to schedule work across SMs.
|
||||
|
||||
"""
|
||||
_lazy_init()
|
||||
if _get_paged_mqa_logits_metadata_impl is None:
|
||||
@@ -674,6 +676,7 @@ def fp8_fp4_paged_mqa_logits(
|
||||
Returns:
|
||||
Logits tensor of shape [B * next_n, max_model_len], dtype
|
||||
`torch.float32`.
|
||||
|
||||
"""
|
||||
_lazy_init()
|
||||
if _fp8_fp4_paged_mqa_logits_impl is None:
|
||||
@@ -701,7 +704,8 @@ def fp8_fp4_paged_mqa_logits(
|
||||
|
||||
def has_deep_gemm_sparse_mqa() -> bool:
|
||||
"""Whether the installed DeepGEMM provides the sparse-indexer kernels
|
||||
(``fp8_fp4_(paged_)sparse_mqa_logits``, added in DeepGEMM 2.8, SM100-only)."""
|
||||
(``fp8_fp4_(paged_)sparse_mqa_logits``, added in DeepGEMM 2.8, SM100-only).
|
||||
"""
|
||||
_lazy_init()
|
||||
return (
|
||||
_fp8_fp4_sparse_mqa_logits_impl is not None
|
||||
@@ -740,6 +744,7 @@ def get_sparse_mqa_logits_metadata(
|
||||
qk_dtype: dtype of the packed Q values (``torch.int8`` for MXFP4,
|
||||
``torch.float8_e4m3fn`` for FP8).
|
||||
sparse_block_kv: Tokens per sparse block, 8 or 16.
|
||||
|
||||
"""
|
||||
_lazy_init()
|
||||
if _get_sparse_mqa_logits_metadata_impl is None:
|
||||
@@ -777,6 +782,7 @@ def get_paged_sparse_mqa_logits_metadata(
|
||||
block ids, [num_q_tokens, num_max_sparse_blocks], int32.
|
||||
qk_dtype: dtype of the packed Q values.
|
||||
sparse_block_kv: Tokens per sparse block, 8 or 16.
|
||||
|
||||
"""
|
||||
_lazy_init()
|
||||
if _get_paged_sparse_mqa_logits_metadata_impl is None:
|
||||
@@ -817,6 +823,7 @@ def fp8_fp4_sparse_mqa_logits(
|
||||
bf16 logits of shape [M, num_max_sparse_blocks * sparse_block_kv];
|
||||
column ``j * sparse_block_kv + o`` scores the token at
|
||||
``sparse_kv_block_indices[row, j] * sparse_block_kv + ks % sbk + o``.
|
||||
|
||||
"""
|
||||
_lazy_init()
|
||||
if _fp8_fp4_sparse_mqa_logits_impl is None:
|
||||
@@ -848,10 +855,13 @@ def fp8_fp4_paged_sparse_mqa_logits(
|
||||
page stride 512B-aligned.
|
||||
weights: [num_q_tokens, H] ``torch.bfloat16``.
|
||||
metadata: From `get_paged_sparse_mqa_logits_metadata`.
|
||||
num_max_sparse_blocks: Candidate blocks per row.
|
||||
sparse_block_kv: Tokens per sparse block, 8 or 16.
|
||||
|
||||
Returns:
|
||||
bf16 logits of shape
|
||||
[num_q_tokens, num_max_sparse_blocks * sparse_block_kv].
|
||||
|
||||
"""
|
||||
_lazy_init()
|
||||
if _fp8_fp4_paged_sparse_mqa_logits_impl is None:
|
||||
@@ -873,8 +883,7 @@ def tf32_hc_prenorm_gemm(
|
||||
sqrsum: torch.Tensor,
|
||||
num_split: int,
|
||||
) -> torch.Tensor:
|
||||
"""
|
||||
Perform the following computation:
|
||||
"""Perform the following computation:
|
||||
out = x.float() @ fn.T
|
||||
sqrsum = x.float().square().sum(-1)
|
||||
|
||||
@@ -950,7 +959,6 @@ def calc_diff(x: torch.Tensor, y: torch.Tensor):
|
||||
and report `1 - sim`. Once kernel accuracy improves this helper can be
|
||||
removed.
|
||||
"""
|
||||
|
||||
x, y = x.double(), y.double()
|
||||
denominator = (x * x + y * y).sum()
|
||||
sim = 2 * (x * y).sum() / denominator
|
||||
|
||||
Reference in New Issue
Block a user