Skip to content

onnx_graphsurgeon incompatible with ONNX 1.20.0 #4635

Closed

Description

@Y-T-G

onnx.helper dtypes have been deprecated in ONNX 1.20.0. So onnx_graphsurgeon import fails

import onnx_graphsurgeon
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[1], line 1
----> 1 import onnx_graphsurgeon

File /opt/conda/lib/python3.11/site-packages/onnx_graphsurgeon/__init__.py:1
----> 1 from onnx_graphsurgeon.exporters.onnx_exporter import export_onnx
      2 from onnx_graphsurgeon.graph_pattern import GraphPattern, PatternMapping
      3 from onnx_graphsurgeon.importers.onnx_importer import import_onnx

File /opt/conda/lib/python3.11/site-packages/onnx_graphsurgeon/exporters/onnx_exporter.py:134
    128     def __call__(self, arr):
    129         return self.func(arr)
    132 _NUMPY_ARRAY_CONVERTERS = {
    133     onnx.TensorProto.BFLOAT16: NumpyArrayConverter(
--> 134         np.uint16, onnx.helper.float32_to_bfloat16
    135     ),
    136     # FP8 in TensorRT supports negative zeros, no infinities
    137     # See https://onnx.ai/onnx/technical/float8.html#papers
    138     onnx.TensorProto.FLOAT8E4M3FN: NumpyArrayConverter(
    139         np.uint8, lambda x: onnx.helper.float32_to_float8e4m3(x, fn=True, uz=False)
    140     ),
    141 }
    144 # Converts a gs.Constant to an onnx tensor and convert the values according to gs.Constant.export_dtype
    145 def constant_to_onnx_tensor(tensor: Constant) -> onnx.TensorProto:

AttributeError: module 'onnx.helper' has no attribute 'float32_to_bfloat16'

https://github.com/onnx/onnx/blob/8827114d2c90c924ab05b68ac1093b0a6adf9324/onnx/helper.py#L359

Reproduce

  1. pip install --pre -U onnx
  2. import onnx_graphsurgeon

Activity

  1. added
    Module:ONNX
    Module:GraphSurgeon
    on Nov 8, 2025
  2. hdnhan commented on Dec 2, 2025

    @hdnhan

    onnx=1.19.1 seems working.

  3. added a commit that references this issue on Dec 11, 2025
  4. added a commit that references this issue on Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Module:GraphSurgeonModule:ONNX

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions