Skip to content

Add mindspeed dependency check for NPU-specific paths (FLA & Megatron)#246

Open
0hujun wants to merge 4 commits into
modelscope:mainfrom
0hujun:main
Open

Add mindspeed dependency check for NPU-specific paths (FLA & Megatron)#246
0hujun wants to merge 4 commits into
modelscope:mainfrom
0hujun:main

Conversation

@0hujun

@0hujun 0hujun commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Motivation

Some NPU patches depend on mindspeed, but lacked explicit dependency checks:

  • The FLA patch silently skipped when mindspeed was missing (try/except + warning), making it hard for users to notice
  • The Megatron NPU path had no upfront check, crashing at runtime only when mindspeed was absent

Changes

  1. kernel/builtin.py — Guard the FLA section with exists('mindspeed'): if present, enable FLA; if missing, log a warning and skip FLA while letting other NPU patches apply normally.
  2. model/megatron/megatron.py & multi_lora_megatron.py — Add requires('mindspeed') in src/twinkle/model/megatron/_mindspeed_runtime.py

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces checks for the 'mindspeed' package before applying NPU-specific patches and adapters. In builtin.py, the Qwen3.5 FLA patch is now conditionally applied with a warning logged if 'mindspeed' is not installed. In _mindspeed_runtime.py, a call to requires('mindspeed') was added. The reviewer pointed out a critical bug where requires is used without being imported, which will lead to a NameError at runtime, and provided a code suggestion to import it.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/twinkle/model/megatron/_mindspeed_runtime.py
0hujun and others added 2 commits July 13, 2026 12:11
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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