Commit dcd404b
authored
[Fix]: guard LigerQwen3_5CausalLMOutputWithPast import (#1169)
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:
```
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.
- Hardware Type: Atlas 800I A2
- [x] run `make test` to ensure correctness
- [x] run `make checkstyle` to ensure code style
- [ ] run `make test-convergence` to ensure convergence1 parent 3978fe2 commit dcd404b
1 file changed
+6
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
| |||
138 | 142 | | |
139 | 143 | | |
140 | 144 | | |
141 | | - | |
| 145 | + | |
142 | 146 | | |
143 | 147 | | |
144 | 148 | | |
| |||
0 commit comments