Skip to content

Commit 17f8245

Browse files
author
Hexu Zhao
committed
fun_asr_nano: declare the torch 2.3 floor the fine-tuning recipe needs
1 parent 2c1a0c8 commit 17f8245

4 files changed

Lines changed: 23 additions & 1 deletion

File tree

‎examples/industrial_data_pretraining/fun_asr_nano/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ cd Fun-ASR
5858
pip install -r requirements.txt
5959
```
6060

61+
`finetune.sh` sets `llm_conf.sdpa_backends`, which needs `torch.nn.attention`, so fine-tuning with it requires PyTorch 2.3 or newer.
62+
6163
<a name="usage-tutorial"></a>
6264

6365
# TODO

‎examples/industrial_data_pretraining/fun_asr_nano/README_zh.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ cd Fun-ASR
5858
pip install -r requirements.txt
5959
```
6060

61+
`finetune.sh` 会设置 `llm_conf.sdpa_backends`,该选项依赖 `torch.nn.attention`,因此使用它进行微调需要 PyTorch 2.3 或更高版本。
62+
6163
<a name="用法教程"></a>
6264

6365
# TODO

‎examples/industrial_data_pretraining/fun_asr_nano/requirements.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
torch>=2.0
1+
torch>=2.3
22
funasr
33
websockets>=12.0
44
regex

‎tests/test_fun_asr_nano_train_opts.py‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ class and the recipe's model.py, imported by path). CPU-only, no weights: tiny s
33

44
import importlib.util
55
import os
6+
import re
67
import sys
78
import types
89

@@ -134,3 +135,20 @@ def test_torch_compile_keeps_cpu_decoder_eager(build):
134135
_run(model, 1)
135136
_run(model, 4)
136137
assert [c["batch"] for c in model.llm.model.eager_calls] == [1, 4]
138+
139+
140+
def test_recipe_declares_the_torch_floor_its_options_need():
141+
"""sdpa_backends goes through torch.nn.attention, absent before torch 2.3; if a recipe
142+
turns it on, the example's requirements.txt has to say so."""
143+
for recipe in ("finetune.sh", "lora_finetune.sh"):
144+
path = os.path.join(RECIPE_DIR, recipe)
145+
if not os.path.exists(path):
146+
continue
147+
with open(path) as f:
148+
if "llm_conf.sdpa_backends" not in f.read():
149+
continue
150+
with open(os.path.join(RECIPE_DIR, "requirements.txt")) as f:
151+
declared = re.search(r"^torch>=(\d+)\.(\d+)", f.read(), re.M)
152+
assert declared, f"{recipe} sets sdpa_backends but requirements.txt pins no torch floor"
153+
floor = (int(declared.group(1)), int(declared.group(2)))
154+
assert floor >= (2, 3), f"{recipe} sets sdpa_backends; torch floor is {floor}, needs >= 2.3"

0 commit comments

Comments
 (0)