Add Molmo2
Author: SangbumChoi
Pull request: yes

<!-- ci-dashboard-badge:start -->
[![CI](https://transformers-ci.lor-e.huggingface.cool/badge/pr?pr=43451)](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=43451)
<!-- ci-dashboard-badge:end -->

# What does this PR do?

<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->

<!-- Remove if not applicable -->

Fixes # (issue)


## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [ ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#create-a-pull-request),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?


## Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- text models: @ArthurZucker @Cyrilvallez
- vision models: @yonigozlan @molbap
- audio models: @eustlb @ebezzam @vasqu
- multimodal models: @zucchini-nlp
- graph models: @clefourrier

Library:

- generate: @zucchini-nlp (visual-language models) or @gante (all others)
- continuous batching: @remi-or @ArthurZucker @McPatate
- pipelines: @Rocketknight1
- tokenizers: @ArthurZucker and @itazap
- trainer: @SunMarc
- attention: @vasqu @ArthurZucker @CyrilVallez
- model loading (from pretrained, etc): @CyrilVallez
- distributed: @3outeille @ArthurZucker
- CIs: @ydshieh

Integrations:

- ray/raytune: @richardliaw, @amogkam
- Big Model Inference: @SunMarc
- quantization: @SunMarc @MekkCyber
- kernels: @MekkCyber @drbh
- peft: @BenjaminBossan @githubnemo

Devices/Backends:

- AMD ROCm: @ivarflakstad
- Intel XPU: @IlyasMoutawwakil
- Ascend NPU: @ivarflakstad 

Documentation: @stevhliu

Research projects are not maintained and should be taken as is.

 -->

Comments:
@molbap Hi I am still working on it since I have to make some example visualizer for this and (most of the code is generated by Claude code). However, you can start review this with brief level of code review! cc. @merveenoyan 

Btw @SangbumChoi , I will unsubscribe now since @molbap is back from paternity leave and will help you review/update the PR 😄 

Indeed I am back! reviewing somewhere between now and tomorrow :wave: 

@molbap No need to rush I will leave you ping when it finish. I realize there are few more big chunk to solve!

Hey @SangbumChoi ! I took the liberty to push an update, as the model is cool and we'd like to have it merged soon! I pushed to your branch so your original authorship is preserved :raised_hands: 

I mainly took to modularize further the model, processor, (now derived from modular) also vectorized the overlapping patches logic and updated a few integration tests, and I think addressed most remaining comments from @zucchini-nlp 
Also cc @merveenoyan here!

run-slow: molmo2

[Workflow Run ⚙️](https://github.com/huggingface/transformers/actions/runs/26236720885)

This comment contains `run-slow`, running the specified jobs: 

models: ["models/molmo2"]
quantizations: []

oh wow actually I also did alot of commit (my tokens...). Is there anything more left?

I will also make some demo based on this PR and let me share you the intermediate logit additition and so forth.

## CI Results
[Workflow Run ⚙️](https://github.com/huggingface/transformers/actions/runs/26236720885)

### Commit Info
| Context | Commit | Description |
|---------|--------|-------------|
| RUN | [17e6becd](https://github.com/huggingface/transformers/commit/17e6becd674dfe73f9c362fc9266aa7fe049fe17) | workflow commit (merge commit) |
| PR | [d0f30949](https://github.com/SangbumChoi/transformers/commit/d0f30949a51df855da8c995ce20d77d1cba9997d) | branch commit (from PR) |
| main | [10555512](https://github.com/huggingface/transformers/commit/10555512868d663ee1ff627e4f5c5c260114235b) | base commit (on `main`) |

### Model CI Report

❌ **[2 new failed tests from this PR](https://huggingface.co/datasets/hf-internal-testing/transformers_pr_ci/raw/4c3d5a19583eb8f10d3ad1628634c1e3229645c9/2026-05-21/runs/35021-26236720885/ci_results_run_models_gpu/new_failures_with_bad_commit.json)** 😭

- [molmo2](https://github.com/huggingface/transformers/actions/runs/26236720885/job/77213110313):
    tests/models/molmo2/test_modeling_molmo2.py::Molmo2_8BIntegrationTest::test_generation_video_qa (✅ ⟹ ❌)
    tests/models/molmo2/test_video_processing_molmo2.py::Molmo2VideoProcessingTest::test_can_compile_fast_video_processor (✅ ⟹ ❌)



Ah dang, sorry about that then @SangbumChoi . I didn't see pushed activity on the branch and tbh you already had done a lot there, so I figured I'd continue, but I should have pinged first. Feel free to take a look, I simplified a few things modeling and processing-wise, nothing's broken so far... (the slow test failing is a OOM error) and the demo's a great idea! 

Very nice, I can’t wait to see Molmo2 in Transformers! We already have MolmoAct2 in LeRobot, and this will simplify a lot the implementation on our side.

@molbap Let's review this!

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=43451&sha=e83123

Hi thanks for the all comments I will read it and try to modify it :) 

I assume https://github.com/huggingface/transformers/pull/43451#pullrequestreview-4513437972 this is becuase resize logic with similar aspec_ratio or shape is more efficient? is there any blog for this?

@molbap @guarin 70% over ready for review PR (also attached demo in chat). might be done in this week.

[molmo2_finetune.ipynb](https://github.com/user-attachments/files/29484500/molmo2_finetune.ipynb)
[molmo2_demo_(5).ipynb](https://github.com/user-attachments/files/29484503/molmo2_demo_.5.ipynb)


[molmo2_finetune.ipynb](https://github.com/user-attachments/files/29599865/molmo2_finetune.ipynb)


@molbap @merveenoyan @guarin gentle ping

@molbap Got it. From now on I will just leave it as a comment only

Thanks @SangbumChoi ! I also am trying to help narrow down AI-assisted PRs scope to boost contribution. I am trying out a "Self-review" skill to run on your end on your PRs, which should cover the recent API changes/alignment and boost a bit. If you have feedback on it it'd be very helpful!
[transformers_contribution_skill.md](https://github.com/user-attachments/files/29707156/transformers_contribution_skill.md)


**[For maintainers]** Suggested jobs to run (before merge)

run-slow: auto, molmo2

<!-- ci-dashboard-recap:start -->

---

### CI recap

**Dashboard:** [View test results in Grafana](https://transformers-ci.lor-e.huggingface.cool/d/pytest-observability-by-pr/pytest-observability-branch?var-pr=43451)
**Latest run:** [28817248748:2](https://github.com/huggingface/transformers/actions/runs/28817248748)
**Result:** `failure` | **Jobs:** 15 | **Tests:** 171,825 | **Failures:** 6 | **Duration:** 25h 3m

<!-- ci-dashboard-recap:end -->