finetuning/sft_12hz.py hard-codes attn_implementation="flash_attention_2" — official fine-tuning fails out-of-the-box on ROCm (no flash-attn build)
Description
finetuning/sft_12hz.py passes attn_implementation="flash_attention_2" unconditionally when loading the model, so the official fine-tuning workflow fails out-of-the-box on any stack that has no flash-attn build — notably AMD ROCm, where the official PyTorch wheels ship without flash-attn. The inference path already handles this gracefully (falls back / warns and uses SDPA); the fine-tuning script does not.
Environment
- Qwen3-TTS @
022e286b98fbec7e1e916cb940cdf532cd9f488e(finetuning/sft_12hz.py) - qwen-tts 0.1.1, Python 3.12
- torch
2.12.0+rocm7.14.0, ROCm 7.14, AMD Radeon 8060S (gfx1151, Radeon AI MAX iGPU) - flash-attn: not installed (no ROCm build available for this stack)
What happens
Running data prep (works fine) and then the training script exactly as the finetuning README describes:
python finetuning/sft_12hz.py \
--init_model_path Qwen/Qwen3-TTS-12Hz-1.7B-Base \
--output_model_path <out> \
--train_jsonl <prepared.jsonl>fails at model load with (verbatim from our run transcript):
ImportError: FlashAttention2 has been toggled on, but it cannot be used due to
the following error: the package flash_attn seems to be not installed. Please refer
to the documentation of https://huggingface.co/docs/transformers/perf_infer_gpu_one#flashattention-2
to install Flash Attention 2.Why
The attn_implementation="flash_attention_2" argument is hard-coded in sft_12hz.py, while SDPA works well on ROCm for this model (the community ROCm enablement project Qwen3-TTS-ROCm has the whole official inference surface validated on sdpa/bf16 on gfx1151).
Workaround we verified (single local line, not submitted as a PR yet)
Changing that one argument to "sdpa" lets the full official workflow run end-to-end on ROCm: data prep → training (12-optimizer-step smoke on 1.7B Base, bf16, batch 2) → checkpoint-epoch-N saves (with the usual CustomVoice conversion) → reload via Qwen3TTSModel.from_pretrained → normal synthesis. Everything else is stock upstream code.
Suggested fix
Mirror the inference path's behavior in sft_12hz.py — either:
- add an
--attn_implementationargument (defaultflash_attention_2to preserve current behavior), or - fall back to
sdpawhenflash_attnis not importable (same as the inference-side handling).
Happy to send a PR for either option if maintainers indicate a preference.
Related
- #12 (closed) — same failure class, but on the inference example back before the inference path grew its fallback; fine-tuning still lacks it.
- #293 (closed) — flash-attn installation difficulty; orthogonal to making the trainer not require it.
Source: QwenLM/Qwen3-TTS