Skip to content

[XLM] Refactor output tracing to align with capture_outputs standardized architecture - #44101

Closed
aman-coder03 wants to merge 7 commits into
huggingface:mainfrom
aman-coder03:refactor-xlm-output-capture
Closed

aman-coder03 wants to merge 7 commits into
huggingface:mainfrom
aman-coder03:refactor-xlm-output-capture

Conversation

@aman-coder03

Copy link
Copy Markdown

What does this PR do?

This PR refactors XLM's output tracing to align with the standardized output capturing patterns used across the codebase.

Key changes:

  • Refactors transformer blocks into a dedicated XLMLayer module to enable structured output capture
  • Integrates the capture_outputs decorator with _can_record_outputs to automatically capture attention weights from each transformer layer
  • Removes manual attention propagation logic and relies on the standardized output capturing infrastructure
  • Implements explicit hidden_states collection in XLMModel.forward to ensure embedding outputs and all intermediate layer outputs are correctly returned
  • Ensures proper handling and propagation of output_attentions, output_hidden_states, and return_dict flags

Why is this needed?

This aligns XLM with the standardized output tracing architecture introduced in #43979 ensuring consistent behavior across models and compatibility with the shared output capturing infrastructure.

@github-actions

Copy link
Copy Markdown
Contributor

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

run-slow: flaubert, xlm

@ArthurZucker

Copy link
Copy Markdown
Collaborator

Thanks for the XLM refactor, @aman-coder03! The #43979 call to contributions was closed right after this was opened and we couldn't review all the PRs it produced, so I'm closing this one. Sorry it didn't get looked at in time.

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.

2 participants