Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

debug: persist the profile table to a file next to the chrome trace

Lincoln Stein454da42153b3
diff --git a/invokeai/backend/minimax_h3/denoise.py b/invokeai/backend/minimax_h3/denoise.py
index 96052756df..6e299ddb1d 100644
--- a/invokeai/backend/minimax_h3/denoise.py
+++ b/invokeai/backend/minimax_h3/denoise.py
@@ -101,14 +101,25 @@ def _profile_one_step(trace_target: str, device: torch.device, run_step: Callabl
trace_dir = Path(trace_target) if trace_target.lower() not in ("1", "true", "yes") else Path.cwd()
trace_path = trace_dir / "h3_denoise_step_trace.json"
+ table_path = trace_dir / "h3_denoise_step_profile.txt"
try:
trace_dir.mkdir(parents=True, exist_ok=True)
+ # Persist the table too: the log line above can scroll away, and the cudaEvent fallback's
+ # chrome trace carries no GPU lanes — on that path this file is the only durable record of
+ # the GPU times.
+ table_path.write_text(
+ f"MiniMax H3 denoise step profile ({time.strftime('%Y-%m-%d %H:%M:%S')})\n"
+ f"device: {torch.cuda.get_device_name(device) if is_gpu else device}\n"
+ f"wall time for the profiled step: {wall_elapsed:.2f}s (includes profiler overhead)\n\n"
+ f"{table}\n",
+ encoding="utf-8",
+ )
prof.export_chrome_trace(str(trace_path))
- logger.info(f"MiniMax H3 denoise: wrote chrome trace to {trace_path}")
+ logger.info(f"MiniMax H3 denoise: wrote {table_path} and chrome trace {trace_path}")
except Exception:
- # The table above is the primary deliverable; a failed trace export must not kill the
+ # The table above is the primary deliverable; a failed file export must not kill the
# generation mid-denoise.
- logger.warning(f"MiniMax H3 denoise: failed to write chrome trace to {trace_path}", exc_info=True)
+ logger.warning(f"MiniMax H3 denoise: failed to write profile files to {trace_dir}", exc_info=True)
def denoise(
diff --git a/tests/backend/minimax_h3/test_denoise.py b/tests/backend/minimax_h3/test_denoise.py
index 41c7630677..96b7b92540 100644
--- a/tests/backend/minimax_h3/test_denoise.py
+++ b/tests/backend/minimax_h3/test_denoise.py
@@ -184,3 +184,4 @@ def test_profiling_env_var_preserves_results_and_writes_trace(tiny_transformer,
assert torch.equal(reference_video, profiled_video)
assert torch.equal(reference_audio, profiled_audio)
assert (tmp_path / "h3_denoise_step_trace.json").exists()
+ assert (tmp_path / "h3_denoise_step_profile.txt").exists()