Fine-tuning Fun-ASR-Nano on a B200: one step in six takes 1 s because cuDNN SDPA builds a plan for every new batch shape

オープン 初心者向け
#3,704 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
86/100
issue の種類
ドキュメント
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python, pytorch

調査の方向性

examples/industrial_data_pretraining/fun_asr_nano/docs/finetune.md と finetune.sh のレシピから始め、報告されている cuDNN SDPA の挙動と回避策を確認します。遅いステップという症状、影響を受ける sm_90/sm_100 GPU、および回避策 TORCH_CUDNN_SDPA_DEPRIORITIZED=1 を文書化します。fine-tuner が profiling なしで問題を特定して回避できれば、この変更は完了です。

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

説明

Before asking

  1. Searched existing issues for "cudnn", "sdpa", "slow step", "finetune Fun-ASR-Nano". No match.
  2. Searched the docs and examples/industrial_data_pretraining/fun_asr_nano/docs/finetune.md.
  3. Read the README quick start and docs/training.md.

Question

I ran the Fun-ASR-Nano fine-tuning recipe (examples/industrial_data_pretraining/fun_asr_nano/finetune.sh, LLM fine-tuning with the encoder and adaptor frozen, one process) on one B200, following the install steps in docs/installation/installation.md and docs/finetune.md, and got 0.245 s per step on average: 323 of 382 steps took 0.098 s and 59 took about 1.05 s. A profile showed that the slow steps are the ones whose (batch, padded token length) the process had not seen before: the Qwen3 attention calls scaled_dot_product_attention with an explicit padding mask (transformers/integrations/sdpa_attention.py:124), torch 2.11 sends that to cuDNN first on sm_100, and cuDNN builds a new execution plan per shape, 0.44 s forward and 0.55 s backward. With cuDNN taken out of the SDPA backend order (torch.backends.cuda.enable_cudnn_sdp(False) at model init, or TORCH_CUDNN_SDPA_DEPRIORITIZED=1 in the environment), the same step took 0.100 s on average, with the loss within bf16 rounding of the unmodified run.

Code or command

cd examples/industrial_data_pretraining/fun_asr_nano
export CUDA_VISIBLE_DEVICES=0
bash finetune.sh   # with a local model dir, my AISHELL-1 jsonl (3600 train / 200 dev utterances), max_epoch=1, seed=1234

What have you tried?

The trainer's per-step log prints forward_time and backward_time, and both jump by about 0.5 s on the slow steps, but nothing in the log or in docs/finetune.md connects that to the batch shape or to the attention backend, and the step-time histogram only shows up if one plots the 382 lines. A one-line note in docs/finetune.md (or in the trainer's log when a step is several times the running median) saying that on sm_90 and sm_100 cuDNN SDPA rebuilds its plan for every new batch shape, and that TORCH_CUDNN_SDPA_DEPRIORITIZED=1 avoids it, would have saved me the profile.

I opened #3705 to record my experiment: setup, measurements, traces and some potential fixes. A different fix may also well suit the codebase.

Environment

  • OS: Linux 6.8 (CoreWeave node)
  • Python version: 3.11.16
  • FunASR version: 1.4.15, main at 486b4b7ce
  • ModelScope version: 1.40.0
  • PyTorch / torchaudio version: 2.11.0+cu128 / 2.11.0+cu128, transformers 5.17.0
  • Install method (pip, source, Docker): source, pip install -e .
  • Device (cuda, cpu, mps): cuda
  • GPU model: NVIDIA B200 (183 GB), one GPU used
  • CUDA/cuDNN version: 12.8 / 9.19, driver 580.126.20
主要言語
Python
スター
20.4k
フォーク
2k
平均マージ
4時間 55分
マージ済み PR(30日)
169

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

modelscope/FunASR のほかの issue

modelscope/FunASR の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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