Skip to content

Performance optimizations - #42

Merged
jwdink merged 3 commits into
developfrom
perf/season-init
Apr 20, 2026
Merged

Performance optimizations#42
jwdink merged 3 commits into
developfrom
perf/season-init

Conversation

@jwdink

@jwdink jwdink commented Apr 20, 2026

Copy link
Copy Markdown
Collaborator
  • speed up Season.get_initial_mean
  • frequently referenced MeasurementModel.nonlinear_processes now a cached_property instead of property
  • fastpath for transition-matrices and measurement-matrices when not time-varying

jwdink and others added 3 commits April 18, 2026 15:01
Verifies that get_initial_mean(offsets) == F^i @ initial_mean for each
group's offset, covering integer and datetime offsets, multiple groups,
and with/without decay. Tests pass against both the original iterative
implementation and the new closed-form one.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Season.get_initial_mean previously stepped through O(period) matrix
multiplications on every forward pass to rotate the initial state to
each group's starting phase. For day_in_year (period=8766h) this was
~8767 matmuls per forward call. The new implementation decomposes each
2x2 block of F into its rotation angle and magnitude, then applies
F^i = decay^i * R(i * lam) analytically in a single vectorised op.

Also changed MeasurementModel.nonlinear_processes from @Property to
@cached_property, eliminating a list-comprehension rebuild on every
timestep (~124K calls per 5-epoch benchmark run).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jwdink
jwdink merged commit b10ebe2 into develop Apr 20, 2026
7 checks passed
@jwdink
jwdink deleted the perf/season-init branch April 20, 2026 14:25
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.

1 participant