Repository navigation
fix for intel devices torch compile configs - #3952
Conversation
Summary of ChangesHello @leizhenyuan, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the hardware compatibility and performance of Unsloth's reinforcement learning trainers. By introducing device-aware Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Pls note, this pr rely on unslothai/unsloth-zoo#451 |
There was a problem hiding this comment.
Code Review
This pull request introduces fixes for torch.compile configurations on Intel devices (XPU) by making the options device-specific. The changes correctly abstract away device-specific calls like torch.cuda.synchronize() to a generic device_synchronize() function. My main feedback is to refactor a small piece of duplicated code where compile options for 'xpu' and the default case are identical. Consolidating this will improve code clarity and maintainability. Otherwise, the changes look good.
| elif DEVICE_TYPE == "xpu": | ||
| # XPU-specific torch_compile_options (disable CUDA-specific options) | ||
| new_options = """torch_compile_options = { | ||
| "epilogue_fusion" : True, | ||
| "max_autotune" : False, | ||
| "shape_padding" : True, | ||
| "trace.enabled" : False, | ||
| }""" | ||
| else: | ||
| # Default options for other device types (hip, etc.) | ||
| new_options = """torch_compile_options = { | ||
| "epilogue_fusion" : True, | ||
| "max_autotune" : False, | ||
| "shape_padding" : True, | ||
| "trace.enabled" : False, | ||
| }""" |
There was a problem hiding this comment.
The torch_compile_options for xpu and the default else case are identical. You can combine these blocks to reduce code duplication and improve maintainability.
else:
# Default options for other device types (xpu, hip, etc.)
new_options = """torch_compile_options = {
"epilogue_fusion" : True,
"max_autotune" : False,
"shape_padding" : True,
"trace.enabled" : False,
}"""|
|
||
| if RLTrainer_name == "GRPOTrainer": | ||
| new_options = """torch_compile_options = { | ||
| # Generate torch_compile_options based on device type |
There was a problem hiding this comment.
NIT: Isn't it simpler if we have base compile_options and then add on top of them?
Because I see all the 3 backends have same configs.
…ic extensions - Extract common options into base_options shared by all device types - CUDA devices get additional CUDA-specific options - XPU, HIP, and other devices use base options only - Reduces code duplication and improves maintainability
|
Thanks so much! |
* fix for intel devices * Refactor torch_compile_options to use base options with device-specific extensions - Extract common options into base_options shared by all device types - CUDA devices get additional CUDA-specific options - XPU, HIP, and other devices use base options only - Reduces code duplication and improves maintainability * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: danielhanchen <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
fix for intel devices torch compile configs