-
Notifications
You must be signed in to change notification settings - Fork 213
ROCm: disable cache in generate and fix GPT-OSS dtype #494
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
db69274
e000231
cdb92b0
c312e59
6dfd726
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -259,6 +259,30 @@ def forward( | |
| TEMPORARY_PATCHES.append(patch_CsmDepthDecoderForCausalLM_forward) | ||
|
|
||
|
|
||
| def patch_rocm_disable_generate_cache(): | ||
| try: | ||
| import transformers.generation.utils as generation_utils | ||
| except Exception as e: | ||
| return raise_error("GenerationMixin.generate", e) | ||
|
|
||
| if not getattr(getattr(torch, "version", None), "hip", None): | ||
| return | ||
|
|
||
| if getattr(generation_utils.GenerationMixin, "_unsloth_rocm_generate_patched", False): | ||
| return | ||
|
|
||
| original_generate = generation_utils.GenerationMixin.generate | ||
|
|
||
| def generate(self, *args, **kwargs): | ||
| kwargs["use_cache"] = False | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Overwriting Useful? React with 👍 / 👎. |
||
| return original_generate(self, *args, **kwargs) | ||
|
|
||
| generation_utils.GenerationMixin.generate = generate | ||
| generation_utils.GenerationMixin._unsloth_rocm_generate_patched = True | ||
| pass | ||
github-code-quality[bot] marked this conversation as resolved.
Fixed
Show fixed
Hide fixed
|
||
| TEMPORARY_PATCHES.append(patch_rocm_disable_generate_cache) | ||
|
|
||
|
|
||
| def patch_CsmForConditionalGeneration_forward(): | ||
| try: | ||
| import transformers.models.csm.modeling_csm | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.