[MGP-STR] Refactor output tracing to use capture_outputs/can_return_tuple decorators#44086
Open
Zephyr-Blessed wants to merge 1 commit intohuggingface:mainfrom
Open
[MGP-STR] Refactor output tracing to use capture_outputs/can_return_tuple decorators#44086Zephyr-Blessed wants to merge 1 commit intohuggingface:mainfrom
Zephyr-Blessed wants to merge 1 commit intohuggingface:mainfrom
Conversation
…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.
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: mgp_str |
This was referenced Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Migrates MGP-STR to the standardized output collection interface using
@capture_outputsand@can_return_tupledecorators.Changes:
_can_record_outputs = {"hidden_states": MgpstrLayer, "attentions": MgpstrAttention}onMgpstrPreTrainedModel@capture_outputsonMgpstrModel.forward@can_return_tupleonMgpstrForSceneTextRecognition.forwardoutput_attentions,output_hidden_states,return_dictparameters from forward signaturesMgpstrEncoderMgpstrLayernow returnshidden_statesdirectly instead of a tupleMgpstrAttentionstill returns(context_layer, attention_probs)for hook capture16 insertions, 48 deletions — a net reduction of 32 lines.
Part of #43979.
Also submitted: #44084 (GPT-J), #44085 (RemBERT)