feat(nn): Lstm layer with explicit-state step() API#824
Merged
Conversation
Single-layer, batch-first LSTM mirroring Gru's unroll-at-trace-time design, built from existing primitives only (matmul/narrow/sigmoid/tanh/multiply) — no new TensorOps op, traces to StableHLO with no dedicated converter. - gate order i,f,g,o and dual biases match torch.nn.LSTM (weights load after transpose to the matmul-ready [in,4H]/[H,4H] orientation, like Gru) - NEW: LstmState(h, c) + step(xt, state, ctx) — explicit caller-owned state, required by transducer prediction networks (RNN-T/TDT, e.g. Parakeet) and exactly the shape that lowers to a fixed-shape single-step StableHLO graph - initialState(batch, ctx, dtype) helper - LstmTest: scalar-reference parity (1e-5), step()==sequence equivalence, gate-order sanity (forget-gate cell persistence), output shapes - api dump synced (jvm) Unblocks: Parakeet-TDT prediction network (SKaiNET-parakeet P1/G2) and the Silero VAD port (PLAN 4.1). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
📖 Documentation Preview The documentation has been built successfully for this PR. Generated Files:
Artifacts:
This comment will be updated automatically when the PR is updated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements the DARC proposal #823 — C (Code) phase.
What
Lstm<T, V>inskainet-lang-core, mirroringGru's unroll-at-trace-time design, built fromexisting primitives only (
matmul/narrow/sigmoid/tanh/multiply/reshape/unsqueeze/concat) — nonew
TensorOpsop, traces to StableHLO with no dedicated converter.torch.nn.LSTM; weights load after transposingto the matmul-ready
[in, 4H]/[H, 4H]orientation (same convention asGru).LstmState(h, c)+step(xt, state, ctx)— explicit caller-owned recurrentstate, required by transducer prediction networks (RNN-T/TDT, e.g. Parakeet) and exactly the
shape that lowers to a fixed-shape single-step StableHLO graph (state as graph I/O).
initialState(batch, ctx, dtype)helper.Tests
LstmTest(skainet-backend-cpu, mirrorsGruTest):step()== unrolledforward()equivalence (the transducer usage pattern)apiDumpsynced (jvm),apiCheckgreen.Motivation / consumers
Closes #823
🤖 Generated with Claude Code