Skip to content

fix: removing delay and nla bugs, small all around fixes#459

Open
MartinuzziFrancesco wants to merge 1 commit into
masterfrom
fm/cfix
Open

fix: removing delay and nla bugs, small all around fixes#459
MartinuzziFrancesco wants to merge 1 commit into
masterfrom
fm/cfix

Conversation

@MartinuzziFrancesco

Copy link
Copy Markdown
Collaborator

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

Add any other context about the problem here.

@Saswatsusmoy Saswatsusmoy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read through this carefully. The InputDelayESN/DelayESN one looks like it had been silently broken since the input-delay split, since the constructor tests never ran a forward pass — the newst.input_delay.clock == n_steps assertion is a useful regression guard. Left a few questions inline, all curiosity, nothing blocking.

Comment thread src/models/esn_delay.jl
# :readout)`, so these models need their own parameter/state setup and their
# own `_partial_apply`. The generic forward call and `collectstates` both route
# through `_partial_apply`, so overriding it here is enough to make them work.
const _InputDelayedESN = Union{InputDelayESN, DelayESN}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious about one thing: since AbstractReservoirComputer{Fields} already encodes the field-name tuple, would it make sense down the line to have the generic initialparameters / _partial_apply introspect Fields directly, so any future composite model with extra pre- or post-fields just works? Could be a follow-up — wondering whether you'd considered that direction, or whether there's a reason a per-model override is preferable here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that could be an elegant solution yeha, if there's a way to make it generic enough it should solve similar gotchas to this one

Comment thread src/states.jl
for idx in eachindex(x_old)
if firstindex(x_old) < idx < lastindex(x_old) && isodd(idx)
x_new[idx, :] .= x_old[idx - 1, :] .* x_old[idx - 2, :]
if firstindex(x_old) < idx && isodd(idx)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When firstindex(x_old) > 1 (e.g. an OffsetArray), this would start applying at idx = firstindex + 1 if odd. Is that the intended semantics for offset inputs, or is NLAT2 effectively assumed to receive standard 1-based vectors? Probably never comes up in practice but I noticed it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't the only algo that would have issues with nonstandard arrays. It's in the plans to make a larger check for this kind of issues

Comment thread test/test_esn_delay.jl
data = rand(rng, Float32, in_dims, n_steps)
target = rand(rng, Float32, out_dims, n_steps)

idesn = InputDelayESN(in_dims, res_dims, out_dims; num_delays = num_delays)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the new round-trip tests touch stride > 1. The fix itself isn't stride-sensitive (stride only changes what the buffer keeps), but I wondered if a quick stride=2 smoke test might be worth adding here just to lock the end-to-end behavior down. Or do you think the current coverage is enough?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeha that would be a good idea, I'll add it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants