Repository navigation
Add graph-level BPTT tape (closes #39) - #55
Merged
Merged
Conversation
tape.h/tape.c: nir_tape_t retains per-step per-node summed inputs, values, and LI/LIF/IF/CubaLIF state across a multi-step forward that reuses the runtime's Delay-breaking scheduler and matches nir_runtime_run bit for bit, then backpropagates in reverse topological order: grad/T seeding for the Output time-average, Delay value gradients routed to the previous step's sources, exact LI state unrolling, and LIF/IF/CubaLIF wiring per the documented zero-gradient reset convention. Parameter gradients accumulate per node (Affine/Linear/Conv weights and biases, Scale constants); input-frame gradients are exposed per step. Tests: test_tape (forward bit-exactness on a Delay+LI graph and the exported conv_net with Delay reset cycles; central-FD gradient checks on LI/Delay, Conv2d/pool/flatten, and Conv1d/Linear/Scale topologies; float64 closed forms for Threshold/LIF/Scale and IF chains; scalar Delay credit-flow proof; spiking smoke; error paths) plus seven graph fixtures. 42/42 ctest green in Debug, Release, and ASan/UBSan.
w4ffl35
force-pushed
the
fix/nir-bptt-tape
branch
from
October 14, 2026 12:48
1a40294 to
f0e95a7
Compare
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 issue #39:
nir_tape_t(tape.h/tape.c) retains per-step per-node summed inputs, values, and LI/LIF/IF/CubaLIF state across a multi-step forward, then backpropagates in reverse topological order.Forward reuses the runtime's Delay-breaking scheduler (an internal
nir_runtime_t, never stepped, supplies the exact order and cycle validation) and evaluates the same public layer ops, so its readout matchesnir_runtime_runbit for bit; every forward starts from unprimed temporal state. Backward seeds grad/T per step for the Output time-average, routes Delay value gradients to the previous step's sources, unrolls LI state exactly, and wires LIF/IF/CubaLIF per the documented zero-gradient reset convention (CubaLIF cross-step synaptic credit is truncated: the op has no grad input for the synaptic current). Parameter gradients accumulate per node (Affine/Linear/Conv weights and biases, Scale constants); input-frame gradients are exposed per step. Inference APIs untouched: purely additive.Acceptance criteria from #39:
Local evidence: 42/42 ctest green in Debug, Release, and ASan/UBSan builds, zero compiler warnings.
Notes for follow-ups (left untouched deliberately): README's training-scope section and the
train.hheader comment still list the tape as future work -- both were already stale for #40/#41/#45-#47 on master, so a doc refresh fits the #44 driver owner better. Spike-count sum accumulation (loss.h) still backprops through the caller, since the tape owns mean-averaging, not plain sums.