Skip to content

Commit 450a873

Browse files
committed
docs(rvm): record reward calibration implementation
1 parent 9848405 commit 450a873

1 file changed

Lines changed: 76 additions & 10 deletions

File tree

examples/train/rvm_h3/MJ_VIDEO_REWARD_PROGRESS.md

Lines changed: 76 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ replaced.
2121

2222
## Phase 0 — source audit and implementation plan
2323

24-
**Status:** complete; awaiting commit.
24+
**Status:** complete.
25+
26+
**Commit:** `55d60aec720be847daea4966bc0e98e57eda7abf`
2527

2628
### Current FastVideo implementation inspected
2729

@@ -80,23 +82,87 @@ replaced.
8082
same 2B model twice. A shared runtime and result cache are required.
8183
4. Raw reward units are not comparable. Fixed calibration artifacts must be
8284
generated from baseline FastH3 outputs and versioned with source provenance.
83-
5. RVM currently knows some diagnostic keys through a Dynamic Tracking-specific
84-
branch. General reward-output-key discovery is needed before calibrated/MJ
85-
diagnostics can be broadcast safely across SP ranks.
85+
5. Distributed RVM must know every raw/diagnostic output key before tensor
86+
broadcasts. The scorer now declares this contract explicitly.
87+
88+
## Phase 1 — fixed calibration and reward-output contracts
89+
90+
**Status:** implementation complete; GPU-independent tests authored.
91+
92+
**Implementation commit:** `9848405f27400781fa9ba8b8478ec975034fa97b`
93+
94+
### Implemented
95+
96+
- Added `fastvideo/train/methods/rl/rewards/calibration.py`.
97+
- Added versioned calibration schema `1` with strict validation of finite
98+
centers, positive scales, optional sample counts, required component coverage,
99+
and optional symmetric clipping.
100+
- Added `CalibratedRewardScorer`:
101+
- applies only a fixed affine transform `(raw - center) / scale`;
102+
- preserves each raw score as `<reward>_unnormalized`;
103+
- preserves diagnostics from the wrapped scorer;
104+
- does not modify the wrapped reward implementation.
105+
- Extended `build_multi_reward_scorer` with an optional
106+
`reward_fn.calibration` block using either a versioned JSON artifact or inline
107+
entries for tests.
108+
- Preserved existing behavior when no calibration is configured: the same raw
109+
component scores and weighted sum are used.
110+
- Added an explicit `MultiRewardScorer.output_keys` contract. It validates that
111+
runtime diagnostics exactly match names declared by each scorer.
112+
- Added `RVMRewardProfileMethod`, a thin subclass of the existing
113+
`RVMWithLocalMetricsMethod`. It synchronizes the scorer-declared key tuple over
114+
each SP group's CPU process group. It does not override the RVM rollout,
115+
advantage, velocity loss, optimizer, or validation equations.
116+
- Declared the existing Dynamic Tracking `raw` and `saturation` diagnostics in
117+
the reward builder so the general output contract includes them.
118+
119+
### Tests added
120+
121+
`fastvideo/tests/train/methods/test_reward_calibration.py` covers:
122+
123+
- exact affine calibration and clipping;
124+
- raw/nested diagnostic propagation;
125+
- required-component failures;
126+
- JSON metadata parsing;
127+
- invalid zero, negative, NaN, and infinite scales;
128+
- deterministic output-key ordering;
129+
- unchanged uncalibrated weighted sums;
130+
- calibrated weighted sums and raw-score logging.
131+
132+
The new Python sources and tests were parsed with Python's AST before commit.
133+
A complete repository pytest/pre-commit run has not yet been executed in this
134+
environment and remains part of the final audit.
135+
136+
### Why this is separate from RVM normalization
137+
138+
The fixed component calibration makes unrelated reward units comparable:
139+
140+
```text
141+
raw reward -> fixed baseline z-score -> configured weighted sum
142+
```
143+
144+
The existing RVM code then computes the policy update:
145+
146+
```text
147+
weighted sum -> per-prompt centering -> rollout-global std -> signed coefficient
148+
```
149+
150+
The second stage is unchanged. Calibration never estimates live-policy moments,
151+
so the reward target does not drift during training.
86152

87153
### Next phase
88154

89-
Implement and test the fixed reward-calibration layer and general reward-output
90-
key discovery. This phase must preserve byte-for-byte aggregate behavior for the
91-
existing reward profile when calibration is not configured.
155+
Implement the pinned MJ-VIDEO runtime adapter, exact eight-frame preprocessing,
156+
aspect extraction, one-model/two-scorer shared cache, and fake-runtime tests.
157+
Then add a real-checkpoint GPU preflight; no compatibility claim will be made
158+
until that forward succeeds.
92159

93160
## Commit log
94161

95-
This table is updated after every pushed phase.
96-
97162
| Phase | Commit | Summary | Validation |
98163
|---|---|---|---|
99-
| 0 | pending | Plan, source inventory, and implementation contract | Source audit only |
164+
| 0 | `55d60aec` | Plan, source inventory, and implementation contract | Source audit |
165+
| 1 | `9848405f` | Fixed calibration, output contracts, distributed profile method | AST parse; tests authored |
100166

101167
## GPU validation boundary
102168

0 commit comments

Comments
 (0)