Skip to content

2026.4.7

Choose a tag to compare

@funkpopo funkpopo released this 07 Apr 03:11
· 170 commits to main since this release

Continues the current fused-op strategy instead of introducing additional fallback-oriented logic.

What Changed

Added a new custom op, anna::causal_conv1d_fused, with both Meta and XPU registrations in the same SYCL extension library.

Added Python-side wrappers and availability checks in anna.model.fused_ops to keep fused-op loading and invocation centralized.

Switched the XPU convolution path in Qwen3GatedDeltaNet to use causal_conv1d_fused, so both the convolution pre-processing stage and the recurrent core now follow the custom-op route on XPU.

Relaxed cached-state reuse so it applies whenever previous cache state exists, instead of only handling single-token decode.

Kept the CPU / non-XPU path as the reference implementation, while the XPU path now prefers the fused operator.

Updated the build script to resolve the Conda environment root correctly and to validate fused-op loading through the project’s runtime loader in the anna environment.

Updated both English and Chinese README files to reflect the broader fused-op coverage and the new build output.

Expanded test coverage for XPU fused causal convolution vs. reference behavior, multi-token causal-conv state updates, and multi-token continuation vs. full forward equivalence.

Testing

python tools/build_gated_delta_fused_op.py

python -m pytest tests/test_fused_op_xpu.py -q

python -m pytest tests/test_model_shapes.py -q

Impact

This PR does not introduce a new public inference API, but it expands the XPU/SYCL fused-kernel coverage on Anna’s linear-attention hot path. It also lays the groundwork for pushing more hot operators further down the same custom-op path in follow-up changes.


继续沿现有 fused-op 方案推进,而不是增加额外的 fallback 机制。

主要改动

新增 anna::causal_conv1d_fused 自定义算子,并在同一份 SYCL 动态库中注册 Meta 和 XPU 实现。

新增 Python 侧 wrapper 和可用性检查,统一通过 anna.model.fused_ops 暴露 fused op 加载与调用入口。

将 Qwen3GatedDeltaNet 的 XPU conv 路径切换为调用 causal_conv1d_fused,使 XPU 上的 conv 预处理与 recurrent core 都走自定义算子路线。

调整状态复用逻辑,只要 cache 中已有历史状态就复用,不再限制为单 token decode。

保留 CPU / 非 XPU 路径作为参考实现,XPU 路径则优先走 fused op。

修正构建脚本中的 Conda 环境路径解析与运行时加载校验,确保在 anna 环境下构建后能正确注册并验证两个 fused op。

更新中英文 README,补充新的构建输出示例和 fused ops 描述。

补充测试,覆盖 XPU fused causal conv 与 reference 对齐、多 token conv 更新语义,以及多 token continuation 与 full forward 对齐。

测试

python tools/build_gated_delta_fused_op.py

python -m pytest tests/test_fused_op_xpu.py -q

python -m pytest tests/test_model_shapes.py -q

影响

这次改动没有引入新的公开推理接口,但扩展了 Anna 在线性注意力热点链路上的 XPU/SYCL fused-op 覆盖范围,为后续继续把更多热点算子沿同一路线下沉到自定义内核打下基础。