Skip to content

Commit 96ea89b

Browse files
Remove legacy export (#57)
- Remove legacy export of decoders - Remove deprecated arguments: use_auth_token, fp16 vs dtype, for_ort, some optimization arguments - Add some missing optimization arguments (added clip optimization to catch them) following [FusionOptions args](https://github.com/microsoft/onnxruntime/blob/88f2652dee465faa485cf68cb39c4489f28945bb/onnxruntime/python/tools/transformers/fusion_options.py#L136) - Fixed CI by adding a Hub token with access to optimum-internal-testing and optimum orgs - removed direct imports from namespaces packages (optimum.exporters, optimum.commands, etc) for compatibility with native namespace packages (see huggingface/optimum#2361). Didn't remove support for loading and inference with legacy models entirely as it would break many tests that still use them.
1 parent fafa2a7 commit 96ea89b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+257
-732
lines changed

.github/workflows/test_exporters_common.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ env:
1414
UV_SYSTEM_PYTHON: true
1515
UV_TORCH_BACKEND: auto
1616
TRANSFORMERS_IS_CI: true
17-
HF_HUB_READ_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }}
17+
HF_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }}
1818

1919
jobs:
2020
build:

.github/workflows/test_exporters_onnx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ env:
1414
UV_SYSTEM_PYTHON: true
1515
UV_TORCH_BACKEND: auto
1616
TRANSFORMERS_IS_CI: true
17-
HF_HUB_READ_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }}
17+
HF_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }}
1818

1919
jobs:
2020
build:

.github/workflows/test_exporters_onnx_cli.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ env:
1414
UV_SYSTEM_PYTHON: true
1515
UV_TORCH_BACKEND: auto
1616
TRANSFORMERS_IS_CI: true
17-
HF_HUB_READ_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }}
17+
HF_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }}
1818

1919
jobs:
2020
build:

.github/workflows/test_onnxruntime.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ env:
1515
UV_SYSTEM_PYTHON: true
1616
UV_TORCH_BACKEND: auto
1717
TRANSFORMERS_IS_CI: true
18-
HF_HUB_READ_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }}
18+
HF_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }}
1919

2020
jobs:
2121
build:

.github/workflows/test_onnxruntime_slow.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ concurrency:
1818
cancel-in-progress: true
1919

2020
env:
21+
RUN_SLOW: true
2122
TRANSFORMERS_IS_CI: true
23+
HF_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }}
2224

2325
jobs:
2426
build:
@@ -69,6 +71,3 @@ jobs:
6971
- name: Test with pytest
7072
run: |
7173
pytest tests/onnxruntime --durations=0 -vvvv
72-
env:
73-
HF_HUB_READ_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }}
74-
RUN_SLOW: 1

docs/source/onnx/usage_guides/contribute.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ This function expects the ONNX configuration, along with the base model, and the
175175

176176
```python
177177
>>> from pathlib import Path
178-
>>> from optimum.exporters import TasksManager
178+
>>> from optimum.exporters.tasks import TasksManager
179179
>>> from optimum.exporters.onnx import export
180180
>>> from transformers import AutoModel
181181

docs/source/onnx/usage_guides/export_a_model.mdx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -391,18 +391,9 @@ class CustomMPTOnnxConfig(TextDecoderOnnxConfig):
391391

392392
model_id = "fxmarty/tiny-mpt-random-remote-code"
393393
config = AutoConfig.from_pretrained(model_id, trust_remote_code=True)
394-
395-
onnx_config = CustomMPTOnnxConfig(
396-
config=config,
397-
task="text-generation",
398-
use_past_in_inputs=False,
399-
)
400394
onnx_config_with_past = CustomMPTOnnxConfig(config, task="text-generation", use_past=True)
401395

402-
custom_onnx_configs = {
403-
"decoder_model": onnx_config,
404-
"decoder_with_past_model": onnx_config_with_past,
405-
}
396+
custom_onnx_configs = {"model": onnx_config_with_past}
406397

407398
main_export(
408399
model_id,
@@ -411,7 +402,6 @@ main_export(
411402
trust_remote_code=True,
412403
custom_onnx_configs=custom_onnx_configs,
413404
no_post_process=True,
414-
legacy=True,
415405
opset=14
416406
)
417407
```

examples/onnxruntime/optimization/multiple-choice/run_swag.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,6 @@ class OptimizationArguments:
134134
"99 will enable all available optimizations including layout optimizations."
135135
},
136136
)
137-
optimize_with_onnxruntime_only: bool = field(
138-
default=False,
139-
metadata={
140-
"help": "Whether to only use ONNX Runtime to optimize the model and no graph fusion in Python."
141-
"Graph fusion might require offline, Python scripts, to be run."
142-
},
143-
)
144137
optimize_for_gpu: bool = field(
145138
default=False,
146139
metadata={
@@ -232,7 +225,6 @@ def main():
232225
# Create the optimization configuration containing all the optimization parameters
233226
optimization_config = OptimizationConfig(
234227
optimization_level=optim_args.optimization_level,
235-
optimize_with_onnxruntime_only=optim_args.optimize_with_onnxruntime_only,
236228
optimize_for_gpu=optim_args.optimize_for_gpu,
237229
)
238230

examples/onnxruntime/optimization/question-answering/run_qa.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,7 @@ class OptimizationArguments:
202202
"99 will enable all available optimizations including layout optimizations."
203203
},
204204
)
205-
optimize_with_onnxruntime_only: bool = field(
206-
default=False,
207-
metadata={
208-
"help": "Whether to only use ONNX Runtime to optimize the model and no graph fusion in Python."
209-
"Graph fusion might require offline, Python scripts, to be run."
210-
},
211-
)
205+
212206
optimize_for_gpu: bool = field(
213207
default=False,
214208
metadata={
@@ -301,7 +295,6 @@ def main():
301295
# Create the optimization configuration containing all the optimization parameters
302296
optimization_config = OptimizationConfig(
303297
optimization_level=optim_args.optimization_level,
304-
optimize_with_onnxruntime_only=optim_args.optimize_with_onnxruntime_only,
305298
optimize_for_gpu=optim_args.optimize_for_gpu,
306299
)
307300

examples/onnxruntime/optimization/text-classification/run_glue.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,6 @@ class OptimizationArguments:
150150
"99 will enable all available optimizations including layout optimizations."
151151
},
152152
)
153-
optimize_with_onnxruntime_only: bool = field(
154-
default=False,
155-
metadata={
156-
"help": "Whether to only use ONNX Runtime to optimize the model and no graph fusion in Python."
157-
"Graph fusion might require offline, Python scripts, to be run."
158-
},
159-
)
160153
optimize_for_gpu: bool = field(
161154
default=False,
162155
metadata={
@@ -249,7 +242,6 @@ def main():
249242
# Create the optimization configuration containing all the optimization parameters
250243
optimization_config = OptimizationConfig(
251244
optimization_level=optim_args.optimization_level,
252-
optimize_with_onnxruntime_only=optim_args.optimize_with_onnxruntime_only,
253245
optimize_for_gpu=optim_args.optimize_for_gpu,
254246
)
255247

0 commit comments

Comments
 (0)