Skip to content

Fix operator-precedence bug in sparse L0 tracking condition#94

Merged
MaxGhenis merged 1 commit into
mainfrom
fix/tracking-precedence
Apr 17, 2026
Merged

Fix operator-precedence bug in sparse L0 tracking condition#94
MaxGhenis merged 1 commit into
mainfrom
fix/tracking-precedence

Conversation

@MaxGhenis
Copy link
Copy Markdown
Contributor

Summary

Finding #4 (HIGH). i % tracking_n / 2 == 0 parsed as (i % tracking_n) / 2 == 0, which is equivalent to i % tracking_n == 0 because any non-zero remainder divided by 2 is non-zero. The intended 2x logging density (the sparse loop runs 2x as many epochs as the dense loop) was silently lost, halving the fidelity of the sparse performance DataFrame that feeds the dashboard.

Stride is now max(1, tracking_n // 2) with a comment explaining both the intent and the original parse mistake.

Test plan

  • Add tests/test_sparse_tracking.py verifying the sparse DataFrame has ~4x the dense DataFrame row count at 100 dense epochs (2x density × 2x epoch count).
  • All existing tests pass (uv run pytest tests -x -q -> 16 passed).

🤖 Generated with Claude Code

`i % tracking_n / 2 == 0` parsed as `(i % tracking_n) / 2 == 0`,
which is equivalent to `i % tracking_n == 0` because any non-zero
remainder divided by 2 is non-zero. The intended 2x logging density
(the sparse loop runs 2x as many epochs as the dense loop) was
silently lost, halving the fidelity of the sparse performance
DataFrame that feeds the dashboard.

Compute the stride explicitly as `max(1, tracking_n // 2)` and use
`i % sparse_tracking_n == 0`, with a comment explaining the intent
and the original parse mistake so it does not regress.

Adds tests/test_sparse_tracking.py verifying the sparse DataFrame
now has ~4x the dense DataFrame's row count at 100 dense epochs
(2x density * 2x epochs), consistent with the design.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
microcalibrate Ready Ready Preview, Comment Apr 17, 2026 0:40am

Request Review

Copy link
Copy Markdown
Contributor Author

@MaxGhenis MaxGhenis left a comment

Choose a reason for hiding this comment

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

LGTM (cannot self-approve; posting as comment).

  • sparse_tracking_n = max(1, tracking_n // 2) gives the intended 2x log density for the sparse loop (which runs 2x as many epochs). The inline comment explains the parse mistake ((i % tracking_n) / 2 == i % tracking_n == 0) so the intent is obvious on future reads.
  • max(1, ...) guards tracking_n == 1 (when epochs <= 10), preventing a divide-by-zero on i % 0.
  • Test exercises the L0 path via csv_path and reads the sparse CSV back, counting rows to verify the ~4x ratio (2x density × 2x sparse epochs). Tight regression.

Docstring / code comment explains what the tracking density should be (match the 2x epoch ratio). Intent is now self-documenting.

@MaxGhenis MaxGhenis merged commit ac6c1e6 into main Apr 17, 2026
6 checks passed
@MaxGhenis MaxGhenis deleted the fix/tracking-precedence branch April 17, 2026 16:07
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