Skip to content

Add target_coverage parameter to logarithmic_windows... - #27

Open
jonscheunemann wants to merge 5 commits into
mainfrom
jonny_const_coverage_windows
Open

jonscheunemann wants to merge 5 commits into
mainfrom
jonny_const_coverage_windows

Conversation

@jonscheunemann

Copy link
Copy Markdown
Collaborator

and corresponding tests.

Added to hold the ratio of measurement steps to actual steps for increasing batchsizes almost constant

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a target_coverage parameter to perspic.logger.logarithmic_windows() to derive base_window from max_steps, aiming to keep the ratio of measurement steps to training steps roughly constant across runs where max_steps varies (e.g., batch-size sweeps).

Changes:

  • Added target_coverage: Optional[float] to logarithmic_windows() and documented its intended usage/behavior.
  • Implemented base_window derivation from target_coverage, max_steps, and the computed number of log points.
  • Added a new unit test suite covering target_coverage behavior and its interaction with adaptive_scale.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
perspic/logger.py Adds the target_coverage parameter, documents it, and derives base_window from it when provided.
tests/unit/test_logger.py Introduces new unit tests validating target_coverage behavior and coverage constancy across a batch-size sweep.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread perspic/logger.py
Comment thread perspic/logger.py Outdated
Comment thread tests/unit/test_logger.py
Comment on lines +186 to +193
window_id_at_794 = next(
wid for wid, c in schedule.window_centers.items() if c == 794
)
window_id_at_0 = next(
wid for wid, c in schedule.window_centers.items() if c == 0
)
assert len(schedule.windows[window_id_at_0]) == 6
assert len(schedule.windows[window_id_at_794]) == 11
@KonstiNik

Copy link
Copy Markdown
Member

If I understand correctly, the idea here is that for different batch sizes / num-steps you get the same coverage in measurements – so sth like 10% of all the steps are measured.

This is a nice idea, and I'd like you to take this into account:

Having a window_size=50 at a given batch size will give you a certain accuracy for the LNP components (See Fig. 6 in our paper). Increasing the batch size will make the computation more accurate at each step (I think falling with $\sim 1/\sqrt{\text{batch size}}$). I believe what's important here is that measurements of runs with different batch sizes have the same statistical error. I think to achieve that, we want to match the number of overall tokens we take into account in the respective measurement window.

How does that compare to what's currently implemented?

jscheunemann added 3 commits August 26, 2026 00:38
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.

3 participants