Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sparseml/pytorch/utils/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ def export_onnx(
https://pytorch.org/docs/stable/onnx.html
"""
if _PARSED_TORCH_VERSION >= version.parse("1.10.0") and opset < 13 and convert_qat:
warnings.warn(
raise ValueError(
"Exporting onnx with QAT and opset < 13 may result in errors. "
"Please use opset>=13 with QAT. "
"See https://github.com/pytorch/pytorch/issues/77455 for more info. "
Expand Down
12 changes: 10 additions & 2 deletions src/sparseml/transformers/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,16 @@ def export_transformer_to_onnx(
recipe_args=None,
teacher=None,
)

applied = trainer.apply_manager(epoch=math.inf, checkpoint=None)
try:
applied = trainer.apply_manager(epoch=math.inf, checkpoint=None)
except ValueError as e:
raise ValueError(
f"Failed to apply the recipe to the "
f"model with the exception message:\n{e}\n"
"It is possible, that there are missing modules "
"specific to the model, that were not properly loaded. "
"A possible solution would be setting the --trust_remote_code flag"
)

if not applied:
_LOGGER.warning(
Expand Down