Skip to content

Conversation

@oivie
Copy link

@oivie oivie commented Aug 13, 2025

Description

Created multiple unconventional neural network models to stress-test the JSTProve system and identify integration limitations. The models successfully test different failure modes in the PyTorch → ONNX → JSTProve pipeline, discovering actual system limitations including unsupported operations (Tanh/Sigmoid) and ONNX export edge cases.

Added three ONNX models with varying levels of architectural weirdness:

  • model_redundant.onnx: Simple model with redundant ReLU layers (baseline)
  • model_wrong_dimension.onnx: Mixes 1D/2D operations, uses unsupported activations
  • model_supported_weird.onnx: Architecturally chaotic but uses only supported operations

Related Issue

  • Testing framework validation for edge cases and unusual model architectures
  • Integration testing between PyTorch, ONNX, and JSTProve systems

Key Findings

  • JSTProve Operation Limitations Discovered: Unsupported op type: {'Tanh', 'Sigmoid'}
  • ONNX Export Limitations Confirmed
  • Models using AdaptiveAvgPool2d with incompatible dimensions fail ONNX export as expected.

Integration Framework Validation

  • All models successfully integrate with pytest framework
  • Test discovery and execution pipeline functions correctly
  • Proper error handling and reporting for different failure modes

Note:
Expected behavior: model_redundant and model_supported_weird should pass, model_wrong_dimension will fail at JSTProve compilation due to unsupported operations

Elena Pashkova added 2 commits July 24, 2025 17:26
- Add model_redundant.onnx: Simple model with redundant layers
- Add model_wrong_dimension.onnx: Model mixing 1D/2D operations
- Add model_supported_weird.onnx: Architecturally weird but uses only supported ops
- Add generation scripts for reproducing models
- Add test file for model_redundant

Models test different failure modes:
- ONNX export limitations
- JSTProve operation support gaps (Tanh/Sigmoid unsupported)
- Integration framework edge cases
Copy link
Member

@HudsonGraeme HudsonGraeme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks 🔥!!
Left some small comments mostly about paths and newlines 😄

import os

# Add the models directory to Python path
sys.path.append('/Users/elenapashkova/GravyTesting-Internal/python/models/models_onnx')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preference to use a relative abs path when possible; this will allow anyone who pulls the repo to easily run the scripts without needing to meddle with the path :)

Suggested change
sys.path.append('/Users/elenapashkova/GravyTesting-Internal/python/models/models_onnx')
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'models', 'models_onnx')))

except Exception as e:
print(f"❌ Error: {e}")
import traceback
traceback.print_exc() No newline at end of file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you open this file in the files tab you may note this do not enter sign; it indicates the file isn't POSIX compliant due to the lack of newline at the end. This is not really a big deal since we're no longer in the 19th century but still preferable to include a newline at the end if possible :)

Image

input_tensor = torch.randn(1, 1, 28, 28)
input_numpy = input_tensor.numpy()

session = ort.InferenceSession("/Users/elenapashkova/GravyTesting-Internal/python/models/models_onnx/model_conv2d.onnx")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
session = ort.InferenceSession("/Users/elenapashkova/GravyTesting-Internal/python/models/models_onnx/model_conv2d.onnx")
session = ort.InferenceSession(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'models', 'models_onnx', 'model_conv2d.onnx')))

import sys

# Add the models directory to Python path
sys.path.append('/Users/elenapashkova/GravyTesting-Internal/python/models/models_onnx')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sys.path.append('/Users/elenapashkova/GravyTesting-Internal/python/models/models_onnx')
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'models', 'models_onnx'))

import sys

# Add the models directory to Python path
sys.path.append('/Users/elenapashkova/GravyTesting-Internal/python/models/models_onnx')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sys.path.append('/Users/elenapashkova/GravyTesting-Internal/python/models/models_onnx')
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'models', 'models_onnx'))

output_data = output.detach().numpy().tolist()

print("Creating output directory...")
io_dir = "python/testing/core/input_output_data/model_wrong_dimension/"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
io_dir = "python/testing/core/input_output_data/model_wrong_dimension/"
io_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'testing', 'core', 'input_output_data', 'model_wrong_dimension')


def test_conv2d_model_output():
# Paths - using relative paths since files are in the same directory as the test
onnx_model_path = "python/models/models_onnx/model_conv2d.onnx"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
onnx_model_path = "python/models/models_onnx/model_conv2d.onnx"
onnx_model_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'models', 'models_onnx', 'model_conv2d.onnx')

import sys

# Add the models directory to Python path
sys.path.append('/Users/elenapashkova/GravyTesting-Internal/python/models/models_onnx')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sys.path.append('/Users/elenapashkova/GravyTesting-Internal/python/models/models_onnx')
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'models', 'models_onnx')))


try:
print("Importing RedundantModel...")
from redundant_layers_model import RedundantModel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm this one might be left out of the commit too or potentially I missed it somehow again too


print("Creating output directory...")
# Save input/output
io_dir = "python/testing/core/input_output_data/model_redundant/"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
io_dir = "python/testing/core/input_output_data/model_redundant/"
io_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'testing', 'core', 'input_output_data', 'model_redundant')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants