[PR #61] [CLOSED] text sampler: an empty penalty window must not touch the unsized shared bitmap #2434

Closed
opened 2026-11-04 02:00:06 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/61
Author: @j-luwierski
Created: 9/28/2026
Status: ❌ Closed

Base: main ← Head: fix/penalty-bitmap-empty-window


📝 Commits (1)

  • 1010075 sampler: an empty penalty window must not touch the unsized shared bitmap

📊 Changes

2 files changed (+33 additions, -3 deletions)

View changed files

📝 src/kernels/cuda/sampler.cu (+7 -3)
📝 src/kernels/sampler_parity.cpp (+26 -0)

📄 Description

Follow-up from the #53 discussion (the penalties fix itself landed in v0.1.17 - this is the other thing I
mentioned there).

use_bits required only a non-null history, but the launch sizes the shared bitmap for penalty_last_n > 0
alone. A caller handing sample_tokens a history buffer with the penalties disabled (e.g. a stale buffer
from a previous penalised request) makes the kernel zero bits_words words of a zero-byte dynamic shared
allocation.

  • unreachable from the serve path: set_history passes nullptr when the window is empty
  • invisible to memcheck: the write lands in the unallocated SMEM window
  • still undefined per the contract of the public API

The gate now also requires a non-empty window (hlen > 0, both kernels), and fixture 11 pins a stale
history with last_n = 0 to the no-history result in both kernels.

Verification

  • sampler_parity --selftest: 0 failures (fixtures 1-11)
  • randomised fuzz, kernels vs a serial single-pass reference (updated to the new top_p-before-min_p order):
    2000 cases, 0 mismatches
  • compute-sanitizer: racecheck 0 hazards, memcheck 0 errors

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/61 **Author:** [@j-luwierski](https://github.com/j-luwierski) **Created:** 9/28/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/penalty-bitmap-empty-window` --- ### 📝 Commits (1) - [`1010075`](https://github.com/Niko1221/Strata/commit/1010075b6d8a634ca047822029b4857b7296f872) sampler: an empty penalty window must not touch the unsized shared bitmap ### 📊 Changes **2 files changed** (+33 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `src/kernels/cuda/sampler.cu` (+7 -3) 📝 `src/kernels/sampler_parity.cpp` (+26 -0) </details> ### 📄 Description Follow-up from the #53 discussion (the penalties fix itself landed in v0.1.17 - this is the other thing I mentioned there). `use_bits` required only a non-null history, but the launch sizes the shared bitmap for `penalty_last_n > 0` alone. A caller handing `sample_tokens` a history buffer with the penalties disabled (e.g. a stale buffer from a previous penalised request) makes the kernel zero `bits_words` words of a **zero-byte** dynamic shared allocation. - unreachable from the serve path: `set_history` passes `nullptr` when the window is empty - invisible to memcheck: the write lands in the unallocated SMEM window - still undefined per the contract of the public API The gate now also requires a non-empty window (`hlen > 0`, both kernels), and fixture 11 pins a stale history with `last_n = 0` to the no-history result in both kernels. ## Verification - `sampler_parity --selftest`: 0 failures (fixtures 1-11) - randomised fuzz, kernels vs a serial single-pass reference (updated to the new top_p-before-min_p order): 2000 cases, 0 mismatches - `compute-sanitizer`: racecheck 0 hazards, memcheck 0 errors --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:00:06 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2434
No description provided.