Core Abstractions#
- class nsight.collection.core.NsightCollector#
Bases:
ABC- abstract collect( )#
Collects profiling data for the given function and configurations.
- class nsight.collection.core.NsightProfiler(
- settings: ProfileSettings,
- collector: NsightCollector,
Bases:
objectA decorator class for profiling functions using Nsight Python’s profiling tools.
This class allows you to wrap a function with profiling capabilities, collecting performance data and saving the results to CSV files. It uses a collector to gather raw profiling data and processes it according to the provided settings.
- Parameters:
settings (ProfileSettings)
collector (NsightCollector)
- settings#
Configuration settings for profiling, including normalization, and other options.
- collector#
The collector responsible for gathering raw profiling data.
- __call__(func)#
Wraps the given function with profiling logic. Collects raw profiling data, processes it, and saves the results to CSV files. Returns the processed data.
- class nsight.collection.core.ProfileResults(results: DataFrame)#
Bases:
objectClass to hold profile results for Nsight Python
- Parameters:
results (DataFrame)
- to_dataframe()#
Returns the processed profiling data as a pandas DataFrame.
This DataFrame contains aggregated statistics across multiple runs for each configuration and annotation combination. The data is equivalent to what is written to the
processed_data-<function_name>-<run_id>.csvfile whenoutput_csv=True.- Returns:
Annotation: Name of the annotated region being profiled<param_name>: One column for each parameter of the decorated functionAvgValue: Average metric value across all runsStdDev: Standard deviation of the metric across runsMinValue: Minimum metric value observedMaxValue: Maximum metric value observedNumRuns: Number of runs used for aggregationCI95_Lower: Lower bound of the 95% confidence intervalCI95_Upper: Upper bound of the 95% confidence intervalRelativeStdDevPct: Standard deviation as a percentage of the meanStableMeasurement: Boolean indicating if the measurement is stable (low variance). The measurement is stable ifRelativeStdDevPct< 2 % .Metric: The metric being collectedTransformed: Name of the function used to transform the metric (specified viaderive_metric), orFalseif no transformation was applied. For lambda functions, this shows"<lambda>"Kernel: Name of the GPU kernel(s) launchedGPU: GPU device nameHost: Host machine nameComputeClock: GPU compute clock frequencyMemoryClock: GPU memory clock frequency
- Return type:
Processed profiling data with the following columns
- class nsight.collection.core.ProfileSettings(
- configs: Sequence[Sequence[Any]] | None,
- runs: int,
- output_progress: bool,
- output_detailed: bool,
- derive_metric: Callable[[...], float] | None,
- normalize_against: str | None,
- thermal_control: bool,
- output_prefix: str | None,
- output_csv: bool,
Bases:
objectClass to hold profile settings for Nsight Python.
- Parameters:
-
configs:
Sequence[Sequence[Any]] |None# A list of configurations to run the function with. Each configuration is a tuple of arguments for the decorated function. Nsight Python invokes the decorated function
len(configs) * runstimes. If the configs are not provided at decoration time, they must be provided when calling the decorated function.
-
derive_metric:
Callable[...,float] |None# A function to transform the collected metric. This can be used to compute derived metrics like TFLOPs that cannot be captured by ncu directly. The function takes the metric value and the arguments of the profile-decorated function and returns the new metric. See the examples for concrete use cases.
-
normalize_against:
str|None# Annotation name to normalize metrics against. This is useful to compute relative metrics like speedup.