Skip to content

Add ruler-plus extending RULER evals to 2m tokens - #276

Merged
jopetty merged 10 commits into
allenai:mainfrom
jopetty:ruler-lc-clean
Oct 20, 2026
Merged

jopetty merged 10 commits into
allenai:mainfrom
jopetty:ruler-lc-clean

Conversation

@jopetty

@jopetty jopetty commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Adds ruler_plus_* tasks and suites mirroring the existing RULER tasks/suites, but reading pre-generated data from the allenai/ruler-plus HuggingFace dataset, which extends context sizes from RULER's 131072 cap up to 2097152 tokens (4k → 2m, doubling at each step).

Tasks: ruler_plus_{task}__{size} for every RULER task at each of the ten context sizes. Suites: ruler_plus_{category}__{size} and ruler_plus_all__{size}.

Data loading: each task downloads only its own shard (data/{size}/{task}/validation.jsonl) via hf_hub_download and streams it line by line, so a task never pulls the full ~109 GB repository or holds a whole shard in memory. OLMO_EVAL_RULER_PLUS_DATA_DIR overrides the Hub with a local directory of the same layout for anyone who regenerates the data themselves.

Comparability with ruler_*: ruler-plus generation budgets follow upstream RULER's per-task tokens_to_generate, with 512 samples per condition, whereas ruler_* follows HELMET's budgets with 100 samples. Token counts also use the Dolma tokenizer. Scores are therefore not directly comparable at the same context size; see the RULER vs RULER+ comparison.

Demo run: https://beaker.org/orgs/ai2/workspaces/linear-rnns/work/01KZPE3PYQN125A0Q52SMR3QJK?taskId=01KZPE3PYXRXJG0DASG01GYB6G&jobId=01KZPE3Q2C997APBS38DFVEA9N

Adds ruler_lc_* tasks and suites mirroring the existing RULER family
(same scorers, prompting behavior, and task types) but reading
pre-generated data from a local Weka path (jopetty/RULER) instead of
the allenai/ruler_data HF release, extending context sizes up to
2097152 tokens (vs. the original 131072 cap).

RulerTask is refactored to be extensible via _tasks_registry,
_name_prefix, and _get_data_root() so RulerLcTask can reuse it without
duplicating loading/registration logic. Existing ruler_* tasks are
unaffected.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

@undfined undfined 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.

Overall lgtm! 2 things to consider in comments.

Comment thread src/olmo_eval/data/ruler_lc_loader.py Resolved
Comment thread src/olmo_eval/evals/tasks/ruler_lc.py Resolved
…ition

Renames the ruler-lc task/suite family to ruler-plus, switches data
loading from a local Weka path to the allenai/ruler-plus HuggingFace
dataset repo (downloaded via snapshot_download), and increases the
per-condition sample limit from 100 to 512.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@jopetty
jopetty requested a review from undfined August 14, 2026 02:35
@jopetty jopetty changed the title Add ruler-lc: long-context RULER tasks/suites reading from local disk Add ruler-plus extending RULER evals to 2m tokens Aug 14, 2026

@undfined undfined 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.

Let's try and reduce the I/O and memory footprint a bit.

  • snapshot_download() fetches the entire ~109 GB repository for every task, even though each task needs only one shard. Can we download just the requested task/context file when possible?

  • The loader reads the full multi-GB shard before applying limit, so small runs still incur the full memory and I/O cost. Can we apply the limit while reading the data? Have we run the full suite without exhausting our system memory?

jopetty and others added 2 commits August 14, 2026 16:38
Addresses review feedback on PR allenai#276: snapshot_download() was pulling
the entire ~109 GB allenai/ruler-plus repo per task even though each
task only needs one shard, and the loader read a shard's full contents
into memory before applying the sample limit.

Switches to hf_hub_download() for the single requested shard, and
reservoir-samples (Algorithm R) while streaming the JSONL instead of
materializing the whole file, so peak memory is proportional to the
sample limit rather than shard size.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
jopetty added a commit that referenced this pull request Aug 15, 2026
* Add ruler-lc: long-context RULER tasks/suites reading from local disk

Adds ruler_lc_* tasks and suites mirroring the existing RULER family
(same scorers, prompting behavior, and task types) but reading
pre-generated data from a local Weka path (jopetty/RULER) instead of
the allenai/ruler_data HF release, extending context sizes up to
2097152 tokens (vs. the original 131072 cap).

RulerTask is refactored to be extensible via _tasks_registry,
_name_prefix, and _get_data_root() so RulerLcTask can reuse it without
duplicating loading/registration logic. Existing ruler_* tasks are
unaffected.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* Rename ruler-lc to ruler-plus, load data from HF, and sample 512/condition

Renames the ruler-lc task/suite family to ruler-plus, switches data
loading from a local Weka path to the allenai/ruler-plus HuggingFace
dataset repo (downloaded via snapshot_download), and increases the
per-condition sample limit from 100 to 512.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

* Dependabot too noisy for now (#286)

* Download only the needed ruler-plus shard and stream-sample it

Addresses review feedback on PR #276: snapshot_download() was pulling
the entire ~109 GB allenai/ruler-plus repo per task even though each
task only needs one shard, and the loader read a shard's full contents
into memory before applying the sample limit.

Switches to hf_hub_download() for the single requested shard, and
reservoir-samples (Algorithm R) while streaming the JSONL instead of
materializing the whole file, so peak memory is proportional to the
sample limit rather than shard size.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

---------

Co-authored-by: Claude Sonnet 5 <[email protected]>
Co-authored-by: Tyler Murray <[email protected]>
@jopetty

jopetty commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

6aad682 addresses these points:

  1. it replaces snapshot_download() (which pulled the entire ~109GB allenai/ruler-plus repo) with hf_hub_download() for just the single shard a task actually needs (data/{size}/{task}/validation.jsonl)
  2. load_ruler_plus_shard() now streams the JSONL line-by-line and reservoir-samples (Algorithm R) up to the configured limit, instead of parsing every record into a list before subsampling. Also skips json.loads entirely on lines that don't get selected into the sample.

In local testing, setting --limit 5 drops the memory usage from 8GB to ~500MB.

@codecov-commenter

codecov-commenter commented Sep 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.78261% with 6 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@04676eb). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/olmo_eval/evals/suites/ruler_plus.py 81.25% 1 Missing and 2 partials ⚠️
src/olmo_eval/evals/tasks/ruler_plus.py 90.00% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #276   +/-   ##
=======================================
  Coverage        ?   62.31%           
=======================================
  Files           ?      501           
  Lines           ?    42935           
  Branches        ?     6660           
=======================================
  Hits            ?    26756           
  Misses          ?    14732           
  Partials        ?     1447           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jopetty

jopetty commented Sep 28, 2026

Copy link
Copy Markdown
Contributor Author

Update: this branch is merged with current main (f1686e7), with no conflicts. CI is green.

@undfined, your 8/14 change request is addressed in 6aad682:

  • Each task downloads only its own shard, data/{size}/{task}/validation.jsonl, via hf_hub_download, instead of snapshot_download pulling the full ~109 GB repo.
  • load_ruler_plus_shard() streams the JSONL line by line instead of holding the whole shard in memory.

The data now comes from allenai/ruler-plus on the Hub rather than Weka. OLMO_EVAL_RULER_PLUS_DATA_DIR still points at a local copy with the same layout. The description is updated to match, and the outdated thread about Weka-only data is resolved. Could you re-review when you get a chance?

@gregorybchris gregorybchris left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This review was generated by an agent following REVIEW_GUIDE.md. It is not from a human reviewer. Reply in the PR thread and a maintainer will follow up.

Nice extension. Loading one shard with hf_hub_download and streaming it is the right fix for a ~109 GB repo, and reusing RulerTask keeps prompting and scoring in one place. There are two things to fix before merge.

I found eight issues. The first two affect persisted per-instance results and task identity, so they should be fixed before merge. The next three cover parity with the existing RULER tasks, data availability, and missing tests. The rest are structure and nits.

What I checked: CI is green. Locally, ruff check, ruff format --check, and pytest tests/ --ignore=tests/integration pass (2793 passed). ty reports one warning in unrelated sandbox code. I confirmed that all 130 data/{size}/{task}/validation.jsonl paths in RULER_PLUS_TASKS exist in allenai/ruler-plus at b1c317b5. I also confirmed that the ruler-plus prompt (input + answer_prefix) matches the original RULER input string for niah_s_1__4096.

Blocking

  1. src/olmo_eval/evals/tasks/ruler_plus.py:59
    Many NIAH shards reuse the same index value for different records, so native_id is not unique within a task. I loaded every 4096 shard and counted unique index values out of 512 rows each:

    task unique ids / 512
    niah_s_1 453
    niah_s_2 364
    niah_s_3 342
    niah_mk_1 452
    niah_mk_2 504
    niah_mk_3 65
    niah_mv 313
    niah_mq 439
    vt, cwe, fwe, qa_1, qa_2 512

    The colliding rows are different samples. For example, index 636 in niah_single_1 appears three times with answers 4226067, 9153566, and 3117788. I reproduced the effect end to end: get_task("ruler_plus_niah_mk_3__4096").instances yields 512 instances with 65 distinct metadata["id"] values. The original RULER shards I checked (niah_s_1__4096, niah_s_2__4096) have unique ids.

    build_predictions writes metadata["id"] as native_id (src/olmo_eval/runners/io/builders.py:125). Pairwise analysis aligns and dedupes instances by (experiment_pk, task_hash, native_id) (src/olmo_eval/analysis/pairwise.py:701-705). With these shards, 447 of 512 niah_mk_3__4096 instances would silently drop out of pairwise comparisons, and per-instance rows in storage can't be told apart.

    Please derive the id from something unique per record, such as the row's line number in the shard, captured in the loader before sampling so it stays stable across limit values. Please also add a test asserting that ids are unique across a shard with repeated index values. Separately, do you know why the generator emits duplicate indexes (index range 185 to 14680 for a 512-row shard)? If it runs in chunks that each restart numbering, the data may deserve a note on the dataset card.

    # ruler_plus_loader.py: tag each record with its row position before sampling
    for row, line in enumerate(f):
        ...
        record = json.loads(line)
        record["_row"] = row
    
    # ruler_plus.py
    "id": f"{doc.get('index', index)}_{doc['_row']}",
  2. src/olmo_eval/data/ruler_plus_loader.py:48 and src/olmo_eval/data/ruler_plus_loader.py:36
    The data a task reads is not part of its identity. RulerTask has no data_source, so TaskConfig.to_dict() serializes data_source: None. The task hash is the same regardless of which data was loaded. Two paths change the data without changing the hash:

    • hf_hub_download has no revision, so it follows main. Re-uploading any shard changes every future result under the same task hash and artifact name.
    • OLMO_EVAL_RULER_PLUS_DATA_DIR swaps in arbitrary local data. I confirmed that to_dict() is identical with and without the variable set.

    Please pin the dataset revision (current head is b1c317b593ffe0ea34ef3c045f5bb7842f797cc0). A future data change should then ship as a new revision under a versioned name (:v2), matching how we version other fixes.

    RULER_PLUS_REVISION = "b1c317b593ffe0ea34ef3c045f5bb7842f797cc0"
    ...
    return hf_hub_download(
        repo_id=RULER_PLUS_REPO_ID,
        repo_type="dataset",
        filename=filename,
        revision=RULER_PLUS_REVISION,
    )

    For the env override, could we either drop it, or record its use somewhere persisted (for example the resolved data path in instance metadata, or a distinct task name)? That way a run on regenerated data can't be mistaken for a run on the published data. This gap is partly a framework problem. RulerTask loads data outside the DataSource abstraction, so nothing about its data reaches the hash, and the original RULER tarball download is unpinned in the same way. A follow-up issue to route RULER-family data identity through to_dict would fix both.

Non-blocking

  1. src/olmo_eval/data/ruler_plus_tasks.py:19-90
    The generation budgets differ from the existing ruler_* tasks at the same sizes. NIAH uses 128 here vs. 50 (100 for mk_3/mq, 250 to 300 for mv), cwe 120 vs. 100, vt 30 vs. 50, and qa_* 32 vs. 50. The sample count also rises from 100 to 512 per condition. The new values look like upstream RULER's tokens_to_generate, while ruler_tasks.py follows HELMET. Could you state in the PR description and the module docstring which reference ruler-plus matches? Could you also post a small parity table comparing ruler_plus_*__{4096..131072} with ruler_* for one model? Otherwise readers will assume ruler_plus_niah__32768 and ruler_niah__32768 are directly comparable. One specific concern: niah_mv at 128 tokens vs. 300 may truncate multi-value answers for verbose models.

  2. src/olmo_eval/data/ruler_plus_loader.py:24
    allenai/ruler-plus is currently private (I could only read it with an authenticated token), so no one outside Ai2 can run these tasks. This follows up on the earlier review thread. Please either make the dataset public before merge, or name the tasks as internal and file an issue to make the data public. The generator is referenced as a personal fork (jopetty/RULER). Could the docstrings also pin the commit used to generate the data?

  3. No tests are added. Please add direct unit tests for:

    • load_ruler_plus_shard: reservoir sampling returns max_samples rows, is deterministic for a seed, skips blank lines, and returns everything when max_samples is None or exceeds the shard size.
    • get_ruler_plus_data_file: the env-override path, and the FileNotFoundError for a missing file.
    • RulerPlusTask.process_doc: concatenates answer_prefix, returns None without input, and produces unique ids (finding 1).
    • Registration: all 130 tasks and the per-size suites are registered, and ruler_plus_* names don't shadow ruler_* ones.

    A tiny JSONL fixture in tests/ and monkeypatch.setenv cover all of this without network access.

  4. src/olmo_eval/evals/tasks/ruler.py:290
    Making make_ruler_task_class public extends the type(...) plus globals()[...] class generation to a second module. The guide prefers __init_subclass__ or one class with partial configuration. The pattern predates this PR, so I'm not asking for the refactor here. Could you file an issue to replace it for both RULER families?

Nits

  • Nit: src/olmo_eval/evals/tasks/ruler.py:103 _get_data_root has no override. RulerPlusTask overrides _load_data instead. Consider dropping the hook and its docstring mention until something needs it.
  • Nit: src/olmo_eval/data/ruler_plus_tasks.py:110 The per-size max_gen_toks dict branch is dead, since no ruler-plus entry uses a dict.
  • Nit: src/olmo_eval/evals/suites/ruler_plus.py:4,41 "all 13 tasks" is an exact count that will go stale. "All tasks" is enough.
  • Nit: src/olmo_eval/data/ruler_plus_tasks.py:10 CONTEXT_SIZES could be a tuple.
  • Nit: src/olmo_eval/evals/tasks/ruler_plus.py:49 The hard-coded seed=42 ignores config.seed (inherited from RulerTask). Every shard has exactly 512 rows, so at the default limit, sampling returns the whole shard and this only matters for --limit runs.

Before merge

Please fix the duplicate native_id values (blocking 1) and pin the dataset revision and handle the env override (blocking 2), each with a regression test. Please also resolve dataset visibility or file the internal-only issue (non-blocking 2). Once those land and CI is green, you may merge. Follow-up issues worth filing: routing RULER-family data identity through TaskConfig.to_dict, and replacing the dynamic class generation in ruler.py/ruler_plus.py.

Comment thread src/olmo_eval/data/ruler_plus_tasks.py Resolved
Comment thread src/olmo_eval/evals/tasks/ruler_plus.py Resolved
The generator's `index` field is not a sample id: in niah.py it is
overwritten with the needle's character offset, so it repeats within a
shard (65 distinct values across 512 rows in niah_mk_3__4096). Instances
now take their id from their row in the shard, recorded before sampling
so it does not depend on the limit.

Shards are downloaded at a pinned allenai/ruler-plus revision. Since the
task hash does not cover RULER data, each instance records where its data
came from, so runs on a local OLMO_EVAL_RULER_PLUS_DATA_DIR copy can be
told apart from runs on the published data.

Also: sample with config.seed, note that budgets follow upstream RULER
rather than HELMET, drop the unused _get_data_root hook and per-size
max_gen_toks branch, and add unit tests for the loader, task and suites.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@jopetty
jopetty requested a review from a team as a code owner October 9, 2026 19:11
@jopetty

jopetty commented Oct 13, 2026

Copy link
Copy Markdown
Contributor Author

RULER vs RULER+ comparison run on allenai/Olmo-3-1025-7B. (Beaker runs at https://beaker.org/orgs/ai2/workspaces/oe-olmo3p5-mt/groups/01M4H172MXE03B8D5AG77TX6E9). There's a slight negative trend for RULER+ scores, mostly due to the fact that the token counts are measured differently (RULER+ is pegged to the Dolma tokenizer for better alignment with our own models)

Task 4k 8k 16k 32k 64k
All (avg) 0.951 / 0.933 0.928 / 0.866 0.870 / 0.797 0.797 / 0.729 0.664 / 0.641
niah_s_1 1.000 / 1.000 1.000 / 1.000 1.000 / 1.000 1.000 / 1.000 1.000 / 1.000
niah_s_2 1.000 / 1.000 1.000 / 1.000 1.000 / 1.000 1.000 / 1.000 1.000 / 0.998
niah_s_3 1.000 / 0.988 1.000 / 0.935 0.990 / 0.951 0.990 / 0.982 0.990 / 0.992
niah_mk_1 0.970 / 0.990 0.950 / 0.982 0.940 / 0.918 0.900 / 0.859 0.770 / 0.834
niah_mk_2 1.000 / 0.988 1.000 / 0.959 0.950 / 0.900 0.870 / 0.785 0.690 / 0.580
niah_mk_3 1.000 / 0.975 0.970 / 0.885 0.850 / 0.742 0.600 / 0.523 0.340 / 0.115
niah_mv 1.000 / 0.998 0.998 / 0.978 0.958 / 0.926 0.895 / 0.825 0.735 / 0.719
niah_mq 0.998 / 0.994 0.985 / 0.961 0.975 / 0.911 0.897 / 0.844 0.830 / 0.775
vt 0.998 / 0.944 0.954 / 0.668 0.836 / 0.417 0.686 / 0.413 0.368 / 0.483
cwe 0.905 / 0.918 0.847 / 0.636 0.518 / 0.453 0.467 / 0.199 0.022 / 0.038
fwe 0.960 / 0.915 0.950 / 0.913 0.953 / 0.889 0.860 / 0.863 0.877 / 0.786
qa_1 0.900 / 0.842 0.860 / 0.775 0.830 / 0.707 0.710 / 0.670 0.610 / 0.609
qa_2 0.630 / 0.576 0.550 / 0.562 0.510 / 0.551 0.480 / 0.508 0.400 / 0.400

jopetty and others added 2 commits October 16, 2026 12:01
allenai/ruler-plus stays private: its haystacks include Paul Graham essay
excerpts that we can't relicense for redistribution. Say so in the loader,
task and suite docstrings, and turn the Hub's not-found error for a token
without access into one that explains how to get the data.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jopetty

jopetty commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Update: merged current main (b243a96) with no conflicts, and marked the tasks internal-only (ab452f6).

Agent review (9/29), addressed in 0e1b83c

Blocking

  1. Duplicate native_id: ids now come from each record's row in the shard (_row), set in the loader before reservoir sampling, so they don't change with --limit. (The generator's index is the needle's character offset in niah.py, which is why it repeats.) Tests: test_ids_are_unique_when_index_repeats, test_id_is_stable_across_limits, test_row_is_shard_position_whatever_the_limit.
  2. Data identity: shards download at a pinned RULER_PLUS_REVISION = b1c317b593ffe0ea34ef3c045f5bb7842f797cc0. Each instance records metadata["data_source"]: hf:allenai/ruler-plus@<rev>/<file>, or local:<path> when OLMO_EVAL_RULER_PLUS_DATA_DIR is set (which also logs a warning). Tests: test_downloads_pinned_revision and the env-override tests.

Non-blocking

  1. Budgets: the module docstrings and the PR description now say ruler-plus follows upstream RULER's tokens_to_generate with 512 samples, vs. HELMET budgets with 100 samples in ruler_*. The parity table for Olmo-3-1025-7B is here.
  2. Visibility: allenai/ruler-plus will stay private, because its haystacks include excerpts of Paul Graham essays that we can't relicense for redistribution. ab452f6 marks the tasks and suites as internal-only in their docstrings, and a token without access now gets an error that explains this and points to HF_TOKEN / OLMO_EVAL_RULER_PLUS_DATA_DIR, instead of the Hub's bare "not found". The generator commit is pinned in the ruler_plus_loader.py docstring (jopetty/RULER@7512d241).
  3. Tests: tests/evals/tasks/test_ruler_plus.py covers sampling (cap, determinism, blank lines, no limit / limit above shard size), the env override and the missing-file error, process_doc (answer prefix, missing input, unique ids) and registration (all 130 tasks, the per-size suites, no ruler_ name collisions).
  4. Dynamic class generation: tracked in Share the long-context task base, class factory and JSONL/hub helpers between RULER and HELMET #454. Share the long-context task base, task registration and JSONL/Hub helpers between RULER and HELMET #455 replaces make_ruler_task_class with register_configured.

Nits: all five done: _get_data_root dropped, the dict branch dropped, "all tasks" wording, CONTEXT_SIZES is a tuple, config.seed is used.

The three reuse threads are answered inline (#454 / #455).

@gregorybchris, could you take a look at the fixes above?

@gregorybchris gregorybchris left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This review was generated by an agent following REVIEW_GUIDE.md. It is not from a human reviewer.

Thanks, both blocking items are resolved at ab452f6.

  1. Unique ids. ruler_plus_niah_mk_3__4096 now yields 512 unique ids out of 512 instances (65 before), and niah_mv__4096 yields 512 out of 512. Both checked against the real shards.
  2. Data identity. The revision is pinned, and metadata["data_source"] is written to the requests output, so a run on local data can be told apart from a run on the published data.

Visibility, budgets, tests and the nits are all addressed, and CI is green.

@jopetty
jopetty merged commit a8b3b2e into allenai:main Oct 20, 2026
8 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.

4 participants