[Fix]: guard LigerQwen3_5CausalLMOutputWithPast import#1169
Open
noemotiovon wants to merge 1 commit intolinkedin:mainfrom
Open
[Fix]: guard LigerQwen3_5CausalLMOutputWithPast import#1169noemotiovon wants to merge 1 commit intolinkedin:mainfrom
noemotiovon wants to merge 1 commit intolinkedin:mainfrom
Conversation
LigerQwen3_5CausalLMOutputWithPast is only defined in output_classes.py
when the installed transformers version includes the Qwen3.5 model. In
older transformers versions, the base class import fails silently and
the Liger subclass is never defined, causing an ImportError when
qwen3_5.py unconditionally imports it at module level.
This breaks CI environments with a transformers version that does not
yet ship Qwen3.5, as test_monkey_patch.py imports qwen3_5.py at
collection time, causing the entire test run to abort with:
ImportError: cannot import name 'LigerQwen3_5CausalLMOutputWithPast'
from 'liger_kernel.transformers.model.output_classes'
Fix by wrapping the import in a try/except block (falling back to None)
and converting the return type annotation to a string literal to avoid
evaluation at function definition time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LigerQwen3_5CausalLMOutputWithPast is only defined in output_classes.py when the installed transformers version includes the Qwen3.5 model. In older transformers versions, the base class import fails silently andthe Liger subclass is never defined, causing an ImportError when qwen3_5.py unconditionally imports it at module level.
This breaks CI(Ascend) environments with a transformers version that does not yet ship Qwen3.5, as test_monkey_patch.py imports qwen3_5.py at collection time, causing the entire test run to abort with:
Fix by wrapping the import in a try/except block (falling back to None) and converting the return type annotation to a string literal to avoid evaluation at function definition time.
make testto ensure correctnessmake checkstyleto ensure code stylemake test-convergenceto ensure convergence