Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat (brevitas_examples/llm): correct scale init with CPU offloading #1124

Merged
merged 3 commits into from
Dec 17, 2024

Conversation

Giuseppe5
Copy link
Collaborator

Reason for this PR

Offload might cause models to end up on CPU + GPU.
If that is the case, the initialization of scale factor is not correct, since the scales that are on CPU are forgotten because of the offload.
This allows to initialize and fix the scales correctly.

Changes Made in this PR

post_forward has now a hook that stores the new parameters, if these have been updated, like the scale post initialization.

Testing Summary

NA

Risk Highlight

NA

  • This PR includes code from another work (please detail).
  • This PR contains API-breaking changes.
  • This PR depends on work in another PR (please provide links/details).
  • This PR introduces new dependencies (please detail).
  • There are coverage gaps not covered by tests.
  • Documentation updates required in subsequent PR.

Checklist

  • Code comments added to any hard-to-understand areas, if applicable.
  • Changes generate no new warnings.
  • Updated any relevant tests, if applicable.
  • No conflicts with destination dev branch.
  • I reviewed my own code changes.
  • Initial CI/CD passing.
  • 1+ reviews given, and any review issues addressed and approved.
  • Post-review full CI/CD passing.

@Giuseppe5 Giuseppe5 force-pushed the fix_offload_param_init branch from ae69ed0 to 3902b6c Compare December 16, 2024 08:37
@Giuseppe5 Giuseppe5 requested a review from nickfraser December 16, 2024 08:45
Copy link
Collaborator

@nickfraser nickfraser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add comments to the changes in main.py. Looks like internal accelerate hackery that deserves a bit of context.

@nickfraser
Copy link
Collaborator

Nice solution BTW, but me in 6 months won't remember how this works

@Giuseppe5 Giuseppe5 force-pushed the fix_offload_param_init branch from 30d256a to 5190deb Compare December 17, 2024 14:10
@Giuseppe5 Giuseppe5 merged commit 09f1371 into Xilinx:dev Dec 17, 2024
23 checks passed
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