Skip to content

Add static_temporal encoding mode#527

Draft
pjreddie wants to merge 4 commits intomainfrom
joer/static-temporal-encoding
Draft

Add static_temporal encoding mode#527
pjreddie wants to merge 4 commits intomainfrom
joer/static-temporal-encoding

Conversation

@pjreddie
Copy link
Copy Markdown
Collaborator

@pjreddie pjreddie commented Apr 7, 2026

Summary

  • Adds a static_temporal encoding mode that replaces legacy time-index + month embeddings with multi-frequency sinusoidal encoding based on fractional year
  • The encoding uses geometric-spaced frequencies (~128-year to daily resolution), making it slot-position invariant: same calendar date always gets the same encoding regardless of time slot index
  • Threads timestamp_encoding_mode through CompositeEncodings, FlexiVitBase, Encoder, PredictorBase, EncoderConfig, PredictorConfig
  • Includes vnext experiment script variant and 8 unit tests
  • Default mode is "legacy" so all existing code/checkpoints are unaffected

Test plan

  • 8 new unit tests covering encoding shape, determinism, forward pass, slot-invariance, and legacy compatibility
  • All 99 nn unit tests pass
  • All 48 integration tests pass
  • Pre-commit (ruff, mypy, bandit, interrogate, ruff-format) all pass

Made with Cursor

Replace legacy time-index + month embeddings with a multi-frequency
sinusoidal temporal encoding based on fractional year. The encoding
uses geometric-spaced frequencies from ~128-year periods to daily
resolution, making it slot-position invariant (same calendar date
always gets the same encoding regardless of time slot index).

- Add TimestampEncodingMode enum and get_static_temporal_encoding()
- Thread timestamp_encoding_mode through CompositeEncodings, FlexiVitBase,
  Encoder, PredictorBase, EncoderConfig, PredictorConfig
- Add experiment script (vnext base_band_dropout variant)
- Add 8 unit tests covering shape, determinism, forward pass, and legacy compat

Made-with: Cursor
@github-actions github-actions Bot added the size/m label Apr 7, 2026
- Precompute temporal frequencies as a registered buffer instead of
  recomputing linspace/exp on every forward pass
- Use TimestampEncodingMode enum as single source of truth for config
  validation instead of duplicated string literals
- Remove duplicate self.embedding_size assignment
- Fix docstring for get_static_temporal_encoding (clarify approximate DOY)
- Use fixed timestamps in test_static_temporal_differs_from_legacy
- Add edge case tests: odd dim assertion, invalid mode, freqs buffer shape

Made-with: Cursor
@pjreddie pjreddie marked this pull request as draft April 7, 2026 05:14
pjreddie and others added 2 commits April 15, 2026 18:14
Simpler implementation: get_static_temporal_encoding now takes
encoding_dim and computes frequencies inline rather than requiring
a precomputed buffer. The computation is trivial (linspace on ~64
elements) so caching provides no meaningful benefit.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…device bug

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added size/l and removed size/m labels Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant