Skip to content
Open
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
5 changes: 5 additions & 0 deletions py/torch_tensorrt/dynamo/_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,9 @@ def compile_module(
num_supported_ops, total_ops = partitioning.get_graph_converter_support(
gm, settings.torch_executed_ops
)
skip_conversion_validation = (
settings.require_full_compilation and num_supported_ops == total_ops
)

dryrun_tracker.total_ops_in_graph = total_ops
dryrun_tracker.supported_ops_in_graph = num_supported_ops
Expand Down Expand Up @@ -1422,6 +1425,7 @@ def contains_metadata(gm: torch.fx.GraphModule) -> bool:
settings=settings,
name="_run_on_acc_0",
engine_cache=engine_cache,
skip_conversion_validation=skip_conversion_validation,
)

# Store the original input spec for later use
Expand Down Expand Up @@ -1622,6 +1626,7 @@ def preserve_module_specs(
settings=settings,
name=name,
engine_cache=engine_cache,
skip_conversion_validation=skip_conversion_validation,
)

trt_modules[name] = trt_module
Expand Down
17 changes: 11 additions & 6 deletions py/torch_tensorrt/dynamo/conversion/_TRTInterpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def __init__(
input_binding_names: Optional[Sequence[str]] = None,
output_binding_names: Optional[Sequence[str]] = None,
_debugger_config: Optional[DebuggerConfig] = None,
skip_conversion_validation: bool = False,
):
super().__init__(module)

Expand All @@ -194,12 +195,16 @@ def __init__(
# an xdist worker), making those ops incorrectly appear as disallowed.
CONVERTERS.set_compilation_settings(compilation_settings)
self.validate_compile_settings()
missing_ops = self.validate_conversion()
if missing_ops:
warnings.warn(
"Interpretation will fail due to missing operations \n"
+ "\n".join(f"{i}" for i in missing_ops)
)
# compile_module already walked CONVERTERS via get_graph_converter_support.
# When that count was complete under require_full_compilation, this extra
# get() pass cannot find missing ops; skip it.
if not skip_conversion_validation:
missing_ops = self.validate_conversion()
if missing_ops:
warnings.warn(
"Interpretation will fail due to missing operations \n"
+ "\n".join(f"{i}" for i in missing_ops)
)

# Optimization profiles. Profiles are an ordered list on
# ``Input.profiles``; profile index i is built from each input's
Expand Down
12 changes: 11 additions & 1 deletion py/torch_tensorrt/dynamo/conversion/_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,16 @@ def interpret_module_to_result(
*,
input_binding_names: Optional[Sequence[str]] = None,
output_binding_names: Optional[Sequence[str]] = None,
skip_conversion_validation: bool = False,
) -> SerializedInterpreterResult:
"""Interpret an FX module to a TRTInterpreterResult
Args:
module: FX GraphModule to interpret
inputs: It requires a sequence of FLATTENED Inputs representing inputs to the module. It should include both arg_inputs and kwarg_inputs, if applicable.
settings: Compilation settings
engine_cache: Engine cache instance
skip_conversion_validation: If True, skip TRTInterpreter.validate_conversion.
Set by compile_module when require_full_compilation already proved full converter coverage.
Returns:
SerializedInterpreterResult
"""
Expand Down Expand Up @@ -291,6 +294,7 @@ def interpret_module_to_result(
engine_cache=engine_cache,
input_binding_names=input_binding_names,
output_binding_names=output_binding_names,
skip_conversion_validation=skip_conversion_validation,
)

interpreter_result = interpreter.run()
Expand Down Expand Up @@ -349,6 +353,7 @@ def convert_module(
settings: CompilationSettings = CompilationSettings(),
name: str = "",
engine_cache: Optional[BaseEngineCache] = None,
skip_conversion_validation: bool = False,
) -> TorchTensorRTModule:
"""Convert an FX module to a TRT module
Args:
Expand All @@ -357,11 +362,16 @@ def convert_module(
settings: Compilation settings
name: TRT engine name
engine_cache: Engine cache instance
skip_conversion_validation: If True, skip TRTInterpreter.validate_conversion.
Returns:
TorchTensorRTModule
"""
serialized_interpreter_result = interpret_module_to_result(
module, inputs, settings, engine_cache=engine_cache
module,
inputs,
settings,
engine_cache=engine_cache,
skip_conversion_validation=skip_conversion_validation,
)

if not ENABLED_FEATURES.torch_tensorrt_runtime:
Expand Down
Loading