Skip to content

feat(odm): add LEARNABILITY, VELOCITY, and COMBINED rewards - #170

Merged
kmehant merged 3 commits into
foundation-model-stack:mainfrom
amaljoe:odm-learnability-velocity-rewards
Sep 8, 2026
Merged

kmehant merged 3 commits into
foundation-model-stack:mainfrom
amaljoe:odm-learnability-velocity-rewards

Conversation

@amaljoe

@amaljoe amaljoe commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds three new Reward types to the online-data-mixing plugin's compute_reward dispatch: LEARNABILITY (1 - loss_few_shot/loss_zero_shot), VELOCITY (1 - current_loss/previous_loss, tracked via a module-level buffer), and COMBINED (exponentially-decayed blend of the two, alpha(t) = exp(-beta*t/total_steps))
  • OnlineMixingDataset gains optional templated_eval_dataset_dict / templated_eval_collators_dict / beta constructor params — the first two are required together when reward_type is LEARNABILITY or COMBINED (validated at construction, raises ValueError otherwise), and are threaded through _reset_eval_dataloaders, update_sampling_weights, and _extract_information_from_state_for_reward
  • Updates the plugin README's Rewards table and adds test coverage for all three reward types plus the new validation path

Test plan

  • pytest tests/test_compute_reward.py -v — 9/9 passed (3 new: learnability, velocity, combined)
  • pytest tests/test_online_data.py -v — 4/4 passed (2 new: validation error, end-to-end update_sampling_weights)
  • Full suite pytest tests/ — 19/19 passed, no regressions

Adds three new reward types to the online-data-mixing plugin's
compute_reward dispatch, ported from a learnability/velocity-driven
data mixing research prototype:

- LEARNABILITY: 1 - loss_few_shot/loss_zero_shot, comparing a
  category's zero-shot vs few-shot (templated) eval loss.
- VELOCITY: 1 - current_loss/previous_loss, tracking how quickly a
  category's eval loss is still dropping (module-level buffer, no
  dev set needed beyond the existing eval_dataset_dict).
- COMBINED: exponentially-decayed blend of the two,
  alpha(t) = exp(-beta*t/total_steps), favoring learnability early
  in training and velocity later.

OnlineMixingDataset gains optional templated_eval_dataset_dict /
templated_eval_collators_dict / beta constructor params (required
together with LEARNABILITY/COMBINED, validated at construction time)
and threads them through _reset_eval_dataloaders,
update_sampling_weights, and _extract_information_from_state_for_reward.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Amal Joe <amal.joe@ibm.com>
@amaljoe
amaljoe force-pushed the odm-learnability-velocity-rewards branch from 19445bc to 1931379 Compare September 1, 2026 06:49
Amal Joe and others added 2 commits September 8, 2026 21:14
Splits compute_reward() and _extract_information_from_state_for_reward()
into per-reward-type helper functions plus a dispatch table, bringing
each back under pylint's too-many-return-statements threshold (both had
grown to 9 returns after the LEARNABILITY/VELOCITY/COMBINED additions).

Also fixes a not-an-iterable false positive in
test_online_data_update_sampling_weights_with_templated_eval_dataset:
OnlineMixingDataset.log["count"] starts as an int literal in dataset.py
before being overwritten with a list by update_sampling_weights(), so
pylint's static inference can't see it's iterable by the time the test
reads it. Wrapping in list() satisfies the checker without changing
runtime behavior.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Amal Joe <amal.joe@ibm.com>
update_sampling_weights() falls back to torch.device(0) (cuda:0) when
no accelerator is passed, so the test previously moved the model there
too. That happens to resolve to mps:0 on Apple Silicon but crashes with
"Found no NVIDIA driver" on the CPU-only CI runner, since torch.device(0)
always means CUDA regardless of platform.

Pass a minimal single-process accelerator stub (device=cpu, no-op
prepare/reduce) instead, so the test exercises the same accelerator-driven
code path update_sampling_weights() takes under real (single-process)
Accelerate usage, without depending on any GPU/MPS backend being present.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Amal Joe <amal.joe@ibm.com>
@kmehant
kmehant self-requested a review September 8, 2026 17:16
@kmehant
kmehant merged commit e93b86a into foundation-model-stack:main Sep 8, 2026
9 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.

2 participants