nsight.annotate#

class nsight.annotate(name: str, ignore_failures: bool = False)#

Bases: annotate

A decorator/context-manager hybrid for marking profiling regions. The encapsulated code will be profiled and associated with an NVTX range of the given annotate name.

Example usage:

# as context manager
with nsight.annotate("name"):
    # your kernel launch here

# as decorator
@nsight.annotate("name")
def your_kernel_launcher(...):
    ...
Parameters:
  • name (str) – Name of the annotation to be used for profiling. Annotation names must be unique within a single profiling run to ensure unambiguous results.

  • ignore_failures (bool) – Flag indicating whether to ignore failures in the annotate context. If set to True, any exceptions raised within the context will be ignored, and the profiling will continue. The measured metric for this run will be set to NaN. Default: False

Raises:

ValueError – If attempting to enter a nested annotation context, or if an annotation with the same name has already been used in this profiling run. Nested annotations are not supported and annotation names must be unique within a profiling run to avoid incorrect profiling results.

Note

All annotations are created under the NVTX domain "nsight-python". This domain is used internally to filter and identify Nsight Python annotations in profiling tools.

Note

Nested annotations are currently not supported. However, since each annotation is expected to contain a single kernel launch by default, nested annotations should not be necessary in typical usage scenarios.