[PR #5305] [Engine] Release a batch slot’s bias allocation when clearing it #5379

Open
opened 2026-11-07 16:34:46 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/5305
Author: @shoucandanghehe
Created: 11/5/2026
Status: 🔄 Open

Base: main ← Head: upstream/slot-bias-ownership


📝 Commits (1)

  • f6eb71e Verifier: release a slot's bias allocation when clearing it

📊 Changes

1 file changed (+6 additions, -1 deletions)

View changed files

📝 src/core/verify.cpp (+6 -1)

📄 Description

Problem

When a batch slot switches from a request with logit_bias to one without it, the empty-bias path drops the owning pointer without releasing the device allocation. Repeated slot reuse leaks another allocation on each biased-to-unbiased transition.

Fix

Free the previous bias buffer under the existing device guard, then clear the owning and sampler pointers.

Related: #3266.

Validation

Tested f6eb71e0.

Backend Environment Result
CUDA Linux/WSL2, CUDA 13.2.51, GCC 15.2, sm_89 Full engine compiled and linked
HIP Linux/WSL2, ROCm 7.10.0a20251120, Clang 22, gfx1100 Full engine compiled and linked
Metal GitHub macOS 26 runner Full engine compiled and linked

Build command, from each configured backend build directory:

cmake --build . --target strata

CUDA regression checks, from the CUDA build directory:

cmake --build . --target logit_bias_test sampler_parity
ctest --output-on-failure -R '^(logit_bias_test|sampler_parity(_one_block|_old)?)$'

All four checks passed on an RTX 4060.

The allocation-and-sampling probe was also rerun against the full CUDA engine libraries. It calls the real setter, sampler and destructor, and checks the released allocation addresses with cuMemGetAddressRange:

  • Unpatched code leaves 65 orphaned allocations; the fix leaves zero.
  • Bias → empty → different bias selects tokens 3 → 0 → 1 in both versions.

🔄 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/5305 **Author:** [@shoucandanghehe](https://github.com/shoucandanghehe) **Created:** 11/5/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `upstream/slot-bias-ownership` --- ### 📝 Commits (1) - [`f6eb71e`](https://github.com/Niko1221/Strata/commit/f6eb71e04fc98f5b00b3ec8de05b2d961bc1d0fc) Verifier: release a slot's bias allocation when clearing it ### 📊 Changes **1 file changed** (+6 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `src/core/verify.cpp` (+6 -1) </details> ### 📄 Description ## Problem When a batch slot switches from a request with `logit_bias` to one without it, the empty-bias path drops the owning pointer without releasing the device allocation. Repeated slot reuse leaks another allocation on each biased-to-unbiased transition. ## Fix Free the previous bias buffer under the existing device guard, then clear the owning and sampler pointers. Related: #3266. ## Validation Tested `f6eb71e0`. | Backend | Environment | Result | | --- | --- | --- | | CUDA | Linux/WSL2, CUDA 13.2.51, GCC 15.2, sm_89 | Full engine compiled and linked | | HIP | Linux/WSL2, ROCm 7.10.0a20251120, Clang 22, gfx1100 | Full engine compiled and linked | | Metal | GitHub macOS 26 runner | [Full engine compiled and linked](https://github.com/shoucandanghehe/Strata/actions/runs/42256818946) | Build command, from each configured backend build directory: ```sh cmake --build . --target strata ``` CUDA regression checks, from the CUDA build directory: ```sh cmake --build . --target logit_bias_test sampler_parity ctest --output-on-failure -R '^(logit_bias_test|sampler_parity(_one_block|_old)?)$' ``` All four checks passed on an RTX 4060. The allocation-and-sampling probe was also rerun against the full CUDA engine libraries. It calls the real setter, sampler and destructor, and checks the released allocation addresses with `cuMemGetAddressRange`: - Unpatched code leaves 65 orphaned allocations; the fix leaves zero. - Bias → empty → different bias selects tokens `3 → 0 → 1` in both versions. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#5379
No description provided.