Skip to content

run: a step that hands back no token is an error, not an underflow - #33

Open
FeathBow wants to merge 1 commit into
pegainfer-project:masterfrom
FeathBow:fix/run-silent-step
Open

FeathBow wants to merge 1 commit into
pegainfer-project:masterfrom
FeathBow:fix/run-silent-step

Conversation

@FeathBow

Copy link
Copy Markdown
Contributor

The protocol requires some forward to sample, not the one kern run steps through. When the step's forward writes no tokens output, emitted returns nothing and out.len() - 1 underflows: a panic in debug, and in release a loop that never advances. The step now fails, naming the forward.

Verification

Qwen3-4B with sample removed from decode (decode_batch still samples, so the protocol accepts it) and kern run --rows 1: before, the release build spun until a 90 s timeout killed it; after, it exits 1 with `decode` handed back no token; kern run steps through a forward that samples.

`kern run` steps through the forward that takes `--rows` rows and adds `out.len() - 1` to its drafted-rows tally. A forward that writes no `tokens` output (the protocol only needs some forward to sample, not the one the step picks) hands back nothing: the subtraction underflows, a panic in debug, and in release the cursor never advances, so the loop never ends. The step now fails naming the forward.

Reproduced with Qwen3-4B whose `decode` has its `sample` call removed (`decode_batch` still samples, so the protocol accepts it) and `kern run --rows 1`: the release build captured the step's graph and spun until a 90 s timeout killed it; with this change it exits 1 at once with "`decode` handed back no token".

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant