Skip to content

Conversation

@vijk777
Copy link
Collaborator

@vijk777 vijk777 commented Jan 23, 2026

The goal here is to test whether we can maintain good performance if the stimulus is provided more sparsely.

We introduce a few different stimulus modes:

  • all (default) - stimulus provided every time step (20ms)
  • constant - stimulus provided every tu units, but we hold the stimulus constant. For example, if the activity data is at 0, 20, 40, 60, .... for evolution at 10 < t < 30, we just repeat the stimulus at t=20.
  • interpolate - stimulus provided every tu units, but we linearly interpolate
  • none - just provide 0's, which is no stimulus control

Results: we don't learn the correct rule and the roll out blows up.

image image

Over the training window we don't see a blow up, but the MSE is pretty close to the linear interpolation baseline. But we blow up right outside the training window.

Also remove unit testing from github actions. Run unit tests locally via a precommit hook.

vijk777 and others added 9 commits January 23, 2026 15:01
adds support for downsampling stimulus at time_units intervals during
training and validation, allowing the model to learn dynamics without
relying on fine-grained stimulus information.

changes:
- add StimulusFrequency enum with 4 modes:
  - ALL: use stimulus at every time step (default)
  - NONE: no stimulus (set to zero)
  - TIME_UNITS_CONSTANT: sample at tu intervals, hold constant
  - TIME_UNITS_INTERPOLATE: sample at tu intervals, linearly interpolate
- add stimulus_frequency field to TrainingConfig with validation
- implement downsample_stimulus() helper in latent.py
- update train_step_nocompile to downsample encoded stimulus
- update validation rollout functions (evolve_n_steps_activity and
  evolve_n_steps_latent) to support downsampling
- rename evolve_n_steps -> evolve_n_steps_activity for clarity

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…s_utils

moves the downsample_stimulus function to a new stimulus_utils.py module
to avoid circular import between latent.py and diagnostics.py.

changes:
- create src/LatentEvolution/stimulus_utils.py with downsample_stimulus
- update latent.py to import from stimulus_utils
- update diagnostics.py to import from stimulus_utils
- remove duplicate function definition from latent.py

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
… point

detects when total_steps doesn't include the final boundary point for
interpolation and falls back to constant mode for the last interval.
also fixes TIME_UNITS_CONSTANT mode to handle missing boundary points.

changes:
- TIME_UNITS_CONSTANT: calculate num_samples based on available data
- TIME_UNITS_INTERPOLATE: detect edge case and use constant for last interval
- both modes now work correctly when total_steps = num_multiples * tu

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
adds 14 unit tests covering all stimulus frequency modes and edge cases.
tests verify correct behavior for ALL, NONE, TIME_UNITS_CONSTANT, and
TIME_UNITS_INTERPOLATE modes, including edge cases with missing boundary
points.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
moves unit tests from tests/ subdirectory to main module directory
following project conventions. tests still pass with new location.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
changes TIME_UNITS_CONSTANT mode to use centered intervals around
each sample point. stimulus at time t is now used for interval
[t-tu/2, t+tu/2) instead of [t, t+tu).

this provides better temporal alignment between the stimulus and
the neural activity it's meant to represent.

example with tu=20:
- stimulus at t=0:  used for steps [0, 10)
- stimulus at t=20: used for steps [10, 30)
- stimulus at t=40: used for steps [30, 50)

changes:
- update downsample_stimulus() to use centered intervals
- update and add unit tests for centered interval behavior
- fix dtype preservation in torch.zeros call

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
sets y-axis limits to (1e-3, 1.0) for better comparison across
different runs and to prevent auto-scaling from hiding important
differences in MSE values.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vijk777 vijk777 changed the title [WIP] feat: add stimulus downsampling feat: add stimulus downsampling Jan 26, 2026
add pre-commit validation:
- run ruff linting with proper exclusions and error messages
- run unit tests using unittest discover with pattern *_test.py
- execute checks in order: file sizes, ruff, then unit tests

standardize test file naming:
- rename test_chunk_loader.py to chunk_loader_test.py
- follow convention: <module_name>_test.py for better IDE sorting

update github actions:
- comment out test job (tests now run in pre-commit hook)
- keep ruff linting in CI

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vijk777 vijk777 merged commit b0445d4 into main Jan 26, 2026
1 check passed
@vijk777 vijk777 deleted the vj/downsample_stimulus branch January 26, 2026 15:52
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