Skip to content

[Fix]: guard LigerQwen3_5CausalLMOutputWithPast import#1169

Open
noemotiovon wants to merge 1 commit intolinkedin:mainfrom
noemotiovon:bugfix
Open

[Fix]: guard LigerQwen3_5CausalLMOutputWithPast import#1169
noemotiovon wants to merge 1 commit intolinkedin:mainfrom
noemotiovon:bugfix

Conversation

@noemotiovon
Copy link
Copy Markdown
Contributor

@noemotiovon noemotiovon commented Mar 26, 2026

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
  • run make test to ensure correctness
  • run make checkstyle to ensure code style
  • run make test-convergence to ensure convergence

  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.
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.

1 participant