Skip to content

model: raise on multi-token input in HyenaCascade.sequential_forward - #82

Open
dhnihaoya wants to merge 1 commit into
Zymrael:mainfrom
dhnihaoya:guard-sequential-forward-multitoken
Open

dhnihaoya wants to merge 1 commit into
Zymrael:mainfrom
dhnihaoya:guard-sequential-forward-multitoken

Conversation

@dhnihaoya

Copy link
Copy Markdown

Fixes #81.

What

HyenaCascade.sequential_forward now raises a ValueError on multi-token input (seqlen > 1) instead of silently truncating to u = u[:, -1].

Why

After prefill, HyenaCascade.forward routes every call to sequential_forward. Passing several tokens at once (e.g. a chunk/block forward with initial state, as speculative-decoding verification requires) used to silently discard all but the last token: the dropped tokens had zero effect on output and state, the surviving position was computed with a wrong conv/recurrent window, and the layer state advanced by one token instead of seqlen — with no error and no warning, corrupting all subsequent decode steps. #81 has a self-contained random-weight reproduction (CPU, ~1 s).

A correct chunk forward is a real feature; until it exists, failing loudly turns a silent correctness bug into an explicit, debuggable error.

Why this is safe

No first-party flow can trigger the raise: vortex's own Generator feeds one token per decode step (x = x[:, -1:], vortex/model/generation.py L169) and prefill goes through parallel_forward. The new branch only activates for seqlen > 1, which previously always produced wrong results.

Test

After prefill, HyenaCascade.forward routes to sequential_forward, which
silently truncated any multi-token input to its last token (u = u[:, -1]):
the dropped tokens had zero effect on output and state, the surviving
position was computed with a wrong conv/recurrent window, and the layer
state advanced by one token instead of seqlen -- all without any error
or warning, corrupting every subsequent decode step.

Chunk forward with initial state (what e.g. speculative-decoding
verification needs) is not implemented on this path, so fail loudly
instead of returning silently wrong results. First-party flows are
unaffected: Generator feeds one token per step (generation.py) and
prefill goes through parallel_forward.

Fixes Zymrael#81
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant