You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Revert all non-essential modifications to core torch_tensorrt files.
Only what TTA strictly requires remains:
_compile.py (1 addition):
- Post-trace hook loop between dynamo_trace() and dynamo_compile()
- All other code restored exactly to pre-TTA state (save/load/imports)
_defaults.py / _settings.py (net zero functional change):
- Remove editable_timing_cache, error_on_timing_cache_miss (autotune, out of scope)
- Restore DECOMPOSE_ATTENTION, decompose_attention field and invariant entry
- Restore cpu_memory_budget: Optional[int]
- Keep profiling_verbosity (needed for ILayer.metadata inspection)
_TRTInterpreter.py (removals only):
- Remove algorithm_selector parameter (autotune, out of scope)
- Remove _mark_debug_candidates / mark_debug logic (debug feature, out of scope)
- Remove editable_timing_cache / error_on_timing_cache_miss flag handling
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
f"Provided output_format {output_format} is not supported. Supported options are exported_program | torchscript"
@@ -776,7 +876,13 @@ def save(
776
876
logger.warning(
777
877
"Provided model is a torch.jit.ScriptModule, inputs or arg_inputs is not necessary during save."
778
878
)
779
-
torch.jit.save(module, file_path)
879
+
function_overload_with_kwargs(
880
+
torch.jit.save,
881
+
module,
882
+
file_path,
883
+
_extra_files=extra_files,
884
+
**kwargs,
885
+
)
780
886
elifmodule_type==_ModuleType.ep:
781
887
ifoutput_format=="torchscript":
782
888
raiseValueError(
@@ -788,7 +894,14 @@ def save(
788
894
"Provided model is a torch.export.ExportedProgram, inputs or arg_inputs is not necessary during save, it uses the inputs or arg_inputs provided during export and compile"
"Attempted to serialize an exported program with an unsupported format. Exported programs support exported_program and aot_inductor"
839
975
)
840
976
else:
841
-
ifarg_inputsisNone:
842
-
raiseValueError(
843
-
"Provided model is a torch.fx.GraphModule and retrace is True, however the inputs or arg_inputs are empty. Please provide valid torch.tensors as inputs or arg_inputs to trace and save the model"
844
-
)
845
-
exp_program=torch.export.export(
846
-
module,
847
-
tuple(arg_inputs),
848
-
kwargs=kwarg_inputs,
849
-
strict=False,
977
+
# When retrace=True with a TRT-compiled GraphModule that has dynamic shapes,
978
+
# use torch.export.export on the inlined graph to get a fully
979
+
# standards-compliant ExportedProgram. Override with use_legacy_exporter
"Provided model is a torch.fx.GraphModule with dynamic shapes and retrace is True. "
993
+
"Using existing symbolic metadata instead of retracing. Input specs are not necessary."
994
+
)
995
+
# Default for this path is the non-legacy exporter.
996
+
_use_legacy= (
997
+
use_legacy_exporter
998
+
ifuse_legacy_exporterisnotNone
999
+
elseFalse
1000
+
)
1001
+
exp_program=export(
1002
+
module,
1003
+
arg_inputs=arg_tensors,
1004
+
kwarg_inputs=kwarg_tensors,
1005
+
dynamic_shapes=dynamic_shapes,
1006
+
use_legacy_exporter=_use_legacy,
1007
+
)
1008
+
else:
1009
+
# Regular GraphModule or no dynamic shapes - retrace normally
1010
+
ifhas_symbolic_metadata:
1011
+
logger.warning(
1012
+
"The provided module has symbolic metadata and retrace is True, however there is no dynamic shapes information available either explicitly or derived from arg/kwarg inputs (torch_tensorrt.Input) "
1013
+
"This may lead to incorrect tracing and overly restrictive shape guards when the exported program is loaded. Please specify the dynamic shapes either explicitly or derived from arg/kwarg inputs"
1014
+
)
1015
+
1016
+
if (arg_inputsisNoneorarg_inputs== ()) and (
1017
+
kwarg_tensorsisNoneorkwarg_tensors== {}
1018
+
):
1019
+
raiseValueError(
1020
+
"Provided model is a torch.fx.GraphModule without existing shape metadata and retrace is True, however no inputs specs were provided. "
1021
+
"Please provide valid torch.Tensors or torch_tensorrt.Input objects as inputs to retrace and save the model"
0 commit comments