Scope where ProfilingContext* skip cuda.synchronize on enter/exit. Use around AR segment loops with async VAE so nested profilers (step_pre, infer_main, segment end2end, AR segments total) do not insert GPU barriers that flatten DiT/VAE overlap. The region must end with explicit sync
(enabled: bool = True)
| 28 | |
| 29 | |
| 30 | def _get_memory_profile_stack(): |
| 31 | if not hasattr(_memory_profile_local, "stack"): |
| 32 | _memory_profile_local.stack = [] |
| 33 | return _memory_profile_local.stack |
| 34 | |
| 35 | |
| 36 | @contextmanager |
| 37 | def no_sync_profiling(enabled: bool = True): |
| 38 | """Scope where ProfilingContext* skip cuda.synchronize on enter/exit. |
| 39 | |
| 40 | Use around AR segment loops with async VAE so nested profilers (step_pre, |
| 41 | infer_main, segment end2end, AR segments total) do not insert GPU barriers |
| 42 | that flatten DiT/VAE overlap. The region must end with explicit sync |
| 43 | (e.g. async_vae_decoder.finish()). |
| 44 | """ |
| 45 | if not enabled: |
| 46 | yield |
| 47 | return |
| 48 | prev = getattr(_no_sync_local, "active", False) |
| 49 | _no_sync_local.active = True |