From 2737ec479421fb6f758bf1445afc049150c613fa Mon Sep 17 00:00:00 2001 From: dbogunowicz <97082108+dbogunowicz@users.noreply.github.com> Date: Wed, 22 Nov 2023 16:14:50 +0100 Subject: [PATCH 1/2] "AttributeError: 'torch._C.Value' object has no attribute 'float'" sparseml.transformers.export_onnx for zoo:bert-base_cased-squad_wikipedia_bookcorpus-pruned80.4block_quantized (#1847) --- src/sparseml/pytorch/utils/exporter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sparseml/pytorch/utils/exporter.py b/src/sparseml/pytorch/utils/exporter.py index 4d7e44b51ac..d54875a98ea 100644 --- a/src/sparseml/pytorch/utils/exporter.py +++ b/src/sparseml/pytorch/utils/exporter.py @@ -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. " From da6a258405ac40ce8a85988b5a459ed50e2d8383 Mon Sep 17 00:00:00 2001 From: dbogunowicz <97082108+dbogunowicz@users.noreply.github.com> Date: Wed, 22 Nov 2023 16:20:12 +0100 Subject: [PATCH 2/2] [Fix]"ValueError: scheme_overrides contains submodule names or module types that do not match to any submodules in the model" when using mpt model in sparseml.transformers.export_onnx (#1846) * initial commit * Update src/sparseml/transformers/export.py --- src/sparseml/transformers/export.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/sparseml/transformers/export.py b/src/sparseml/transformers/export.py index 02a8bb69c61..0ef3f82c7d8 100644 --- a/src/sparseml/transformers/export.py +++ b/src/sparseml/transformers/export.py @@ -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(