Skip to content

Commit 53f39a6

Browse files
Transformers 4.53 support, SmolLM3 and Fix old Transformers support (#2319)
* test * fix seq2seq patched sdpa * patch qwen3_moe, out_attentions, and eager_mask * fix * use optimum model * editable subpackages * Apply suggestions from code review * smollm3 support * deprecate tensorflow onnx export and add smollm3 to export tests * write a more general sdpa_mask without vmap that's also vectorized and broadcastable * better and more generic sdpa_mask_without_vmap implementation * style and fix * fix * patch find_packed_sequence_indices as it's untraceable * fix * fix * revert tests removal until refactor * fix temporary hub repo import * fix * fix external data tests on windows * update phi and phi3 min version * condition modernbert optimization test * get back old (pre 4.44) bloom modeling support and remove the need for normalized config in ort modeling * fix test was using hardcoded architecture * unparallelize test that uses remote code * support older versions of mpt and phi (4.36) * remove parallelism from slow tests * fix vision to text pipelines test * more specific version handling for find_packed_sequence_indices * fix
1 parent 9564248 commit 53f39a6

28 files changed

Lines changed: 414 additions & 190 deletions

.github/workflows/test_exporters_onnx.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ jobs:
4040
4141
- name: Test with pytest
4242
run: |
43-
pytest tests/exporters/onnx/test_export.py -vvvv --durations=0 -n auto
43+
pytest tests/exporters/onnx/test_export.py -vvvv --durations=0

.github/workflows/test_exporters_tflite.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
branches: [main]
77
pull_request:
88
branches: [main]
9-
types: [opened, synchronize, reopened, labeled, unlabeled]
109

1110
concurrency:
1211
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}

.github/workflows/test_exporters_tflite_cli.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
branches: [main]
77
pull_request:
88
branches: [main]
9-
types: [opened, synchronize, reopened, labeled, unlabeled]
109

1110
concurrency:
1211
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}

.github/workflows/test_onnxruntime_slow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787

8888
- name: Test with pytest (in parallel)
8989
run: |
90-
pytest tests/onnxruntime -m "not run_in_series" --durations=0 -vvvv -n auto
90+
pytest tests/onnxruntime -m "not run_in_series" --durations=0 -vvvv
9191
env:
9292
HF_HUB_READ_TOKEN: ${{ secrets.HF_HUB_READ_TOKEN }}
9393
RUN_SLOW: 1

optimum/commands/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
1415

1516
from .base import BaseOptimumCLICommand, CommandInfo, RootOptimumCLICommand
1617
from .env import EnvironmentCommand

optimum/commands/export/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
14+
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
1515

1616
from .base import ExportCommand
1717
from .onnx import ONNXExportCommand

optimum/exporters/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15-
from . import onnx # noqa
15+
__path__ = __import__("pkgutil").extend_path(__path__, __name__)
16+
1617
from .tasks import TasksManager # noqa
18+
from .base import ExporterConfig # noqa

optimum/exporters/base.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@
6969

7070

7171
class ExportConfig(ABC):
72-
pass
72+
def __init_subclass__(cls, **kwargs):
73+
super().__init_subclass__(**kwargs)
74+
logger.warning(
75+
"The `ExportConfig` class is deprecated and will be removed in a future version. "
76+
"Please use `ExporterConfig` instead."
77+
)
7378

7479

7580
class ExporterConfig(ABC):

optimum/exporters/onnx/__main__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,10 @@ def main_export(
340340
if model_type in SDPA_ARCHS_ONNX_EXPORT_NOT_SUPPORTED and is_transformers_version("<", "4.42"):
341341
loading_kwargs["attn_implementation"] = "eager"
342342

343+
# Only eager attention implementation returns attentions
344+
if model_kwargs is not None and model_kwargs.get("output_attentions", False):
345+
loading_kwargs["attn_implementation"] = "eager"
346+
343347
with DisableCompileContextManager():
344348
model = TasksManager.get_model_from_task(
345349
task,

optimum/exporters/onnx/convert.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,11 @@ def export_tensorflow(
642642
`Tuple[List[str], List[str]]`: A tuple with an ordered list of the model's inputs, and the named outputs from
643643
the ONNX configuration.
644644
"""
645+
646+
logger.warning(
647+
"The TensorFlow ONNX export is deprecated and will be removed in the next major release of Optimum."
648+
)
649+
645650
# This is needed to import onnx and tf2onnx because onnx is also the name of the current directory.
646651
import sys
647652

0 commit comments

Comments
 (0)