Skip to content

Panic trying to input ONNX Model for ModernBERT #3130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
hjarrell opened this issue May 1, 2025 · 2 comments
Open

Panic trying to input ONNX Model for ModernBERT #3130

hjarrell opened this issue May 1, 2025 · 2 comments
Assignees
Labels
bug Something isn't working onnx

Comments

@hjarrell
Copy link

hjarrell commented May 1, 2025

Describe the bug
Hello, I was trying to import https://huggingface.co/answerdotai/ModernBERT-base ONNX model and it panicked trying to parse Shape_4.

I am not an ML expert by any means but tried to do some basic troubleshooting:

  • I did try to open it in netron and shape_4 input appears to be a tensor: float32[batch_size,1,sequence_length,sequence_length]
  • I checked the onnx-ir crate and saw something about updating the model version so tried that with the python library and same issue
  • Found Mismatched types when importing ONNX models #2806 which also had an issue importing the same model but its a different issue
  DEBUG onnx_ir::proto_conversion: Converting ONNX node with type "Shape"    
  DEBUG onnx_ir::from_onnx: renaming node "/model/Shape_4"    
  ERROR burn_import::logger: PANIC => panicked at /[...]/onnx-ir-0.17.0/src/util.rs:14:14:
  Only tensor input is valid    

  --- stderr

  thread 'main' panicked at /[...]/onnx-ir-0.17.0/src/util.rs:14:14:

To Reproduce

  1. Download model.onnx from https://huggingface.co/answerdotai/ModernBERT-base/tree/main/onnx
  2. Run:
use burn_import::onnx::ModelGen;

fn main() {
    ModelGen::new()
        .input("src/model/model.onnx")
        .out_dir("model/")
        .run_from_script();
}
  1. Panic

Expected behavior
An output of rust code for the model.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: macOS 15.5
  • Browser N/A
@laggui laggui added bug Something isn't working onnx labels May 1, 2025
@laggui
Copy link
Member

laggui commented May 1, 2025

Thanks for flagging the issue! The ONNX import module is going through some changes to improve it.

A quick glance at the error tells me this might be a scalar input issue. But given that the input to the node is a tensor with shape [batch_size,1,sequence_length,sequence_length], it's probably an incorrect conversion when parsing one of the preceding graph nodes.

@antimora
Copy link
Collaborator

antimora commented May 2, 2025

I'll investigate after the big refactoring PRs are merged.

@antimora antimora self-assigned this May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working onnx
Projects
None yet
Development

No branches or pull requests

3 participants