From a0a904a3d48e631dde5ea9466339ccd50343bb4b Mon Sep 17 00:00:00 2001 From: Cao Yi Date: Tue, 3 Mar 2026 20:08:39 +0800 Subject: [PATCH] [BugFix] Improve GDN layer detection for multimodal models (#6941) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary - Enhanced `check_gdn_layer()` function to properly detect GDN layers in multimodal models - Added support for checking `text_config.layer_types` in addition to root-level `layer_types` - Fixed potential None reference errors when `layer_types` attribute is missing ## Changes - Modified `vllm_ascend/utils.py`: - Replaced `hasattr()` check with safer `getattr()` approach - Added fallback to empty list when `layer_types` is None - Added secondary check for `text_config.layer_types` to support models like Qwen-Omni ## Motivation Previous implementation only checked `layer_types` at the root config level, which failed to detect GDN layers in multimodal models where this information is nested under `text_config`. Additionally, it could raise errors when `layer_types` was None. --- Co-authored-by: wanghuanjun2113 Co-authored-by: SlightwindSec 🤖 Generated with [Claude Code](https://claude.com/claude-code) - vLLM version: v0.16.0 - vLLM main: https://github.com/vllm-project/vllm/commit/15d76f74e2fdb12a95ea00f0ca283acf6219a2b7 Signed-off-by: SlightwindSec Co-authored-by: wanghuanjun2113 --- vllm_ascend/utils.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/vllm_ascend/utils.py b/vllm_ascend/utils.py index de0e5d12..a45834b6 100644 --- a/vllm_ascend/utils.py +++ b/vllm_ascend/utils.py @@ -1146,7 +1146,16 @@ def check_gdn_layer(vllm_config) -> bool: return False hf_config = model_config.hf_config - if not hasattr(hf_config, "layer_types"): - return False - return "linear_attention" in hf_config.layer_types + # Use `or []` to prevent errors when layer_types is None + layer_types = getattr(hf_config, "layer_types", None) or [] + if "linear_attention" in layer_types: + return True + + text_config = getattr(hf_config, "text_config", None) + if text_config: + text_layer_types = getattr(text_config, "layer_types", None) or [] + if "linear_attention" in text_layer_types: + return True + + return False