[Ulysses SP] sdpa/eager x non-packed inputs crash with NPU vector-core exception 507035 (IndexCheckKernel OOB)

オープン
#408 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
55/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python, pytorch

調査の方向性

Start by reading DistributedAttention.forward and tracing how the 2D attention mask length relates to the gathered q/k/v sequence length for Ulysses sequence parallelism. Reproduce with sequence_parallel_size=2, attn_impl=sdpa, packing=false, and padding_free=false on Ascend NPU. Done means the mask uses the global sequence length or this configuration is rejected early with an actionable validation message; the report says a fix candidate and companion validation PR are planned.

索引モデルが issue の本文から書いたものです。

説明

bug
Checklist / 检查清单
  • I have searched existing issues, and this is a new bug report. / 我已经搜索过现有的 issues,确认这是一个新的 bug report。
Bug Description / Bug 描述

Ulysses sequence parallelism (sequence_parallel_size>1) with attn_impl=sdpa/eager and
non-packed inputs (padding=False, padding_free=False) crashes on Ascend NPU with a
vector-core exception (507035). The crash is an index-out-of-bounds during attention
mask building: the attention mask stays at the local shard length while q/k/v are
gathered to the global sequence length.

Evidence (cann log):
EE9999: vector core exception, error code 507035
cann IndexCheckKernel: bounds=88, index in [128, 173]

  • bounds=88 is exactly the local seq length (global 176 / SP2)
  • indices 128-173 fall in the global position range (88+40 ~ 88+85)

Triggering matrix (20-step training runs, all on Ascend910 x2):
fa2 + packed -> PASS
fa2 + non-packed -> PASS
sdpa + packed -> rejected by existing validation (requires flash kernel)
sdpa + non-packed -> CRASH (only combination neither supported nor guarded)

An all-ones mask (single sample, no padding) also crashes, which confirms the issue
is the length mismatch, not the padding values.

How to Reproduce / 如何复现
  1. ms-swift dev-swift-v5 + twinkle dev-swift-v5, 2 x Ascend910, torchrun:
  2. Config: sequence_parallel_size=2, attn_impl=sdpa, packing=false, padding_free=false,
    backend=hf, tuner=lora, any text SFT dataset (e.g. alpaca-zh 2000 rows), max_steps=20.
  3. First forward_backward crashes with 507035.

Expected: either the 2D mask is gathered to the global sequence length (like the 4D
path), or config validation rejects this combination early with an actionable message
(flash-attention backends take the varlen path and are unaffected; see companion
ms-swift validation PR).

Additional Information / 补充信息
  • twinkle: dev-swift-v5 @ dd3d68f
  • Hardware: Ascend910 x2 (64GB), torch_npu 2.10.0.post7, CANN 8.x
  • transformers 5.22.1, peft 0.19, Qwen3.5-4B / Qwen3.5-35B-A3B-8L (MoE, 256 experts)
  • We have a fix candidate: gather 2D masks along the sequence dim in
    DistributedAttention.forward (PR to follow), plus an NPU-gated config-level guard in
    ms-swift validate (companion PR).
主要言語
Python
スター
270
フォーク
68
平均マージ
2日 16時間
マージ済み PR(30日)
38

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

modelscope/twinkle のほかの issue

modelscope/twinkle の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。