Skip to content

Exporting Models: torch_dtype is deprecated #2438

Description

@tschoellhorn

System Info

Running in an python virtual environment / Ubuntu 22.04 LTS:

---
The current version are (pip freeze):


certifi==2026.5.20
charset-normalizer==3.4.7
coloredlogs==15.0.1
cuda-bindings==13.2.0
cuda-pathfinder==1.5.4
cuda-toolkit==13.0.2
filelock==3.29.0
flatbuffers==25.12.19
fsspec==2026.4.0
hf-xet==1.5.0
huggingface_hub==0.36.2
humanfriendly==10.0
idna==3.15
Jinja2==3.1.6
joblib==1.5.3
MarkupSafe==3.0.3
ml_dtypes==0.5.4
mpmath==1.3.0
networkx==3.4.2
numpy==2.2.6
nvidia-cublas==13.1.1.3
nvidia-cuda-cupti==13.0.85
nvidia-cuda-nvrtc==13.0.88
nvidia-cuda-runtime==13.0.96
nvidia-cudnn-cu13==9.20.0.48
nvidia-cufft==12.0.0.61
nvidia-cufile==1.15.1.6
nvidia-curand==10.4.0.35
nvidia-cusolver==12.0.4.66
nvidia-cusparse==12.6.3.3
nvidia-cusparselt-cu13==0.8.1
nvidia-nccl-cu13==2.29.7
nvidia-nvjitlink==13.0.88
nvidia-nvshmem-cu13==3.4.5
nvidia-nvtx==13.0.85
onnx==1.21.0
onnxruntime==1.23.2
optimum==2.1.0
optimum-onnx==0.1.0
packaging==26.2
protobuf==7.35.0
PyYAML==6.0.3
regex==2026.5.9
requests==2.34.2
safetensors==0.7.0
scikit-learn==1.7.2
scipy==1.15.3
sentence-transformers==5.5.1
sympy==1.14.0
threadpoolctl==3.6.0
tokenizers==0.22.2
torch==2.12.0
tqdm==4.67.3
transformers==4.57.6
triton==3.7.0
typing_extensions==4.15.0
urllib3==2.7.0

Who can help?

I want to transform a model to onnx-format. The following code worked so far - but is not working with the current versions. Previously - with older versions this worked:

@echarlaix @IlyasMoutawwakil

Any ideas?

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction (minimal, reproducible, runnable)

python -m pip install --upgrade pip

pip install optimum[onnxruntime] sentence-transformers
#pip install "optimum-onnx[onnxruntime]"

echo "Exporting ONNX-Models..."
mkdir -p /vagrant/embedding-models/sentence-transformers
optimum-cli export onnx \
	--model sentence-transformers/paraphrase-MiniLM-L12-v2 \
	/targetdir/paraphrase-MiniLM-L12-v2

The command aborts with the follwing stacktrace:

`torch_dtype` is deprecated! Use `dtype` instead!
Traceback (most recent call last):
  File "/opt/build-embedding-models/venv/bin/optimum-cli", line 6, in <module>
    sys.exit(main())
  File "/opt/build-embedding-models/venv/lib/python3.10/site-packages/optimum/commands/optimum_cli.py", line 219, in main
    service.run()
  File "/opt/build-embedding-models/venv/lib/python3.10/site-packages/optimum/commands/export/onnx.py", line 264, in run
    main_export(
  File "/opt/build-embedding-models/venv/lib/python3.10/site-packages/optimum/exporters/onnx/__main__.py", line 325, in main_export
    model = TasksManager.get_model_from_task(
  File "/opt/build-embedding-models/venv/lib/python3.10/site-packages/optimum/exporters/tasks.py", line 1222, in get_model_from_task
    TasksManager.standardize_model_attributes(model, library_name=library_name)
  File "/opt/build-embedding-models/venv/lib/python3.10/site-packages/optimum/exporters/tasks.py", line 1043, in standardize_model_attributes
    model.config = model[0].auto_model.config
  File "/opt/build-embedding-models/venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 2074, in __setattr__
    super().__setattr__(name, value)
AttributeError: can't set attribute 'config'

Any ideas? Suggestions?

Expected behavior

The result of the transformed model should be written to the file system.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions