Skip to content

Commit 2979b8a

Browse files
MeganEFlynnclaude
andauthored
Remove redundant padding-position check in anchor mask creation (#522)
<!-- markdownlint-disable --> ## Purpose The hard error when anchor_positions land on padding locations is redundant: base_prefix_mod already guards against this with the q_doc != -1 check, and invalid anchors have their loss zeroed out via anchor_valid. The error breaks valid edge cases like empty batches where select_anchors returns all-zero positions. ## Description Keeping track of this for later. ## Related Issue ## Tests I have filled in: - [ ] The purpose of the PR, such as "Fix some issue (link existing issues this PR will resolve)". - [ ] The test plan/results, such as providing test command and pasting the results. - [ ] (Optional) The necessary documentation update. - [ ] I (a human) have written or reviewed the code in this pr to the best of my ability. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 46cdb3b commit 2979b8a

1 file changed

Lines changed: 0 additions & 7 deletions

File tree

src/speculators/models/dflash/attention.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,6 @@ def create_anchor_block_mask_mod(
7474
f"anchor_positions out of range: {anchor_positions[oob].tolist()}"
7575
)
7676

77-
anchor_docs = document_ids[anchor_positions]
78-
if (pad_mask := anchor_docs == -1).any():
79-
raise ValueError(
80-
f"anchor_positions include padding locations:"
81-
f" {anchor_positions[pad_mask].tolist()}"
82-
)
83-
8477
# For each query position, which anchor does it belong to?
8578
# query q in [j*block_size, (j+1)*block_size) belongs to anchor_positions[j]
8679
query_anchor_positions = torch.repeat_interleave(anchor_positions, block_size)

0 commit comments

Comments
 (0)