Commit 56653d4
Fix two double-buffer bugs in CTRNN advance method
Bug 1: The exponential Euler update applied decay to ovalues (the stale
buffer from two steps ago) instead of ivalues (the current state). Each
buffer was only updated every other step, so the decay term used state
from two timesteps ago rather than one.
Fix: decay * ivalues[node_key] instead of decay * ovalues[node_key]
Bug 2: The return statement read from values[1 - self.active], which
is the pre-update buffer (ivalues), not the just-written buffer
(ovalues). This returned output lagging one step behind the actual
state.
Fix: return values[self.active] (the buffer that was last written to)
Both bugs existed in the original forward Euler code and were carried
over in the exponential Euler conversion. They were found by the GPU
numerical equivalence tests, which use single-buffer in-place updates
and thus don't have the double-buffer issue.
Also fix test_response_parameter_effect to use small inputs/weights
that avoid tanh saturation, which was masking the response difference.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent cb26b8d commit 56653d4
3 files changed
+14
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
479 | | - | |
480 | | - | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
481 | 485 | | |
482 | 486 | | |
483 | 487 | | |
484 | 488 | | |
485 | | - | |
| 489 | + | |
486 | 490 | | |
487 | 491 | | |
488 | 492 | | |
| |||
0 commit comments