Skip to content

[MGP-STR] Refactor output tracing to use capture_outputs/can_return_tuple decorators#44086

Open
Zephyr-Blessed wants to merge 1 commit intohuggingface:mainfrom
Zephyr-Blessed:refactor/mgp-str-output-tracing
Open

[MGP-STR] Refactor output tracing to use capture_outputs/can_return_tuple decorators#44086
Zephyr-Blessed wants to merge 1 commit intohuggingface:mainfrom
Zephyr-Blessed:refactor/mgp-str-output-tracing

Conversation

@Zephyr-Blessed
Copy link
Copy Markdown

What does this PR do?

Migrates MGP-STR to the standardized output collection interface using @capture_outputs and @can_return_tuple decorators.

Changes:

  • Added _can_record_outputs = {"hidden_states": MgpstrLayer, "attentions": MgpstrAttention} on MgpstrPreTrainedModel
  • Added @capture_outputs on MgpstrModel.forward
  • Added @can_return_tuple on MgpstrForSceneTextRecognition.forward
  • Removed output_attentions, output_hidden_states, return_dict parameters from forward signatures
  • Removed manual collection loops in MgpstrEncoder
  • MgpstrLayer now returns hidden_states directly instead of a tuple
  • MgpstrAttention still returns (context_layer, attention_probs) for hook capture

16 insertions, 48 deletions — a net reduction of 32 lines.

Part of #43979.

Also submitted: #44084 (GPT-J), #44085 (RemBERT)

…uple decorators

Migrate MGP-STR to the standardized output collection interface:
- Add _can_record_outputs on MgpstrPreTrainedModel
- Add @capture_outputs on MgpstrModel.forward
- Add @can_return_tuple on MgpstrForSceneTextRecognition.forward
- Remove output_attentions/output_hidden_states/return_dict params
- Remove manual hidden_states/attentions collection loops in encoder
- MgpstrLayer returns hidden_states directly instead of tuple

Part of huggingface#43979.
@github-actions
Copy link
Copy Markdown
Contributor

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

run-slow: mgp_str

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