#10788·LlamaFactory

[Bug] transformers >= 5.15 removes the GDN kernel attributes: NPU patch becomes a silent no-op, GDN context parallel raises

Author: alanhuangyooCreated Aug 25, 2026Updated Sep 23, 2026
Labelsnpu

Reminder

  • I have read the above rules and searched the existing issues.

System Info

Not a runtime report from one machine — this is a version-boundary problem, verified by reading modeling_qwen3_5.py at each transformers tag.

Reproduction

transformers v5.15.0 moved the linear-attention kernels off the module in [Kernels] Refactor all linear attn models & native kernels fallback. Qwen3_5GatedDeltaNet and Qwen3NextGatedDeltaNet no longer carry self.causal_conv1d_fn, self.chunk_gated_delta_rule or self.act; the forward calls module-level functions wrapped in @use_kernel_func_from_hub_with_fallback instead.

Occurrences of each attribute in src/transformers/models/qwen3_5/modeling_qwen3_5.py:

tag        self.causal_conv1d_fn   self.chunk_gated_delta_rule   self.act
v5.7.0             3                        2                       1
v5.8.0             3                        2                       1
v5.9.0             3                        2                       1
v5.12.0            3                        2                       1
v5.14.0            3                        2                       1
v5.15.0            0                        0                       0
v5.15.1            0                        0                       0

v5.15.0 was released 2026-08-10. pyproject.toml currently pins transformers>=4.55.0,<=5.8.0, so a clean install is on the old shape and nothing is broken today. Two places break the moment that pin moves past 5.14, or when a user installs transformers themselves, which is common enough that it seemed worth writing down before the bump rather than after.

src/llamafactory/model/patcher.py:122 and :134 are the ones that worry me, because they do not raise:

python
for layer in model.model.layers:
    if hasattr(layer, "linear_attn"):
        layer.linear_attn.chunk_gated_delta_rule = npu_chunk_gated_delta_rule

logger.info_rank0("Replaced chunk_gated_delta_rule with NPU-compatible implementation for Qwen3.5 model.")

On >= 5.15 that assignment lands on an attribute nothing reads. hasattr(layer, "linear_attn") still passes, the log still says the replacement happened, and the model goes on calling the module-level chunk_gated_delta_rule. An NPU run would look configured and silently use the wrong kernel. The try/except Exception around it does not help — there is no exception to catch.

src/llamafactory/v1/plugins/model_plugins/parallelization/gdn_attention.py fails loudly at least: gdn_forward_with_cp reads self.causal_conv1d_fn (line 167) and self.chunk_gated_delta_rule (line 217), so GDN context parallel would AttributeError on the first backward.

Expected behavior

Both sites resolve the kernel through a helper that accepts either shape — the module attribute when it exists, the module-level function otherwise — so the NPU patch keeps taking effect and CP keeps working across the pin bump. For the NPU patch specifically, it would also help if a missing attribute logged a warning instead of reporting success.

I have #10787 open against gdn_attention.py already. Happy to send this as a follow-up once that lands, or fold it in if you would rather have one PR — whichever is easier to review. Not opening a PR yet since nothing in the supported range is affected and I did not want to guess at the direction.

Others

No response