Skip to content

Commit 0d4a104

Browse files
committed
Quality
Signed-off-by: Fynn Schmitt-Ulms <fschmitt@redhat.com>
1 parent 49e7a8b commit 0d4a104

7 files changed

Lines changed: 9 additions & 8 deletions

File tree

src/speculators/models/dflash/attention.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def create_anchor_block_mask_mod(
2727
- may not attend to other synthetic blocks or later base tokens
2828
2929
Args:
30-
document_ids: [total_seq_len] maps each position to its document index, -1 for padding
30+
document_ids: [total_seq_len] maps each position to its doc index, pad -1
3131
total_seq_len: padded packed sequence width
3232
anchor_positions: [n_anchors] absolute positions into the packed base sequence
3333
block_size: number of query tokens per anchor block

src/speculators/models/dflash/core.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import functools
21
from typing import Any, ClassVar
32

43
import torch

src/speculators/models/dflash/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ def select_anchors(
5555
k = min(num_anchors, valid_indices.numel())
5656

5757
# Constrain value of k for torch dynamo
58-
torch._check(k <= valid_indices.numel())
59-
torch._check(k >= 0)
58+
torch._check(k <= valid_indices.numel()) # noqa: SLF001
59+
torch._check(k >= 0) # noqa: SLF001
6060

6161
perm = torch.randperm(valid_indices.numel(), device=loss_mask.device)
6262
anchors[:k] = torch.gather(valid_indices, 0, perm[:k])

src/speculators/models/eagle3/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def load_verifier_weights(self):
111111
)
112112

113113
@conditional_torch_compile
114-
def forward( # noqa: C901
114+
def forward(
115115
self,
116116
hidden_states: torch.Tensor, # shape: [1, total_seq_len, 3 * hidden_size]
117117
input_ids: torch.Tensor, # shape: [1, total_seq_len]

src/speculators/models/peagle/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def forward(
6363
Args:
6464
hidden_states: Verifier hidden states [batch, seq_len, 3*hidden_size]
6565
input_ids: Input token IDs [batch, seq_len]
66-
document_ids: Document IDs [1, seq_len], maps positions to document index, -1 for padding
66+
document_ids: Document IDs [1, seq_len], maps positions to doc index, pad -1
6767
position_ids: Position IDs [batch, seq_len] (optional)
6868
loss_mask: Loss mask for which tokens to compute loss on
6969
[batch, seq_len]

src/speculators/models/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def conditional_torch_compile(func):
4343
def wrapper(*args, **kwargs):
4444
lengths = kwargs.get("lengths")
4545
if lengths is not None:
46-
torch._dynamo.mark_dynamic(lengths, 0)
46+
torch._dynamo.mark_dynamic(lengths, 0) # noqa: SLF001
4747
return compiled(*args, **kwargs)
4848

4949
return wrapper

tests/unit/train/test_eagle3_attention.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ def test_diagonal_draft_tokens_mask_mod(lengths):
5050
document_ids = torch.repeat_interleave(
5151
torch.arange(lengths.shape[0], dtype=torch.long), lengths
5252
)
53-
mask_mod = create_combined_mask_mod(document_ids, total_seq_len=lengths.sum().item())
53+
mask_mod = create_combined_mask_mod(
54+
document_ids, total_seq_len=lengths.sum().item()
55+
)
5456

5557
N = lengths.sum().item()
5658

0 commit comments

Comments
 (0)