[PR #235] [CLOSED] verify: STRATA_LOGPOS hook for per-position log-probabilities (items 12-13 of #84) #2519

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

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/235
Author: @enkynakamura
Created: 9/30/2026
Status: ❌ Closed

Base: main ← Head: window-logprobs-hook


📝 Commits (1)

  • 92e64c2 verify: STRATA_LOGPOS hook for per-position teacher-forced log-probabilities

📊 Changes

3 files changed (+64 additions, -0 deletions)

View changed files

📝 include/strata/core/verify.hpp (+9 -0)
📝 src/core/verify.cpp (+41 -0)
📝 src/program/generate.cpp (+14 -0)

📄 Description

Adds Verifier::window_logprobs and a call to it in read_windows, enabled only when STRATA_LOGPOS= is set. Every token read through the verify windows gets one tab-separated line: pos target logprob top top_logprob hit extra_logprob target_logprob_without_extra, where row t is the head's distribution at pos0 + t and the target is the prompt's own token at pos0 + t + 1. STRATA_LOGPOS_EXTRA (default 248046, <|im_end|>) is reported separately and taken out of the last column, because on raw text in a user turn a chat model puts much of its mass on the end-of-turn token.

Checked:

Built on v0.1.29 (d6708a4), CUDA 13.3, RTX 5080, Windows. A 32k probe dump (2931 rows) from this branch is byte-identical (md5 3e97790a…) to the dumps from v0.1.26, v0.1.28 and v0.1.29 built with the earlier revision of the hook.
Earlier, on the revision in #84: rows are aligned (top-1 equals the target only at shift 0), no periodicity per window, and a cross-check against llama.cpp on the same token ids (same top token in 9 of 11 positions, close log-probabilities).
Cost when enabled: 10.4 ms per token read from the windows, measured on 631c3d8. When disabled: one null check per window.

Not checked: the HIP build (the hook only uses cudaMemcpy/cudaMemcpyDeviceToHost, as the existing STRATA_DBG_NAN block does), and the layer-split path (forwarding plus OnDevice; I have a single GPU).


🔄 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/235 **Author:** [@enkynakamura](https://github.com/enkynakamura) **Created:** 9/30/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `window-logprobs-hook` --- ### 📝 Commits (1) - [`92e64c2`](https://github.com/Niko1221/Strata/commit/92e64c2121123701be567b22ce7c977c3ba5c641) verify: STRATA_LOGPOS hook for per-position teacher-forced log-probabilities ### 📊 Changes **3 files changed** (+64 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `include/strata/core/verify.hpp` (+9 -0) 📝 `src/core/verify.cpp` (+41 -0) 📝 `src/program/generate.cpp` (+14 -0) </details> ### 📄 Description Adds Verifier::window_logprobs and a call to it in read_windows, enabled only when STRATA_LOGPOS=<path> is set. Every token read through the verify windows gets one tab-separated line: pos target logprob top top_logprob hit extra_logprob target_logprob_without_extra, where row t is the head's distribution at pos0 + t and the target is the prompt's own token at pos0 + t + 1. STRATA_LOGPOS_EXTRA (default 248046, <|im_end|>) is reported separately and taken out of the last column, because on raw text in a user turn a chat model puts much of its mass on the end-of-turn token. Checked: Built on v0.1.29 (d6708a4), CUDA 13.3, RTX 5080, Windows. A 32k probe dump (2931 rows) from this branch is byte-identical (md5 3e97790a…) to the dumps from v0.1.26, v0.1.28 and v0.1.29 built with the earlier revision of the hook. Earlier, on the revision in #84: rows are aligned (top-1 equals the target only at shift 0), no periodicity per window, and a cross-check against llama.cpp on the same token ids (same top token in 9 of 11 positions, close log-probabilities). Cost when enabled: 10.4 ms per token read from the windows, measured on 631c3d8. When disabled: one null check per window. Not checked: the HIP build (the hook only uses cudaMemcpy/cudaMemcpyDeviceToHost, as the existing STRATA_DBG_NAN block does), and the layer-split path (forwarding plus OnDevice; I have a single GPU). --- <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:57 +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#2519
No description provided.