diff --git a/optimum/exporters/onnx/config.py b/optimum/exporters/onnx/config.py index 17daad5b6bf..563a6452290 100644 --- a/optimum/exporters/onnx/config.py +++ b/optimum/exporters/onnx/config.py @@ -125,32 +125,32 @@ def post_process_exported_models( path, models_and_onnx_configs, onnx_files_subpaths ) - # Attempt to merge only if the decoder-only was exported separately without/with past - if self.use_past is True and len(models_and_onnx_configs) == 2: - decoder_path = Path(path, onnx_files_subpaths[0]) - decoder_with_past_path = Path(path, onnx_files_subpaths[1]) - decoder_merged_path = Path(path, ONNX_DECODER_MERGED_NAME + ".onnx") - try: - merge_decoders( - decoder=decoder_path, - decoder_with_past=decoder_with_past_path, - save_path=decoder_merged_path, - ) - except Exception as e: - raise Exception(f"Unable to merge decoders. Detailed error: {e}") - - # In order to do the validation of the two branches on the same file - onnx_files_subpaths = [decoder_merged_path.name, decoder_merged_path.name] - - # We validate the two branches of the decoder model then - models_and_onnx_configs[ONNX_DECODER_NAME][1].is_merged = True - models_and_onnx_configs[ONNX_DECODER_NAME][1].use_cache_branch = False - - # Past key values won't be generated by default, but added in the input - models_and_onnx_configs[ONNX_DECODER_NAME][1].use_past_in_inputs = True - - models_and_onnx_configs[ONNX_DECODER_WITH_PAST_NAME][1].use_cache_branch = True - models_and_onnx_configs[ONNX_DECODER_WITH_PAST_NAME][1].is_merged = True + # # Attempt to merge only if the decoder-only was exported separately without/with past + # if self.use_past is True and len(models_and_onnx_configs) == 2: + # decoder_path = Path(path, onnx_files_subpaths[0]) + # decoder_with_past_path = Path(path, onnx_files_subpaths[1]) + # decoder_merged_path = Path(path, ONNX_DECODER_MERGED_NAME + ".onnx") + # try: + # merge_decoders( + # decoder=decoder_path, + # decoder_with_past=decoder_with_past_path, + # save_path=decoder_merged_path, + # ) + # except Exception as e: + # raise Exception(f"Unable to merge decoders. Detailed error: {e}") + + # # In order to do the validation of the two branches on the same file + # onnx_files_subpaths = [decoder_merged_path.name, decoder_merged_path.name] + + # # We validate the two branches of the decoder model then + # models_and_onnx_configs[ONNX_DECODER_NAME][1].is_merged = True + # models_and_onnx_configs[ONNX_DECODER_NAME][1].use_cache_branch = False + + # # Past key values won't be generated by default, but added in the input + # models_and_onnx_configs[ONNX_DECODER_NAME][1].use_past_in_inputs = True + + # models_and_onnx_configs[ONNX_DECODER_WITH_PAST_NAME][1].use_cache_branch = True + # models_and_onnx_configs[ONNX_DECODER_WITH_PAST_NAME][1].is_merged = True return models_and_onnx_configs, onnx_files_subpaths