Skip to content

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

Open
aman-coder03 wants to merge 7 commits intohuggingface:mainfrom
aman-coder03:refactor-xlm-output-capture
Open

[XLM] Refactor output tracing to align with capture_outputs standardized architecture#44101
aman-coder03 wants to merge 7 commits intohuggingface: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

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