Repository navigation
Fix KeyError for input-only hidden states and dropped pure-copy edges (#184) - #190
Merged
Merged
Conversation
…#184) A hidden state whose new value depends only on inputs (an input latch) joins a group through another member's transition, so no collected equation produces it and HiddenGroup.transition raised KeyError. Bind such outvars as constvars (zero Jacobian row). A pure copy h2^t = h1^{t-1} (delay line) has no equation, so its edge was dropped and the weight feeding h1 got a zero online gradient. Merge the copy into the source's group (identity row). A same-step read of the copy cannot be attributed to h2^t and now emits a WARNING (HIDDEN_COPY_SAME_STEP_READ).
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This was referenced Oct 24, 2026
Merged
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.
Fixes #184.
Summary
Input-only hidden state (the issue).
write_jaxpr_of_hidden_group_transitionbuilds the group jaxpr only from equations reachable from the group invars. A latchlatch^t = x @ wthat joined the group throughV's transition was therefore never produced and never bound, andeval_jaxprraisedKeyError.Pure copies (found while fixing; same family).
h2^t = h1^{t-1}(a delay line / shift register) has no equation, so the edge was dropped.h2fell back to a zero-recurrence group, and the weight feedingh1got a silently zero online gradient. Downstream'snew + 0*oldworkaround hides this case too._post_checknow merges the copy into the source's group, which gives an identity row.h1^{t-1}(they are one variable), so it cannot be fixed there. It now emits a WARNINGDiagnosticKind.HIDDEN_COPY_SAME_STEP_READthat names both states. A read on the next step is exact.Spec:
docs/specs/2026-10-24-issue-184-input-only-hidden.md.Before / after
etrace_grad, |grad w|)KeyError--workaroundresult)KeyErrorTests
_compiler/hidden_group_test.py::TestInputOnlyHiddenInMergedGroup:[[0,0],[1,0.9]]forlatch <- x@wandlatch <- x;_compiler/hidden_group_test.py::TestHiddenCopySameStepRead: warns for a same-step read, silent for a next-step read._algorithm/d_rtrl_test.py::TestEquationFreeHiddenEdges:chunked_online_param_gradients, chunk 1 and 3) for the latch and delay-line models;d_rtrlandepropmatch thenew + 0*oldworkaround.hypothesisimport missing in the remote env, which also occurs onmain.