From eb4a9837611531c59106af7e8ac877b8e5dcbe20 Mon Sep 17 00:00:00 2001 From: xyr <1615681145@qq.com> Date: Tue, 14 Jul 2026 16:40:38 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9visible=5Fdevice?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=8A=A5=E9=94=99=E5=92=8Cdense=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E6=B2=A1=E6=9C=89=5Frouter=5Freplay=5Fenabled?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/twinkle/model/transformers/transformers.py | 2 +- src/twinkle/utils/device_mesh.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/twinkle/model/transformers/transformers.py b/src/twinkle/model/transformers/transformers.py index c8fec86d..9be48cae 100644 --- a/src/twinkle/model/transformers/transformers.py +++ b/src/twinkle/model/transformers/transformers.py @@ -384,7 +384,7 @@ def _router_replay_setup(self, router_replay_action, routed_experts=None, batch_ Returns ``cleanup_fn``. Call *cleanup_fn* after the forward to gather recorded indices(when RECORD) and clear global state. """ - if not self._router_replay_enabled: + if not getattr(self, '_router_replay_enabled', False): return lambda: None self._maybe_apply_router_replay() diff --git a/src/twinkle/utils/device_mesh.py b/src/twinkle/utils/device_mesh.py index 7215f7fc..aa8b1c6e 100644 --- a/src/twinkle/utils/device_mesh.py +++ b/src/twinkle/utils/device_mesh.py @@ -538,6 +538,7 @@ class DeviceGroup: ranks: Union[List[int], int] device_type: str gpus_per_worker: int = 1 + visible_devices: Optional[Union[List[str],List[int], str, int]] = None _device_mesh: Dict[str, DeviceMesh] = field(default_factory=dict) From a2f1be96ac9b14edb90f83569452dc7bf8ffddb1 Mon Sep 17 00:00:00 2001 From: xyr <1615681145@qq.com> Date: Tue, 14 Jul 2026 17:22:22 +0800 Subject: [PATCH 2/3] =?UTF-8?q?style:=20=E4=BF=AE=E5=A4=8D=20pre-commit=20?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=A0=BC=E5=BC=8F=E5=8C=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/twinkle/kernel/builtin.py | 9 +++++---- src/twinkle/utils/device_mesh.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/twinkle/kernel/builtin.py b/src/twinkle/kernel/builtin.py index faffb4e7..7675767b 100644 --- a/src/twinkle/kernel/builtin.py +++ b/src/twinkle/kernel/builtin.py @@ -90,10 +90,11 @@ def npu_builtin(model: nn.Module | None = None) -> dict[Any, dict[str, Any]]: if exists('mindspeed>=0.12.1') and exists('flash-linear-attention'): apply_qwen3_5_fla(model) else: - logger.warning('[NPU] [FLA] mindspeed or flash-linear-attention is not installed, or mindspeed version smaller than 0.12.1; ' - 'FLA patch for Qwen3.5 requires mindspeed and flash-linear-attention. ' - 'Install them with: pip install flash-linear-attention and mindspeed from source code via https://gitcode.com/Ascend/MindSpeed.' - 'Other NPU patches will still apply.') + logger.warning( + '[NPU] [FLA] mindspeed or flash-linear-attention is not installed, or mindspeed version smaller than 0.12.1; ' + 'FLA patch for Qwen3.5 requires mindspeed and flash-linear-attention. ' + 'Install them with: pip install flash-linear-attention and mindspeed from source code via https://gitcode.com/Ascend/MindSpeed.' + 'Other NPU patches will still apply.') return bundle diff --git a/src/twinkle/utils/device_mesh.py b/src/twinkle/utils/device_mesh.py index aa8b1c6e..20cda0cf 100644 --- a/src/twinkle/utils/device_mesh.py +++ b/src/twinkle/utils/device_mesh.py @@ -538,7 +538,7 @@ class DeviceGroup: ranks: Union[List[int], int] device_type: str gpus_per_worker: int = 1 - visible_devices: Optional[Union[List[str],List[int], str, int]] = None + visible_devices: Optional[Union[List[str], List[int], str, int]] = None _device_mesh: Dict[str, DeviceMesh] = field(default_factory=dict) From 71c9bc6bc013434dbbf08fd54ad725b3d5107d7f Mon Sep 17 00:00:00 2001 From: xyr <1615681145@qq.com> Date: Wed, 15 Jul 2026 10:11:18 +0800 Subject: [PATCH 3/3] fix: resolve flake8 formatting in builtin.py --- src/twinkle/kernel/builtin.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/twinkle/kernel/builtin.py b/src/twinkle/kernel/builtin.py index 7675767b..3a6de079 100644 --- a/src/twinkle/kernel/builtin.py +++ b/src/twinkle/kernel/builtin.py @@ -90,11 +90,13 @@ def npu_builtin(model: nn.Module | None = None) -> dict[Any, dict[str, Any]]: if exists('mindspeed>=0.12.1') and exists('flash-linear-attention'): apply_qwen3_5_fla(model) else: - logger.warning( - '[NPU] [FLA] mindspeed or flash-linear-attention is not installed, or mindspeed version smaller than 0.12.1; ' - 'FLA patch for Qwen3.5 requires mindspeed and flash-linear-attention. ' - 'Install them with: pip install flash-linear-attention and mindspeed from source code via https://gitcode.com/Ascend/MindSpeed.' - 'Other NPU patches will still apply.') + logger.warning('[NPU] [FLA] mindspeed or flash-linear-attention is not installed, ' + 'or mindspeed version smaller than 0.12.1; ' + 'FLA patch for Qwen3.5 requires mindspeed and flash-linear-attention. ' + 'Install them with: pip install flash-linear-attention, ' + 'and install mindspeed from source code via ' + 'https://gitcode.com/Ascend/MindSpeed. ' + 'Other NPU patches will still apply.') return bundle