Skip to content

Commit 70b0d4e

Browse files
sguggerydshieh
andauthored
Fix compatibility with 1.12 (#17925)
* Fix compatibility with 1.12 * Remove pin from examples requirements * Update torch scatter version * Fix compatibility with 1.12 * Remove pin from examples requirements * Update torch scatter version * fix torch.onnx.symbolic_opset12 import * Reject bad version Co-authored-by: ydshieh <[email protected]>
1 parent 2fecde7 commit 70b0d4e

File tree

7 files changed

+19
-14
lines changed

7 files changed

+19
-14
lines changed

.circleci/config.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
- run: git lfs install
8484
- run: pip install --upgrade pip
8585
- run: pip install .[sklearn,tf-cpu,torch,testing,sentencepiece,torch-speech,vision]
86-
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.11.0+cpu.html
86+
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.12.0+cpu.html
8787
- run: pip install tensorflow_probability
8888
- run: pip install https://github.com/kpu/kenlm/archive/master.zip
8989
- run: pip install git+https://github.com/huggingface/accelerate
@@ -124,7 +124,7 @@ jobs:
124124
- run: git lfs install
125125
- run: pip install --upgrade pip
126126
- run: pip install .[sklearn,tf-cpu,torch,testing,sentencepiece,torch-speech,vision]
127-
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.11.0+cpu.html
127+
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.12.0+cpu.html
128128
- run: pip install tensorflow_probability
129129
- run: pip install https://github.com/kpu/kenlm/archive/master.zip
130130
- run: pip install git+https://github.com/huggingface/accelerate
@@ -159,7 +159,7 @@ jobs:
159159
- run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng
160160
- run: pip install --upgrade pip
161161
- run: pip install .[sklearn,flax,torch,testing,sentencepiece,torch-speech,vision]
162-
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.11.0+cpu.html
162+
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.12.0+cpu.html
163163
- run: pip install https://github.com/kpu/kenlm/archive/master.zip
164164
- run: pip install git+https://github.com/huggingface/accelerate
165165
- save_cache:
@@ -198,7 +198,7 @@ jobs:
198198
- run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng
199199
- run: pip install --upgrade pip
200200
- run: pip install .[sklearn,flax,torch,testing,sentencepiece,torch-speech,vision]
201-
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.11.0+cpu.html
201+
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.12.0+cpu.html
202202
- run: pip install https://github.com/kpu/kenlm/archive/master.zip
203203
- run: pip install git+https://github.com/huggingface/accelerate
204204
- save_cache:
@@ -231,7 +231,7 @@ jobs:
231231
- run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng time
232232
- run: pip install --upgrade pip
233233
- run: pip install .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm]
234-
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.11.0+cpu.html
234+
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.12.0+cpu.html
235235
- run: pip install https://github.com/kpu/kenlm/archive/master.zip
236236
- run: pip install git+https://github.com/huggingface/accelerate
237237
- save_cache:
@@ -269,7 +269,7 @@ jobs:
269269
- run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng
270270
- run: pip install --upgrade pip
271271
- run: pip install .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm]
272-
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.11.0+cpu.html
272+
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.12.0+cpu.html
273273
- run: pip install https://github.com/kpu/kenlm/archive/master.zip
274274
- run: pip install git+https://github.com/huggingface/accelerate
275275
- save_cache:
@@ -439,7 +439,7 @@ jobs:
439439
- run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng
440440
- run: pip install --upgrade pip
441441
- run: pip install .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm]
442-
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.11.0+cpu.html
442+
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.12.0+cpu.html
443443
- run: pip install https://github.com/kpu/kenlm/archive/master.zip
444444
- save_cache:
445445
key: v0.5-torch-{{ checksum "setup.py" }}
@@ -477,7 +477,7 @@ jobs:
477477
- run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng
478478
- run: pip install --upgrade pip
479479
- run: pip install .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm]
480-
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.11.0+cpu.html
480+
- run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.12.0+cpu.html
481481
- run: pip install https://github.com/kpu/kenlm/archive/master.zip
482482
- save_cache:
483483
key: v0.5-torch-{{ checksum "setup.py" }}

examples/pytorch/_tests_requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,4 @@ protobuf
2222
torchvision
2323
jiwer
2424
librosa
25-
torch < 1.12
2625
evaluate >= 0.2.0

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
"timeout-decorator",
163163
"timm",
164164
"tokenizers>=0.11.1,!=0.11.3,<0.13",
165-
"torch>=1.0,<1.12",
165+
"torch>=1.0,!=0.12.0",
166166
"torchaudio",
167167
"pyctcdecode>=0.3.0",
168168
"tqdm>=4.27",

src/transformers/dependency_versions_table.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"timeout-decorator": "timeout-decorator",
6969
"timm": "timm",
7070
"tokenizers": "tokenizers>=0.11.1,!=0.11.3,<0.13",
71-
"torch": "torch>=1.0,<1.12",
71+
"torch": "torch>=1.0,!=0.12.0",
7272
"torchaudio": "torchaudio",
7373
"pyctcdecode": "pyctcdecode>=0.3.0",
7474
"tqdm": "tqdm>=4.27",

src/transformers/models/deberta/modeling_deberta.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ def backward(ctx, grad_output):
187187

188188
@staticmethod
189189
def symbolic(g: torch._C.Graph, input: torch._C.Value, local_ctx: Union[float, DropoutContext]) -> torch._C.Value:
190+
from torch.onnx import symbolic_opset12
191+
190192
dropout_p = local_ctx
191193
if isinstance(local_ctx, DropoutContext):
192194
dropout_p = local_ctx.dropout
@@ -198,7 +200,7 @@ def symbolic(g: torch._C.Graph, input: torch._C.Value, local_ctx: Union[float, D
198200
# Once https://github.com/pytorch/pytorch/issues/78391 is fixed, do something like:
199201
# if opset_version < 12:
200202
# return torch.onnx.symbolic_opset9.dropout(g, input, dropout_p, train)
201-
return torch.onnx.symbolic_opset12.dropout(g, input, dropout_p, train)
203+
return symbolic_opset12.dropout(g, input, dropout_p, train)
202204

203205

204206
class StableDropout(nn.Module):

src/transformers/models/deberta_v2/modeling_deberta_v2.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ def backward(ctx, grad_output):
193193

194194
@staticmethod
195195
def symbolic(g: torch._C.Graph, input: torch._C.Value, local_ctx: Union[float, DropoutContext]) -> torch._C.Value:
196+
from torch.onnx import symbolic_opset12
197+
196198
dropout_p = local_ctx
197199
if isinstance(local_ctx, DropoutContext):
198200
dropout_p = local_ctx.dropout
@@ -204,7 +206,7 @@ def symbolic(g: torch._C.Graph, input: torch._C.Value, local_ctx: Union[float, D
204206
# Once https://github.com/pytorch/pytorch/issues/78391 is fixed, do something like:
205207
# if opset_version < 12:
206208
# return torch.onnx.symbolic_opset9.dropout(g, input, dropout_p, train)
207-
return torch.onnx.symbolic_opset12.dropout(g, input, dropout_p, train)
209+
return symbolic_opset12.dropout(g, input, dropout_p, train)
208210

209211

210212
# Copied from transformers.models.deberta.modeling_deberta.StableDropout

src/transformers/models/sew_d/modeling_sew_d.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,8 @@ def backward(ctx, grad_output):
597597

598598
@staticmethod
599599
def symbolic(g: torch._C.Graph, input: torch._C.Value, local_ctx: Union[float, DropoutContext]) -> torch._C.Value:
600+
from torch.onnx import symbolic_opset12
601+
600602
dropout_p = local_ctx
601603
if isinstance(local_ctx, DropoutContext):
602604
dropout_p = local_ctx.dropout
@@ -608,7 +610,7 @@ def symbolic(g: torch._C.Graph, input: torch._C.Value, local_ctx: Union[float, D
608610
# Once https://github.com/pytorch/pytorch/issues/78391 is fixed, do something like:
609611
# if opset_version < 12:
610612
# return torch.onnx.symbolic_opset9.dropout(g, input, dropout_p, train)
611-
return torch.onnx.symbolic_opset12.dropout(g, input, dropout_p, train)
613+
return symbolic_opset12.dropout(g, input, dropout_p, train)
612614

613615

614616
# Copied from transformers.models.deberta.modeling_deberta.StableDropout

0 commit comments

Comments
 (0)