Skip to content

feat(rm): score GeneratedMedia and let each reward declare the fields it requires - #422

Merged
Rockdu merged 1 commit into
rockdu/rollout-waveform-from-extra-streamsfrom
rockdu/reward-generated-media
Nov 24, 2026
Merged

Rockdu merged 1 commit into
rockdu/rollout-waveform-from-extra-streamsfrom
rockdu/reward-generated-media

Conversation

@Rockdu

@Rockdu Rockdu commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #408 (the waveform reaches Sample.generated_audio). The diff here is the one commit on top of it.

What

  • GeneratedMedia (miles/utils/types.py): what one sample generated, by stream name: visual (Sample.generated_output), audio (Sample.generated_audio) and audio_sample_rate. Sample.generated_media builds it.
  • Every built-in reward entry hands its pool GeneratedMedia records instead of video tensors, and each scorer class declares required_media: frozenset({"visual"}) for PickScore, HPS, HPSv3, OCR and the OpenAI image actor.
  • AsyncRewardActorPool reads required_media when it is built (a missing declaration, an empty one or an unknown field name fails there), rejects a sample that lacks a required field, and sends the scorer only the tensor fields it requires. An image reward therefore neither moves nor reads a waveform.
  • With --use-output-store, the reward actor reads the stored videos of a batch, then its stored waveforms.

Why

Rewards were handed generated_output alone, so the audio of an audio-video rollout (LTX, #413) could not reach any reward. This PR is the interface only: it adds no audio reward model and changes no recipe.

Breaking

  • ApiRewardActor.build_request(output, prompt): output is a GeneratedMedia; the video is output.visual. A subclass must declare required_media.
  • A custom AsyncRewardActorPool: its actor class declares required_media, and its score_batch(outputs, prompts) receives GeneratedMedia records.
  • A --custom-rm-path function that reads sample.generated_output itself is not affected; Sample's fields are unchanged.

Validation

CPU only.

Scope Commit Result
tests/fast/rollout, tests/fast/utils/test_diffusion_rollout_response.py, test_api_rm_config.py, test_output_store_materialize.py, on Linux (two test_sft_read_media.py cases that need a writable HF cache are deselected; they fail on main there too) 55ca215, on #408 fd1f509 and main 4cb1a29 249 passed
pre-commit on the touched files 55ca215 clean

The image reward scores are meant to be unchanged: each scorer reads output.visual, the tensor it was handed before, and the existing scorer tests keep their numbers.

Not validated:

  • GPU e2e: the reward standards have not been run on this head. run-ci-basic on this PR runs the three default e2e tests.
  • An audio scorer end to end: none exists. The audio path through the pool and the stored-output actor is covered by CPU tests with fake scorers.

Files

  • miles/utils/types.py: GeneratedMedia, Sample.generated_media.
  • miles/rollout/rm_hub/core.py: the pool's required_media check and field selection; the stored-output actor reads videos and waveforms.
  • miles/rollout/rm_hub/{pickscore,hps,hpsv3,ocr,api,openai_api}.py: required_media; scorers read output.visual.
  • tests/fast/rollout/test_reward_media.py (new, stage-a-cpu): the pool's contract. The other test files under tests/fast/rollout/ pass GeneratedMedia where they passed tensors.
  • docs/user-guide/rewards.md, docs/user-guide/customization.md: the scorer interface, which the breaking changes above would otherwise leave wrong. They describe the interface only, not how to train with an audio reward.

Checklist

  • pre-commit run --all-files passes — run on the touched files only, clean
  • Added/updated tests for new behaviour
  • pytest -x is green — CPU subset only, see Validation
  • If launch flags changed, python3 train.py --help still parses — no flag changed
  • If a public flag was added, it appears in the CLI reference docs — none added
  • If an example was added, it has a real walkthrough — none added

… it requires

Rewards were handed generated_output alone, so the waveform an audio-video
rollout produces could not reach any reward. Every reward entry now hands its
pool one GeneratedMedia per sample (visual, audio, audio_sample_rate), and
each scorer class declares required_media. The pool rejects a scorer whose
declaration is missing or names no known field when the pool is built,
rejects a sample missing a required field, and sends no other tensor field,
so image rewards neither move nor read a waveform.

Breaking: the outputs a reward actor's score_batch receives, and the output
ApiRewardActor.build_request receives, are GeneratedMedia records instead of
tensors (the video is output.visual); a scorer class, including every
ApiRewardActor subclass, must declare required_media.
@Rockdu Rockdu added run-ci-basic Authorize and run only basic unlabeled CI tests run-ci-e2e Run e2e metric-regression tests on this PR labels Nov 24, 2026
@Rockdu
Rockdu marked this pull request as ready for review November 24, 2026 22:20
@Rockdu
Rockdu merged commit 3dcb12a into rockdu/rollout-waveform-from-extra-streams Nov 24, 2026
42 of 47 checks passed
Rockdu added a commit that referenced this pull request Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-ci-basic Authorize and run only basic unlabeled CI tests run-ci-e2e Run e2e metric-regression tests on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant