You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
both `scientificmltests.hamiltoniannn_trainupdatesparameters` and
`...lagrangiannn_trainupdatesparameters` failed only when they ran
after `universaldifferentialequation_trainupdatesparameters` in the
same class (each passes in isolation). symptom: post-train params
identical to pre-train, lastloss nonzero but inconsistent with the
real forward output, train returned in ~4 ms (way too fast for an
eager forward+backward+adam step).
root cause: `compiledtapetrainingstep<t>` keeps a `[threadstatic]`
cache of compiled plans, `_cachedparameters`, `_persistentinput`,
`_persistenttarget`, etc. the cache key for both `step` and
`trystepwithfusedoptimizer` is just `(input shape, target shape)`.
ude trains first → caches a compiled plan + parameter array whose
leaves are ude's tensor refs. hamilton/lagrangian then call train
with the same `[1,2]→[1,1]` shapes → cache hit → plan replays
against ude's (now uninvolved) parameter tensors and the optimizer
"trains" them, leaving the new model's tensors untouched.
fix: track the trainable-layer set's reference identities alongside
the cached parameters. when the next call arrives with a different
layer set (element-wise `referenceequals`), force `invalidate()`
so the next call rebuilds the cache against the new model's tensors.
the steady-state cost is one ref-compare per layer per train step;
on a model switch we pay one cache rebuild, which is exactly the
correctness boundary.
also added `_cachedlayersetidentities` to `invalidate()` so manual
invalidation paths reset it too.
Closes#1406
0 commit comments