Skip to content

[data] Derive M-RoPE positions from the model instead of a config flag - #6429

Open
tianyu-l wants to merge 1 commit into
shared-microbatch-assemblyfrom
derive-mrope-positions
Open

tianyu-l wants to merge 1 commit into
shared-microbatch-assemblyfrom
derive-mrope-positions

Conversation

@tianyu-l

@tianyu-l tianyu-l commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary (human-written)

Why

Whether image tokens take 3D M-RoPE positions is a property of the model (its full-attention RoPE is MRoPE, as in Qwen3.5), but SFT and RL each make recipes set it by hand: MultiModalCollator.Config.build_mrope_positions and TrainingBatchBuilder.Config.build_mrope_positions. RL's controller rejects a mismatch with the trainer model; SFT doesn't check. Qwen3.5's preprocess_inputs falls back to the 1D positions when mrope_positions is absent, so a Qwen3.5-family SFT recipe that leaves the flag out trains image tokens with the wrong rotary positions, silently.

Example (Qwen3.5 SFT on images):

before: MultiModalCollator.Config()                            -> no mrope_positions -> image tokens get 1D positions, no error
        MultiModalCollator.Config(build_mrope_positions=True)  -> 3D M-RoPE positions
after:  MultiModalCollator.Config()                            -> 3D M-RoPE positions (from the model)

What changed

  • The model declares it, like multimodal_encoder_fqns: MultimodalModel.uses_mrope_positions (False), set True on Qwen35MultimodalModel, whose preprocess_inputs reads mrope_positions; MultimodalModel.Config.uses_mrope_positions reads it from the owner model class. Qwen3.8 Flash-Next's model class inherits it (its config can't inherit Qwen35MultimodalModel.Config: two slotted bases that both add fields can't combine). Models that aren't multimodal have no image tokens, so callers give them False. Checked: for all 21 multimodal flavors it equals whether the full-attention RoPE is MRoPE.
  • SFT: the trainer passes it to the dataloader and the validator, through DatasetBuildContext.build_mrope_positions, which MultiModalCollator reads.
  • RL: the controller passes it to the training batch builder (a constructor argument now, like max_kept_set_size); its mismatch check is deleted. The vLLM registry gates M-RoPE on the same declaration (asserting the full-attention RoPE is MRoPE) instead of get_mrope_config, which is deleted, so the generator and the trainer can't disagree.
  • Both config flags and every recipe's setting are deleted (Qwen3.5/3.6/3.8, Flash-Next, Kimi, Muse Glimmer/Spark, SFT Slake, RL Geometry3K).

Net +4 lines: recipes -13, tests -5, docs +4, source +18 (passing the value from the trainer to the dataloader, validator and the torchft trainer). The point is the removed knob and the silent SFT case, not line count.

User-facing changes

Before After
MultiModalCollator.Config(build_mrope_positions=...) field removed: derived from the model
TrainingBatchBuilder.Config(build_mrope_positions=...) field removed: derived from the trainer model
Qwen3.5-family SFT without the flag: 1D image positions, silently 3D M-RoPE positions

Numerics

Every recipe that set the flag derives the same value (checked for all 29: True for the Qwen3.5/3.6/3.8 and Flash-Next ones, False for Kimi, Muse and SFT Slake), so their numerics are unchanged. Bitwise equal loss and grad_norm vs #6427, 10 steps, seed 42, deterministic, 1 GB300 (scripts/loss_compare.py --assert-equal, grad_norm from TensorBoard):

Config Path Result
qwen35_debugmodel (CC12M images), accelerator graphs off M-RoPE built bitwise equal
qwen35_debugmodel_video M-RoPE built (video) bitwise equal
muse_glimmer_debugmodel_mm, flex attention 1D positions bitwise equal

Testing

  • The recipe tests in test_qwen_multimodal_data.py now also assert uses_mrope_positions per family (True for the Qwen recipes, False for Kimi and Muse): a family that loses it would silently train 1D image positions. test_geometry3k.py checks the RL recipe's model.
  • pytest tests/rl/unit_tests/cpu tests/unit_tests/cpu/components tests/unit_tests/cpu/test_trainer.py tests/unit_tests/cpu/models (aarch64 GB300 host): 2,248 passed; the 5 failures also fail on main on aarch64 (compiled flex attention on CPU, fixed by [tests] Keep compiled flex attention out of CPU unit tests #6422).

Known issues / follow-ups

@pytorch-bot pytorch-bot Bot added ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rl labels Nov 28, 2026
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 28, 2026
@tianyu-l
tianyu-l added this pull request to stack #6396 November 28, 2026 07:17
@tianyu-l

Copy link
Copy Markdown
Contributor Author

@claude review

@github-actions
github-actions Bot requested a review from pzhan9 November 28, 2026 07:17
@claude

claude Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 2m 10s —— View job


Approve -- please address the items before merging (empty human-written summary; the new uses_mrope_positions duplicates get_mrope_config, which the vLLM generator still uses). Review

@claude claude Bot 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.

Verdict: Approve -- please address the items below before merging. The model now decides whether image tokens get M-RoPE positions, which deletes two hand-set flags and fixes a real silent case in SFT. What's left are small local edits. A maintainer still needs to review, since this touches trainer.py and BaseModel.Config.

What this PR does. BaseModel.Config.uses_mrope_positions (default False) is set to True by MultimodalModel.Config when its full-attention RoPE config has takes_mrope_positions (MRoPE.Config). The SFT trainer passes it to the dataloader and validator through DatasetBuildContext. The RL controller passes it to TrainingBatchBuilder. Both config flags, every recipe's setting of them, and the controller's mismatch check are deleted.

Example.

# Qwen3.5 SFT recipe that forgets the flag
collator=MultiModalCollator.Config()
before: no mrope_positions in the batch -> Qwen35MultimodalModel.preprocess_inputs
        falls back to 1D `positions` for image tokens; no error
after:  config.model.uses_mrope_positions == True -> collator builds (T, 3) mrope_positions
# Kimi / Muse: uses_mrope_positions == False -> 1D positions, unchanged

Must fix

  1. The PR body's "Summary (human-written)" section is empty. It needs to be filled in before merge.
  2. torchtitan/models/common/multimodal.py:58-64: this duplicates get_mrope_config (qwen3_5/rope.py:115), which the vLLM generator still uses. With the controller check gone, the trainer and the generator now decide the same question with two different predicates. Have registry.py use cfg.uses_mrope_positions and delete get_mrope_config (see inline comment).

Should consider

  • torchtitan/components/data/loader.py:125 (and validator.py:141, training_batch_builder.py:422, the Monarch actor): the = False defaults let a new caller that forgets the argument silently get 1D positions again. Make the argument required.
  • tests/rl/unit_tests/cpu/test_geometry3k.py:143-148: this test repeats the Qwen3.5 recipe asserts and has a misleading docstring. The Flash-Next case the description highlights isn't covered. Swap this test for a Flash-Next entry in the existing parametrize list.
Details
  • Gate: the problem is real on the base branch. Qwen35MultimodalModel.preprocess_inputs (qwen3_5/model.py:463-467) uses 1D positions whenever mrope_positions is absent, and nothing on the SFT side checked the flag. Deriving it from the model is the right layer and removes a knob nobody would set differently.
  • Callsite audit: GrainDataLoader and Validator are built only in trainer.py and experiments/torchft/trainer.py, and both are updated. TrainingBatchBuilder is built through the Monarch actor and in tests, all updated. No other DatasetBuildContext construction in source needs the value.
  • ClassVar on a slots=True dataclass is excluded from fields and is fine. Subclasses of MRoPE.Config inherit True.
  • A model-side guard (raise in preprocess_inputs when the model uses M-RoPE and pixel_values are present but mrope_positions is missing) would also catch the failure. This PR removes the cause, so that guard isn't needed here.

Not verified: the bitwise loss/grad_norm equality in the description (needs a GPU run).

Comment thread torchtitan/models/common/multimodal.py Outdated
Comment on lines +58 to +64
@property
def uses_mrope_positions(self) -> bool:
"""True when the full-attention RoPE is M-RoPE (e.g. Qwen3.5's); else image tokens
take 1D positions, like text."""
# MLA attention configs (e.g. DeepSeek V3, Kimi K3) have no ``rope`` field.
rope = getattr(self.first_full_attention, "rope", None)
return isinstance(rope, RoPE.Config) and rope.takes_mrope_positions

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.

This is the same predicate as get_mrope_config (torchtitan/models/qwen3_5/rope.py:115), which isn't touched here: the same getattr(self.first_full_attention, "rope", None), even the same MLA comment. But the two tests differ. This one reads RoPE.Config.takes_mrope_positions; that one uses isinstance(rope, MRoPE.Config). The vLLM generator decides on 3D positions through get_mrope_config (rl/generator/vllm/registry.py:204), and the trainer/data side now goes through this property. The controller check that kept those two in agreement is deleted in this PR, so the two predicates are now the only thing that has to stay in sync.

The smallest fix is one predicate. In registry.py, gate on cfg.uses_mrope_positions and read theta/mrope_section from cast(MRoPE.Config, cfg.first_full_attention.rope), then delete get_mrope_config. That's about -7 lines, and generator and trainer can't disagree.

max_context_length: int,
num_tokens_per_microbatch: int,
vision_processor: VisionProcessor | None = None,
build_mrope_positions: bool = False,

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.

The = False default here brings back the failure this PR removes. A new entry point that builds the dataloader (or the validator, validator.py:141, or TrainingBatchBuilder, training_batch_builder.py:422) and forgets to pass the value gets 1D image positions again, with no error. Every in-repo caller already passes it explicitly. Making it a required keyword argument at these three pass-through points (and on the Monarch actor) turns a forgotten pass into a TypeError. It also follows CLAUDE.md: "Don't give internal functions defaults that duplicate a config default."

Comment on lines 143 to +148
def test_recipe_gives_image_tokens_the_positions_its_model_takes() -> None:
"""The training batch builder gives the trainer M-RoPE positions exactly when the model takes them, as
the generator does; Controller.Config rejects a mismatch."""
"""The training batch builder gives the trainer M-RoPE positions exactly when the model
takes them, as the generator does."""
from torchtitan_recipes.rl.geometry3k import rl_grpo_qwen3_5_0_8b_geometry3k

config = rl_grpo_qwen3_5_0_8b_geometry3k()
training_batch_builder = config.async_loop.training_batch_builder

assert training_batch_builder.build_mrope_positions
with pytest.raises(ValueError, match="build_mrope_positions=False.*M-RoPE"):
dataclasses.replace(
config,
async_loop=dataclasses.replace(
config.async_loop,
training_batch_builder=dataclasses.replace(
training_batch_builder, build_mrope_positions=False
),
),
)
assert rl_grpo_qwen3_5_0_8b_geometry3k().trainer.model.uses_mrope_positions

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.

The docstring says this checks what the training batch builder does "as the generator does". It now only reads uses_mrope_positions off a Qwen3.5 model config. The new asserts in test_qwen_multimodal_data.py already cover that same derivation for Qwen3.5. Meanwhile the case the PR description calls out, Flash-Next (whose config isn't a Qwen35MultimodalModel.Config), isn't asserted anywhere. I suggest deleting this test and adding qwen38_flash_next_debugmodel_mm to the test_qwen_recipe_vision_processor_matches_vision_encoder parametrize list (or a one-line assert next to it).

@tianyu-l
tianyu-l force-pushed the derive-mrope-positions branch from 406039a to 4ceab0a Compare November 28, 2026 08:59
@tianyu-l

Copy link
Copy Markdown
Contributor Author

@claude review again

@claude

claude Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 1m 21s —— View job


Approve -- please address the items before merging. None of the four earlier items are fixed at HEAD: the human-written summary is empty, get_mrope_config is still a second predicate, the = False defaults are still there, and the Flash-Next test is still missing. The amended commit adds no new problems. Review

@claude claude Bot 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.

Verdict: Approve -- please address the items below before merging. None of the items from the previous review are fixed at HEAD (4ceab0a, amended 08:58), and the amend adds no new problems. A maintainer still needs to review, since this touches trainer.py.

Correction to the previous review. It said the property lives on BaseModel.Config. That was wrong: uses_mrope_positions is defined only on MultimodalModel.Config (torchtitan/models/common/multimodal.py:58). Each caller (trainer.py:221, experiments/torchft/trainer.py:210, rl/controller/controller.py:907) guards it with isinstance(config.model, MultimodalModel.Config). I checked Flash-Next: its config subclasses MultimodalModel.Config (qwen3_8_flash_next/model.py:414), and its RoPE config subclasses Qwen35MRoPE.Config (qwen3_8_flash_next/attention.py:106). So it does derive True.

Must fix (still open)

  1. The PR body's "Summary (human-written)" section is still empty.
  2. torchtitan/models/common/multimodal.py:58-65 vs torchtitan/models/qwen3_5/rope.py:115: there are still two predicates for the same question. The trainer and data side use uses_mrope_positions (RoPE.Config.takes_mrope_positions). The vLLM generator uses get_mrope_config (isinstance(rope, MRoPE.Config), rl/generator/vllm/registry.py:204). The controller check that kept them in agreement is deleted. Fix: in registry.py, gate on cfg.uses_mrope_positions, read theta and mrope_section from cast(MRoPE.Config, cfg.first_full_attention.rope), and delete get_mrope_config.

Should consider (still open)

  • torchtitan/components/data/loader.py:125, components/validator.py:141, rl/trainer/training_batch_builder.py:422, rl/actors/monarch/training_batch_builder.py:39 (and DatasetBuildContext.build_mrope_positions at components/data/types.py:102): the = False defaults are still there. A new caller that forgets the argument silently gets 1D image positions again. Make it a required keyword.
  • tests/rl/unit_tests/cpu/test_geometry3k.py:143-148: this test still repeats the Qwen3.5 assert in test_qwen_multimodal_data.py, and its docstring describes behavior it no longer checks. Flash-Next, the case the description highlights, is still not in the test_qwen_recipe_vision_processor_matches_vision_encoder parametrize list (test_qwen_multimodal_data.py:251-261). Replace this test with a (qwen38_flash_next_configs, "qwen38_flash_next_debugmodel_mm") entry there.
Details
  • Re-checked at HEAD: the callsites of GrainDataLoader, Validator, TrainingBatchBuilder, and MultiModalCollator all pass the derived value. No recipe still sets either deleted field. ClassVar on the slots=True RoPE configs stays out of the dataclass fields, and subclasses inherit it.
  • The isinstance(..., MultimodalModel.Config) and ...uses_mrope_positions expression is repeated in three places (one of them in experiments). That is acceptable at this size. Fixing must-fix 2 doesn't change it.

Not verified: the bitwise loss/grad_norm equality in the description (needs a GPU run).

@tianyu-l
tianyu-l force-pushed the derive-mrope-positions branch from 4ceab0a to 9059e3d Compare November 28, 2026 09:11
@tianyu-l

Copy link
Copy Markdown
Contributor Author

@claude review again

@claude

claude Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 1m 53s —— View job


Approve -- please address the items before merging. The new class-attribute derivation is fine, but all four earlier items are still open. The two-predicate item now has a different shape: the trainer reads uses_mrope_positions from the model class, while the vLLM generator still decides with get_mrope_config. Review

@claude claude Bot 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.

Verdict: Approve -- please address the items below before merging. HEAD 9059e3d changes how the value is derived, and that change is fine. All four earlier items are still open, though, and the two-predicate one now has a different shape. A maintainer still needs to review, since this touches trainer.py.

What changed since the last review. uses_mrope_positions is now a class attribute on the model: MultimodalModel.uses_mrope_positions = False (torchtitan/models/common/multimodal.py:43), set to True on Qwen35MultimodalModel (qwen3_5/model.py:386). MultimodalModel.Config.uses_mrope_positions reads it from type(self)._owner (multimodal.py:60-64). This follows the existing multimodal_encoder_fqns precedent in the same __post_init__. Flash-Next gets True through the MRO: Qwen38FlashNextMultimodalModel(Qwen38FlashNextModel, Qwen35MultimodalModel) puts Qwen35MultimodalModel ahead of MultimodalModel. Kimi, Muse Glimmer and Muse Spark inherit False.

Example.

Qwen3.5 SFT, collator=MultiModalCollator.Config()
  Qwen35MultimodalModel.Config._owner.uses_mrope_positions == True
  -> trainer passes build_mrope_positions=True -> collator builds (T, 3) mrope_positions
RL generator for the same model: get_mrope_config(cfg) -> isinstance(rope, MRoPE.Config)
  -> a different question, and nothing checks the two answers agree any more

Must fix (still open)

  1. The PR body's "Summary (human-written)" section is still empty.
  2. torchtitan/rl/generator/vllm/registry.py:204 vs torchtitan/models/common/multimodal.py:43: two predicates still answer the same question, and now they read different sources. The trainer and data side use a hand-set class attribute. The vLLM generator still uses get_mrope_config (qwen3_5/rope.py:113, isinstance(rope, MRoPE.Config)). The controller check that kept them in agreement is gone. Take a new multimodal model whose RoPE is MRoPE.Config but whose class doesn't set the attribute: the generator serves 3D positions, the trainer trains on 1D, and nothing raises. That is the same silent failure this PR removes from SFT. Fix: in registry.py, gate on isinstance(cfg, MultimodalModel.Config) and cfg.uses_mrope_positions (serves_images already implies a multimodal config), read theta/mrope_section from cast(MRoPE.Config, cfg.first_full_attention.rope), and delete get_mrope_config. That's about -7 lines.

Should consider (still open)

  • components/data/loader.py:125, components/validator.py:141, rl/trainer/training_batch_builder.py:422, rl/actors/monarch/training_batch_builder.py:39, components/data/types.py:102: the = False defaults are unchanged. A new caller that forgets to pass the value silently gets 1D image positions again. Make the argument required. The test_packed_vision.py contexts already pass it explicitly.
  • tests/rl/unit_tests/cpu/test_geometry3k.py:143-148: this test still repeats the Qwen3.5 assert in test_qwen_multimodal_data.py:276, and its docstring describes training-batch-builder behavior it doesn't check. Flash-Next is still missing from the parametrize list at test_qwen_multimodal_data.py:251-261. It's the one family where the value arrives only through MRO, so it's the case most worth guarding. Replace this test with a (qwen38_flash_next_configs, "qwen38_flash_next_debugmodel_mm") entry there.
Details
  • _owner is set per Config class by Configurable.__init_subclass__ (config/configurable.py:190). Every multimodal model class defines its own Config, so the property resolves to the right class for all five families. Reading _owner from a config's __post_init__ or a property already has precedent in multimodal.py:49.
  • Callsites re-checked at HEAD: GrainDataLoader and Validator (trainer.py, experiments/torchft/trainer.py), and TrainingBatchBuilder (the Monarch actor via controller.py:907, plus tests) all pass the derived value. No recipe still sets either deleted field.

Not verified: the description's claim that the attribute equals "full-attention RoPE is MRoPE" for all 21 multimodal flavors (I couldn't run Python in this job), and the bitwise loss/grad_norm equality (needs a GPU run).

SFT (MultiModalCollator.Config) and RL (TrainingBatchBuilder.Config) each had a
build_mrope_positions flag that recipes set by hand to whether the model's image tokens
take 3D M-RoPE positions. RL's controller rejected a mismatch; SFT didn't check, and a
Qwen3.5-family SFT recipe without the flag silently gave image tokens 1D positions
(Qwen3.5's preprocess_inputs falls back to positions when mrope_positions is absent).

The model now declares it, like multimodal_encoder_fqns: MultimodalModel.uses_mrope_positions
(False), True on Qwen35MultimodalModel, whose preprocess_inputs reads mrope_positions;
Qwen3.8 Flash-Next's model inherits it (its config can't inherit Qwen35MultimodalModel.Config:
two slotted bases that add fields can't combine). MultimodalModel.Config.uses_mrope_positions
reads it from the owner model class. One declaration feeds every consumer: the trainer passes
it to the dataloader and validator (DatasetBuildContext.build_mrope_positions), the RL
controller to the training batch builder, and the vLLM registry gates M-RoPE on it (asserting
the RoPE is MRoPE) instead of get_mrope_config, which is deleted. Both flags, RL's mismatch
check and the recipes' settings are deleted; every recipe that set the flag derives the same
value.
@tianyu-l
tianyu-l force-pushed the derive-mrope-positions branch from 9059e3d to b70d79a Compare November 28, 2026 09:24
@tianyu-l

Copy link
Copy Markdown
Contributor Author

@claude review again

@claude

claude Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @tianyu-l's task in 56s —— View job


Approve -- please address the items before merging. The two-predicate issue is fixed: the trainer and the vLLM generator now both read uses_mrope_positions, and get_mrope_config is deleted. Three items are still open: the empty human-written summary, the = False defaults, and the missing Flash-Next test entry. Review

@claude claude Bot 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.

Verdict: Approve -- please address the items below before merging. HEAD b70d79a fixes the two-predicate problem: the generator and the trainer now read the same declaration. The other three earlier items are still open, and all three are small local edits. A maintainer still needs to review, since this touches trainer.py.

What changed since the last review. registry.py:205-215 now gates vLLM's M-RoPE on isinstance(cfg, MultimodalModel.Config) and cfg.uses_mrope_positions. It asserts that the full-attention RoPE is MRoPE.Config and reads theta/mrope_section from it. get_mrope_config is deleted (qwen3_5/rope.py), and no references to it remain in the repo.

Example.

Qwen3.5 RL, image prompts
  trainer:   Qwen35MultimodalModel.uses_mrope_positions == True -> training batch builder builds (T, 3) mrope_positions
  generator: same attribute -> rope_parameters["mrope_section"] set -> vLLM uses 3D positions
New multimodal model with MRoPE.Config but no class attribute:
  before this commit: generator 3D, trainer 1D, nothing raised
  now:                both 1D (consistent)
Class attribute True but non-MRoPE RoPE: the registry assert fires

Resolved

  • Two predicates for the same question (registry.py vs multimodal.py): fixed. There is one source now.

Must fix (still open)

  1. The PR body's "Summary (human-written)" section is still empty.

Should consider (still open)

  • components/data/loader.py:125, components/validator.py:141, components/data/types.py:102, rl/trainer/training_batch_builder.py:422, rl/actors/monarch/training_batch_builder.py:39: the build_mrope_positions: bool = False defaults are still there. A new caller that forgets the argument silently gets 1D image positions, which is the failure this PR removes. Every caller in the repo already passes the value explicitly; test_packed_vision.py now does too. Drop the defaults so a missed pass raises TypeError.
  • tests/rl/unit_tests/cpu/test_geometry3k.py:143-148: this test repeats the Qwen3.5 assert at test_qwen_multimodal_data.py:276 (same model class). Flash-Next is still missing from the parametrize list at test_qwen_multimodal_data.py:250-262. It's the one family that gets True only through the MRO (Qwen38FlashNextMultimodalModel(..., Qwen35MultimodalModel)). Replace this test with a (qwen38_flash_next_configs, "qwen38_flash_next_debugmodel_mm") entry there.
Details
  • The new registry assert is the right tool. A class that declares M-RoPE but has a non-M-RoPE RoPE is a programmer error, not a user config error.
  • serves_images alone doesn't imply MultimodalModel.Config at this call site, so the isinstance guard is needed. With it, a text-only Decoder.Config skips M-RoPE correctly.
  • Callsites re-checked at HEAD. GrainDataLoader/Validator are built in trainer.py and experiments/torchft/trainer.py. TrainingBatchBuilder is built through controller.py:907 -> the Monarch actor, plus tests. All of them pass the derived value. No recipe sets either deleted field.

Not verified: the bitwise loss/grad_norm equality in the description (needs a GPU run).

tianyu-l added a commit that referenced this pull request Nov 29, 2026
…6431)

## Summary (human-written)
<!-- Write this yourself, not with an AI tool. 2-5 sentences: the
problem, why
     this approach, and what you checked yourself. -->

## Why
In #6429, the author (an agent) and the `@claude` review bot both
accepted two misplaced members, and the bot approved each version
(406039a, 4ceab0a):

- `BaseModel.Config.uses_mrope_positions`: a question that only means
something for multimodal models, on the config every model implements
(Llama3, Flux, DeepSeek, ...). A `False` default made it type-check
everywhere.
- `RoPE.Config.takes_mrope_positions`: a RoPE declaring how its model
and the data side use it. The model that reads `mrope_positions`
(`Qwen35MultimodalModel.preprocess_inputs`) is what should declare that.

Each was correct, small and used, so every existing checklist item
passed. The checklist also pushed toward the mistake: it bans
`isinstance(cfg, SomeModel.Config)` branches in shared code without
saying a check against a family base (`MultimodalModel.Config`) is fine,
and avoiding that `isinstance` is why the property was hoisted to the
root. The fix the maintainer asked for (a class-level declaration on the
consuming model, like `multimodal_encoder_fqns`) is what #6429 now does.

## What changed
`.claude/skills/pr-review/review-checklist.md`, design section:
- New item: a new member on a base class or shared component must mean
something for every subclass (else it goes on the subset's base); a
component's config must not answer a question about the model or the
data side (the consuming model declares it); a check against a model
class's `Config` misses configs that can't inherit it (slotted
dataclasses can't combine two bases that add fields, e.g. Qwen3.8
Flash-Next vs Qwen3.5).
- Clarified: `isinstance` against a family base at the call site is
fine; the ban is on branching per specific model.

The examples in the new item are analogous (an MoE expert count on the
root, an attention-config flag about document masks), not the #6429
case, so the backtest below measures whether the rule transfers.

## Backtest
Local `/pr-review` runs (one each) on #6429's two earlier commits, with
each commit's own description, from local files only:

| Commit (what it has) | Old checklist (`main`) | New checklist, first
wording | New checklist, this PR |
| --- | --- | --- | --- |
| 406039a (`BaseModel` property + RoPE `ClassVar`) | root property
**endorsed** ("the least intrusive option ... the trainer stays free of
`isinstance` checks"); RoPE `ClassVar` not flagged | both flagged | both
flagged; proposes the model-class declaration |
| 4ceab0a (RoPE `ClassVar` only) | -- (the live bot approved it) |
**missed** the RoPE `ClassVar` | flagged ("wrong owner ... the consuming
model declares this") |

The first wording ("a lower-level piece must not encode how its
container uses it") was too abstract to catch the `ClassVar`; naming the
shape (a flag or `ClassVar` on a component's config that answers a
question about the model or the data side) did. One run per cell, so
this shows the item can fire, not its rate.

## Testing
Docs-only (agent skill); `pre-commit` passes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/fake-pg Run 1-GPU Fake PG integration tests ciflow/rl CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant