Skip to content

check_model in _framework_apis is a no-op — torch.onnx.export(verify=True) reports success without validating anything #2981

Description

@gabrielfruet

check_model in onnxscript/_framework_apis/torch_2_5.py is:

def check_model(model: ir.Model) -> None:
    """Check the model."""

    del model  # Unused yet

torch_2_6.py through torch_2_11.py all re-export this same function unchanged (confirmed on current main).

torch.onnx.export(..., dynamo=True, verify=True) calls this via onnxscript_apis.check_model(onnx_program.model) in torch/onnx/_internal/exporter/_core.py, prints "Check the ONNX model... ✅", and sets export_status.onnx_checker = True — regardless of whether the model is actually valid. A model that would fail onnx.checker.check_model(..., full_check=True) still gets reported as checked and passing.

Repro:

import torch

class M(torch.nn.Module):
    def forward(self, x):
        return x + 1

torch.onnx.export(M(), (torch.randn(2, 2),), "m.onnx", dynamo=True, verify=True)
# Prints "Check the ONNX model... ✅" no matter what — the check never runs.

Is real validation (e.g. wiring in onnx.checker.check_model) planned, or should the verify=True reporting reflect that this step is currently a stub?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions