Skip to content

fix(core): restore lambda scaling in dense context loss - #5

Merged
josaum merged 1 commit into
mainfrom
fix/dense-context-loss-weighting
Oct 25, 2026
Merged

josaum merged 1 commit into
mainfrom
fix/dense-context-loss-weighting

Conversation

@josaum

@josaum josaum commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes the dense context supervision objective so lambda_coeff actually controls its strength.

Previously, lambda was included in both the per-token weights and their normalization denominator. It therefore cancelled for every non-zero value: lambda 0.1, 0.5, 1.0, and 2.0 all produced the same context loss.

Changes

  • Compute distance-only weights and normalize the weighted mean by their sum.
  • Apply lambda_coeff after normalization, preserving a batch-size-independent objective while making supervision strength linear in lambda.
  • Keep the NumPy and zero-dependency pure-Python implementations mathematically identical.
  • Add regressions covering exact weighted-loss values, linear lambda scaling, and backend parity.

Validation

  • pytest -q: 396 passed, 1 skipped
  • ruff check event_jepa_cube/numpy_ops.py tests/test_event_jepa.py: passed
  • ruff format --check event_jepa_cube/numpy_ops.py tests/test_event_jepa.py: passed
  • git diff --check: passed

No public APIs or call sites changed.

@josaum
josaum merged commit 532934c into main Oct 25, 2026
1 of 6 checks passed
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