Skip to content

Adding support for GraniteDoclingHybrid#44445

Draft
gabe-l-hart wants to merge 23 commits intohuggingface:mainfrom
gabe-l-hart:GraniteDoclingHybrid
Draft

Adding support for GraniteDoclingHybrid#44445
gabe-l-hart wants to merge 23 commits intohuggingface:mainfrom
gabe-l-hart:GraniteDoclingHybrid

Conversation

@gabe-l-hart
Copy link
Copy Markdown
Contributor

What does this PR do?

This PR adds support for the forthcoming Granite Docling model based on the Granite 4 LLM architecture (GraniteMoeHybrid).

Draft Status

This PR is in draft pending the possibility of some additional changes:

  • Finalizing the vision projector
  • Finalizing the name as GraniteDoclingHybrid (versus eg GraniteMoeHybridDocling or similar)

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,
    Pull Request section?
  • Was this discussed/approved via a Github issue or the forum? 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, and
    here are tips on formatting docstrings.
  • Did you write any new necessary tests?

Who can review?

Models:

Copy link
Copy Markdown
Member

@zucchini-nlp zucchini-nlp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Left a few comments so we are aligned with recent changes in v5, otherwise the PR is in good shape

**kwargs,
)

image_seq_len = image_seq_len if image_seq_len is not None else self.image_seq_len
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

am I right that this line is the only diff from Idefics3? If yes, I'd prefer to just copy completely from ideifcs because making image_seq_len an arg isn't very useful

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The real diff is below where the GotOcr2 logic is swapped for the Idefics3 logic. I think this may be one of the TBD architectural decisions, so if the team decides to switch back to Idefics3, this ould all go away.

@gabe-l-hart gabe-l-hart force-pushed the GraniteDoclingHybrid branch 2 times, most recently from f2b4745 to a16c63c Compare March 9, 2026 21:11
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

This is untested, but passes code generation correctly now

Branch: GraniteDoclingHybrid
AI-usage: draft (IBM Bob)
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
Co-authored-by: omenetti.matteo@gmail.com
Co-authored-by: nassarofficial@gmail.com
Branch: GraniteDoclingHybrid
AI-usage: full (IBM Bob)
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
Branch: GraniteDoclingHybrid
AI-usage: none
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
…s after v5 rebase

Branch: GraniteDoclingHybrid
AI-usage: none
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
This was getting injected in Idefics3ProcessorKwargs and causing errors
since it's not a valid kwarg in the base ImageProcessorKwargs and somehow
that's what was being validated against (versus
Idefics3ImageProcessorKwargs)

Branch: GraniteDoclingHybrid
AI-usage: none
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
Branch: GraniteDoclingHybrid
AI-usage: none
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
Branch: GraniteDoclingHybrid
AI-usage: none
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
Branch: GraniteDoclingHybrid
AI-usage: none
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
Branch: GraniteDoclingHybrid
AI-usage: none
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
Branch: GraniteDoclingHybrid
AI-usage: none
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
Branch: GraniteDoclingHybrid
AI-usage: none
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
Branch: GraniteDoclingHybrid
AI-usage: none
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
Branch: GraniteDoclingHybrid
AI-usage: none
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
Branch: GraniteDoclingHybrid
AI-usage: none
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
This all lives in `prepare_inputs_for_generation`

Branch: GraniteDoclingHybrid
AI-usage: none
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
Branch: GraniteDoclingHybrid
AI-usage: none
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
Branch: GraniteDoclingHybrid
AI-usage: none
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
Branch: GraniteDoclingHybrid
AI-usage: none
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
Branch: GraniteDoclingHybrid
AI-usage: none
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
This was recommended in review. Also, there was already a bug where
self.image_seq_len was being used for the real computation, so this kwarg
was never fully supported.

Branch: GraniteDoclingHybrid
AI-usage: none
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
Branch: GraniteDoclingHybrid
AI-usage: none
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
Branch: GraniteDoclingHybrid
AI-usage: none
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
Branch: GraniteDoclingHybrid
AI-usage: none
Signed-off-by: Gabe Goodhart <ghart@us.ibm.com>
@gabe-l-hart gabe-l-hart force-pushed the GraniteDoclingHybrid branch from 1bf67fb to f82599a Compare March 11, 2026 19:18
@github-actions
Copy link
Copy Markdown
Contributor

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

run-slow: auto

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.

3 participants