Closed puppetpyt closed 1 month ago
cc @IlyasMoutawwakil
the change I had to do in optimum
https://github.com/huggingface/optimum/pull/1971 is to use the eager attention since you can't foward attn_implementation="eager"
in a diffusion pipeline to the clip model https://github.com/huggingface/diffusers/issues/8957. I still haven't investigated why sdpa can't be exported in this case.
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.
Please note that issues that do not follow the contributing guidelines are likely to be ignored.
System Info
python3.9
Who can help?
No response
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
When I use version 4.42.4 transformers, I can still export.Do I need to make any changes to adapt to version 4.43? export_onnx.py
Traceback (most recent call last): File "/home/export_onnx.py", line 59, in
export_text_encoder()
File "/home/export_onnx.py", line 49, in export_text_encoder
torch.onnx.export(model, (input),
File "/usr/local/lib64/python3.9/site-packages/torch/onnx/utils.py", line 516, in export
_export(
File "/usr/local/lib64/python3.9/site-packages/torch/onnx/utils.py", line 1596, in _export
graph, params_dict, torch_out = _model_to_graph(
File "/usr/local/lib64/python3.9/site-packages/torch/onnx/utils.py", line 1139, in _model_to_graph
graph = _optimize_graph(
File "/usr/local/lib64/python3.9/site-packages/torch/onnx/utils.py", line 677, in _optimize_graph
graph = _C._jit_pass_onnx(graph, operator_export_type)
File "/usr/local/lib64/python3.9/site-packages/torch/onnx/utils.py", line 1940, in _run_symbolic_function
return symbolic_fn(graph_context, *inputs, attrs)
File "/usr/local/lib64/python3.9/site-packages/torch/onnx/symbolic_helper.py", line 306, in wrapper
return fn(g, *args, *kwargs)
File "/usr/local/lib64/python3.9/site-packages/torch/onnx/symbolic_opset14.py", line 176, in scaled_dot_product_attention
query_scaled = g.op("Mul", query, g.op("Sqrt", scale))
File "/usr/local/lib64/python3.9/site-packages/torch/onnx/_internal/jit_utils.py", line 87, in op
return _add_op(self, opname, raw_args, outputs=outputs, kwargs)
File "/usr/local/lib64/python3.9/site-packages/torch/onnx/_internal/jit_utils.py", line 238, in _add_op
inputs = [_const_if_tensor(graph_context, arg) for arg in args]
File "/usr/local/lib64/python3.9/site-packages/torch/onnx/_internal/jit_utils.py", line 238, in
inputs = [_const_if_tensor(graph_context, arg) for arg in args]
File "/usr/local/lib64/python3.9/site-packages/torch/onnx/_internal/jit_utils.py", line 269, in _const_if_tensor
return _add_op(graph_context, "onnx::Constant", value_z=arg)
File "/usr/local/lib64/python3.9/site-packages/torch/onnx/_internal/jit_utils.py", line 246, in _add_op
node = _create_node(
File "/usr/local/lib64/python3.9/site-packages/torch/onnx/_internal/jit_utils.py", line 305, in _create_node
_add_attribute(node, key, value, aten=aten)
File "/usr/local/lib64/python3.9/site-packages/torch/onnx/_internal/jit_utils.py", line 356, in _addattribute
return getattr(node, f"{kind}")(name, value)
TypeError: z_(): incompatible function arguments. The following argument types are supported:
Invoked with: %354 : Tensor = onnx::Constant(), scope: main.text_encoder::/transformers.models.clip.modeling_clip.CLIPTextModel::encoder/transformers.models.clip.modeling_clip.CLIPTextTransformer::text_model/transformers.models.clip.modeling_clip.CLIPEncoder::encoder/transformers.models.clip.modeling_clip.CLIPEncoderLayer::layers.0/transformers.models.clip.modeling_clip.CLIPSdpaAttention::self_attn , 'value', 0.125 (Occurred when translating scaled_dot_product_attention).
Expected behavior
Successfully exported onnx