diff --git a/CHANGELOG.md b/CHANGELOG.md index ada9f32d..7adde34f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ limitations under the License. - change: Remove PyTorch dependencies from `nav.profile` - new: Introducing custom_args in TensorConfig for custom runners to handle - enables dynamic shapes user setup for TorchTensorRT compilation +- fix: Exception is raised with Python >=3.11 due to wrong dataclass initialization ## 0.12.0 diff --git a/model_navigator/reporting/optimize/base_report.py b/model_navigator/reporting/optimize/base_report.py index a2b64d09..1a912975 100644 --- a/model_navigator/reporting/optimize/base_report.py +++ b/model_navigator/reporting/optimize/base_report.py @@ -21,7 +21,10 @@ from rich.console import Console from rich.table import Table -from model_navigator.reporting.optimize.events import OptimizeEvent, default_event_emitter +from model_navigator.reporting.optimize.events import ( + OptimizeEvent, + default_event_emitter, +) class BaseReport(ABC): @@ -43,7 +46,7 @@ def __init__(self, event_emitter: Optional[EventEmitter] = None) -> None: self.inplace_started = False self.has_optimization_started = False self.is_first_pipeline_command = False - self.console = Console(record=True) + self.console = Console(record=True, width=256) # specify width to prevent auto-width detection self.listen_for_events() def listen_for_events(self): @@ -51,7 +54,10 @@ def listen_for_events(self): self.emitter.on(OptimizeEvent.MODULE_REGISTERED, self.on_module_registered) self.emitter.on(OptimizeEvent.MODULE_REGISTRY_CLEARED, self.on_registry_cleared) self.emitter.on(OptimizeEvent.WORKSPACE_INITIALIZED, self.on_workspace_initialized) - self.emitter.on(OptimizeEvent.MODULE_PICKED_FOR_OPTIMIZATION, self.on_module_picked_for_optimization) + self.emitter.on( + OptimizeEvent.MODULE_PICKED_FOR_OPTIMIZATION, + self.on_module_picked_for_optimization, + ) self.emitter.on(OptimizeEvent.OPTIMIZATION_STARTED, self.on_optimization_started) self.emitter.on(OptimizeEvent.OPTIMIZATION_FINISHED, self.on_optimization_finished) self.emitter.on(OptimizeEvent.PIPELINE_STARTED, self.on_pipeline_started) diff --git a/model_navigator/reporting/profile/report.py b/model_navigator/reporting/profile/report.py index 02607ce2..a98999c0 100644 --- a/model_navigator/reporting/profile/report.py +++ b/model_navigator/reporting/profile/report.py @@ -38,7 +38,7 @@ class Row: """Represents a row in the status table.""" runtime: str = "" - status: Text = Text() + status: Text = field(default_factory=Text) results: List[ProfilingResult] = field(default_factory=list) is_separator: bool = False @@ -46,9 +46,7 @@ class Row: class SimpleReport: """Profile reports.""" - def __init__( - self, show_results: bool = True, event_emitter: Optional[EventEmitter] = None, width: Optional[int] = None - ) -> None: + def __init__(self, show_results: bool = True, event_emitter: Optional[EventEmitter] = None) -> None: """Initialized object. Args: @@ -68,7 +66,7 @@ def __init__( self.table_data: List[Row] = [] - self.console = Console(record=True, width=width) + self.console = Console(record=True, width=256) # specify width to prevent auto-width detection self.listen_for_events() def listen_for_events(self): diff --git a/tests/assets/reports/optimize/scenario_inplace_expected.txt b/tests/assets/reports/optimize/scenario_inplace_expected.txt index ad92f2e3..c10fd6eb 100644 --- a/tests/assets/reports/optimize/scenario_inplace_expected.txt +++ b/tests/assets/reports/optimize/scenario_inplace_expected.txt @@ -182,14 +182,11 @@ model_c: Verifying model trt-fp32 on TensorRT backend OK model_c: Verifying model trt-fp16 on TensorRT backend ... model_c: Verifying model trt-fp16 on TensorRT backend OK Optimization finished for all modules. - Optimization result for max throughput and min latency strategy -┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ -┃ Module name ┃ Optimized backend ┃ Path ┃ -┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ -│ model_a │ torchscript-trace on │ /home/dev/.cache/model_navig… │ -│ │ TorchScriptCUDA backend │ │ -│ model_b │ torchscript-trace on │ /home/dev/.cache/model_navig… │ -│ │ TorchScriptCUDA backend │ │ -│ model_c │ torchscript-trace on │ /home/dev/.cache/model_navig… │ -│ │ TorchScriptCUDA backend │ │ -└─────────────┴────────────────────────────────┴───────────────────────────────┘ + Optimization result for max throughput and min latency strategy +┏━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ +┃ Module name ┃ Optimized backend ┃ Path ┃ +┡━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ +│ model_a │ torchscript-trace on TorchScriptCUDA backend │ /home/dev/.cache/model_navigator/model_a/0/torchscript-trace/model.pt │ +│ model_b │ torchscript-trace on TorchScriptCUDA backend │ /home/dev/.cache/model_navigator/model_b/0/torchscript-trace/model.pt │ +│ model_c │ torchscript-trace on TorchScriptCUDA backend │ /home/dev/.cache/model_navigator/model_c/0/torchscript-trace/model.pt │ +└─────────────┴──────────────────────────────────────────────┴───────────────────────────────────────────────────────────────────────┘ diff --git a/tests/assets/reports/optimize/scenario_jax_expected.txt b/tests/assets/reports/optimize/scenario_jax_expected.txt index 0a1a573d..14ffb9be 100644 --- a/tests/assets/reports/optimize/scenario_jax_expected.txt +++ b/tests/assets/reports/optimize/scenario_jax_expected.txt @@ -33,15 +33,11 @@ Model: Building TensorRT engine trt-fp32 from ONNX model ... Model: Building TensorRT engine trt-fp32 from ONNX model SKIPPED Model: Building TensorRT engine trt-fp16 from ONNX model ... Model: Building TensorRT engine trt-fp16 from ONNX model SKIPPED -Model: Validating model tf-savedmodel-jit-xla on TensorFlowSavedModelCUDA -backend ... -Model: Validating model tf-savedmodel-jit-xla on TensorFlowSavedModelCUDA -backend OK -Model: Validating model tf-savedmodel-jit on TensorFlowSavedModelCUDA backend -... +Model: Validating model tf-savedmodel-jit-xla on TensorFlowSavedModelCUDA backend ... +Model: Validating model tf-savedmodel-jit-xla on TensorFlowSavedModelCUDA backend OK +Model: Validating model tf-savedmodel-jit on TensorFlowSavedModelCUDA backend ... Model: Validating model tf-savedmodel-jit on TensorFlowSavedModelCUDA backend OK -Model: Validating model tf-savedmodel-xla on TensorFlowSavedModelCUDA backend -... +Model: Validating model tf-savedmodel-xla on TensorFlowSavedModelCUDA backend ... Model: Validating model tf-savedmodel-xla on TensorFlowSavedModelCUDA backend OK Model: Validating model tf-savedmodel on TensorFlowSavedModelCUDA backend ... Model: Validating model tf-savedmodel on TensorFlowSavedModelCUDA backend OK @@ -77,18 +73,12 @@ Model: Validating model trt-fp32 on TensorRT backend ... Model: Validating model trt-fp32 on TensorRT backend FAIL Model: Validating model trt-fp16 on TensorRT backend ... Model: Validating model trt-fp16 on TensorRT backend SKIPPED -Model: Benchmarking model tf-savedmodel-jit-xla on TensorFlowSavedModelCUDA -backend ... -Model: Benchmarking model tf-savedmodel-jit-xla on TensorFlowSavedModelCUDA -backend OK -Model: Benchmarking model tf-savedmodel-jit on TensorFlowSavedModelCUDA backend -... -Model: Benchmarking model tf-savedmodel-jit on TensorFlowSavedModelCUDA backend -OK -Model: Benchmarking model tf-savedmodel-xla on TensorFlowSavedModelCUDA backend -... -Model: Benchmarking model tf-savedmodel-xla on TensorFlowSavedModelCUDA backend -OK +Model: Benchmarking model tf-savedmodel-jit-xla on TensorFlowSavedModelCUDA backend ... +Model: Benchmarking model tf-savedmodel-jit-xla on TensorFlowSavedModelCUDA backend OK +Model: Benchmarking model tf-savedmodel-jit on TensorFlowSavedModelCUDA backend ... +Model: Benchmarking model tf-savedmodel-jit on TensorFlowSavedModelCUDA backend OK +Model: Benchmarking model tf-savedmodel-xla on TensorFlowSavedModelCUDA backend ... +Model: Benchmarking model tf-savedmodel-xla on TensorFlowSavedModelCUDA backend OK Model: Benchmarking model tf-savedmodel on TensorFlowSavedModelCUDA backend ... Model: Benchmarking model tf-savedmodel on TensorFlowSavedModelCUDA backend OK Model: Benchmarking model onnx-jit-xla on OnnxCUDA backend ... @@ -123,16 +113,12 @@ Model: Benchmarking model trt-fp32 on TensorRT backend ... Model: Benchmarking model trt-fp32 on TensorRT backend FAIL Model: Benchmarking model trt-fp16 on TensorRT backend ... Model: Benchmarking model trt-fp16 on TensorRT backend SKIPPED -Model: Verifying model tf-savedmodel-jit-xla on TensorFlowSavedModelCUDA backend -... -Model: Verifying model tf-savedmodel-jit-xla on TensorFlowSavedModelCUDA backend -SKIPPED +Model: Verifying model tf-savedmodel-jit-xla on TensorFlowSavedModelCUDA backend ... +Model: Verifying model tf-savedmodel-jit-xla on TensorFlowSavedModelCUDA backend SKIPPED Model: Verifying model tf-savedmodel-jit on TensorFlowSavedModelCUDA backend ... -Model: Verifying model tf-savedmodel-jit on TensorFlowSavedModelCUDA backend -SKIPPED +Model: Verifying model tf-savedmodel-jit on TensorFlowSavedModelCUDA backend SKIPPED Model: Verifying model tf-savedmodel-xla on TensorFlowSavedModelCUDA backend ... -Model: Verifying model tf-savedmodel-xla on TensorFlowSavedModelCUDA backend -SKIPPED +Model: Verifying model tf-savedmodel-xla on TensorFlowSavedModelCUDA backend SKIPPED Model: Verifying model tf-savedmodel on TensorFlowSavedModelCUDA backend ... Model: Verifying model tf-savedmodel on TensorFlowSavedModelCUDA backend SKIPPED Model: Verifying model onnx-jit-xla on OnnxCUDA backend ... @@ -168,10 +154,9 @@ Model: Verifying model trt-fp32 on TensorRT backend SKIPPED Model: Verifying model trt-fp16 on TensorRT backend ... Model: Verifying model trt-fp16 on TensorRT backend SKIPPED Optimization finished for the model. - Optimization result for max throughput and min latency strategy -┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ -┃ Optimized backend ┃ Path ┃ -┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ -│ tf-savedmodel on │ /workspace/navigator_workspace/tf-s… │ -│ TensorFlowSavedModelCUDA backend │ │ -└───────────────────────────────────────┴──────────────────────────────────────┘ + Optimization result for max throughput and min latency strategy +┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ +┃ Optimized backend ┃ Path ┃ +┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩ +│ tf-savedmodel on TensorFlowSavedModelCUDA backend │ /workspace/navigator_workspace/tf-savedmodel/model.savedmodel │ +└───────────────────────────────────────────────────┴───────────────────────────────────────────────────────────────┘ diff --git a/tests/assets/reports/optimize/scenario_torch_expected.txt b/tests/assets/reports/optimize/scenario_torch_expected.txt index 6c0158be..3ba28041 100644 --- a/tests/assets/reports/optimize/scenario_torch_expected.txt +++ b/tests/assets/reports/optimize/scenario_torch_expected.txt @@ -49,10 +49,8 @@ Model: Validating model torchscript-script on TorchScriptCUDA backend ... Model: Validating model torchscript-script on TorchScriptCUDA backend OK Model: Validating model torchscript-trace on TorchScriptCUDA backend ... Model: Validating model torchscript-trace on TorchScriptCUDA backend OK -Model: Validating model torch-exportedprogram on TorchExportedProgramCUDA -backend ... -Model: Validating model torch-exportedprogram on TorchExportedProgramCUDA -backend FAIL +Model: Validating model torch-exportedprogram on TorchExportedProgramCUDA backend ... +Model: Validating model torch-exportedprogram on TorchExportedProgramCUDA backend FAIL Model: Validating model onnx-dynamo on OnnxCUDA backend ... Model: Validating model onnx-dynamo on OnnxCUDA backend SKIPPED Model: Validating model onnx-dynamo on OnnxTensorRT backend ... @@ -89,10 +87,8 @@ Model: Benchmarking model torchscript-script on TorchScriptCUDA backend ... Model: Benchmarking model torchscript-script on TorchScriptCUDA backend OK Model: Benchmarking model torchscript-trace on TorchScriptCUDA backend ... Model: Benchmarking model torchscript-trace on TorchScriptCUDA backend OK -Model: Benchmarking model torch-exportedprogram on TorchExportedProgramCUDA -backend ... -Model: Benchmarking model torch-exportedprogram on TorchExportedProgramCUDA -backend FAIL +Model: Benchmarking model torch-exportedprogram on TorchExportedProgramCUDA backend ... +Model: Benchmarking model torch-exportedprogram on TorchExportedProgramCUDA backend FAIL Model: Benchmarking model onnx-dynamo on OnnxCUDA backend ... Model: Benchmarking model onnx-dynamo on OnnxCUDA backend SKIPPED Model: Benchmarking model onnx-dynamo on OnnxTensorRT backend ... @@ -137,10 +133,8 @@ Model: Verifying model torchscript-script on TorchScriptCUDA backend ... Model: Verifying model torchscript-script on TorchScriptCUDA backend OK Model: Verifying model torchscript-trace on TorchScriptCUDA backend ... Model: Verifying model torchscript-trace on TorchScriptCUDA backend OK -Model: Verifying model torch-exportedprogram on TorchExportedProgramCUDA backend -... -Model: Verifying model torch-exportedprogram on TorchExportedProgramCUDA backend -SKIPPED +Model: Verifying model torch-exportedprogram on TorchExportedProgramCUDA backend ... +Model: Verifying model torch-exportedprogram on TorchExportedProgramCUDA backend SKIPPED Model: Verifying model onnx-dynamo on OnnxCUDA backend ... Model: Verifying model onnx-dynamo on OnnxCUDA backend SKIPPED Model: Verifying model onnx-dynamo on OnnxTensorRT backend ... diff --git a/tests/unit/base/test_reporting_profile.py b/tests/unit/base/test_reporting_profile.py index e2b9d683..7da1c610 100644 --- a/tests/unit/base/test_reporting_profile.py +++ b/tests/unit/base/test_reporting_profile.py @@ -40,7 +40,7 @@ def emit_events(event_emitter, filename): @pytest.mark.parametrize("scenario_name", ["profile_with_results"]) def test_simple_report_with_results(scenario_name, mock_event_emitter): # noqa: F811 # given - report = SimpleReport(event_emitter=mock_event_emitter, width=200) + report = SimpleReport(event_emitter=mock_event_emitter) # when emit_events(mock_event_emitter, f"scenario_{scenario_name}.txt") # then