Skip to content

[ColQwen2] Refactor output tracing (issue #43979)#44713

Open
kulkarni-rohan wants to merge 1 commit intohuggingface:mainfrom
kulkarni-rohan:output-tracing-colqwen2
Open

[ColQwen2] Refactor output tracing (issue #43979)#44713
kulkarni-rohan wants to merge 1 commit intohuggingface:mainfrom
kulkarni-rohan:output-tracing-colqwen2

Conversation

@kulkarni-rohan
Copy link

Applies the output tracing refactor to ColQwen2ForRetrieval as part of the broader effort tracked in issue #43979 to modernize output handling across all models in the library.

Changes in both modular_colqwen2.py and modeling_colqwen2.py:

  • Add TransformersKwargs to imports; add Unpack import in modeling file
  • Remove explicit output_attentions, output_hidden_states, and return_dict params from ColQwen2ForRetrieval.forward() -- these are now captured via **kwargs: Unpack[TransformersKwargs]
  • Remove manual config-resolution boilerplate for those three flags
  • Pop output_hidden_states from kwargs and resolve from config as fallback (matching the pattern established in ColPali parent)
  • Always pass output_hidden_states=True to self.vlm.model() so hidden states are always collected internally; only returned to the caller when explicitly requested
  • Spread **kwargs into self.vlm.model() so output_attentions and other flags flow through naturally to the underlying Qwen2VL model, which already handles output capturing via @capture_outputs and @merge_with_config_defaults

The @can_return_tuple decorator (already present) continues to handle the return_dict=False tuple-conversion path.

What does this PR do?

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,
    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?

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.

Applies the output tracing refactor to ColQwen2ForRetrieval as part of
the broader effort tracked in issue huggingface#43979 to modernize output handling
across all models in the library.

Changes in both modular_colqwen2.py and modeling_colqwen2.py:

- Add TransformersKwargs to imports; add Unpack import in modeling file
- Remove explicit output_attentions, output_hidden_states, and
  return_dict params from ColQwen2ForRetrieval.forward() -- these are
  now captured via **kwargs: Unpack[TransformersKwargs]
- Remove manual config-resolution boilerplate for those three flags
- Pop output_hidden_states from kwargs and resolve from config as
  fallback (matching the pattern established in ColPali parent)
- Always pass output_hidden_states=True to self.vlm.model() so
  hidden states are always collected internally; only returned to
  the caller when explicitly requested
- Spread **kwargs into self.vlm.model() so output_attentions and
  other flags flow through naturally to the underlying Qwen2VL model,
  which already handles output capturing via @capture_outputs and
  @merge_with_config_defaults

The @can_return_tuple decorator (already present) continues to handle
the return_dict=False tuple-conversion path.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

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

run-slow: colqwen2

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.

1 participant