Utils#

class nsight.utils.Colors#

Bases: object

For colorful printing.

BLUE = '\x1b[0;34m'#
BOLD = '\x1b[1m'#
CYAN = '\x1b[0;36m'#
ENDC = '\x1b[0m'#
GREEN = '\x1b[0;32m'#
HEADER = '\x1b[95m'#
ORANGE = '\x1b[0;33m'#
PURPLE = '\x1b[0;35m'#
RED = '\x1b[0;31m'#
UNDERLINE = '\x1b[4m'#
class nsight.utils.LogParser#

Bases: object

Base class for parsing the log files

parse_logs(log_file_path: str)#

Parses the log file and returns a list of log entries.

Parameters:

log_file_path (str) – Path to the log file.

Return type:

dict[str, list[str]]

class nsight.utils.NCUActionData(
name: str,
value: Any,
compute_clock: int,
memory_clock: int,
gpu: str,
)#

Bases: object

Parameters:
static combine(value_reduce_op: Any)#

Combines two NCUActionData objects into a new one by applying the value_reduce_op to their values.

Return type:

Any

Parameters:

value_reduce_op (Any)

compute_clock: int#
gpu: str#
memory_clock: int#
name: str#
value: Any#
class nsight.utils.NCULogParser#

Bases: LogParser

Parse NCU log file.

get_logs(log_file_path: str, category: str)#

Returns log entries of a specific category from the NCU log file.

Parameters:
  • log_file_path (str) – Path to the NCU log file.

  • category (str) – Category of logs (e.g., “ERROR”, “PROF”).

Return type:

list[str]

parse_logs(log_file_path: str)#

Parses the NCU log file and returns a dictionary of log entries categorized by their type.

Parameters:

log_file_path (str) – Path to the NCU log file.

Return type:

dict[str, list[str]]

nsight.utils.batched(iterable: Any, n: int)#

Batch an iterable into tuples of size n.

This is a minimal backport of itertools.batched for Python 3.10 and 3.11, where the standard library implementation is not available.

Return type:

Iterator[tuple[Any, ...]]

Parameters:
class nsight.utils.col_panel#

Bases: object

nsight.utils.format_ncu_error_message(context: NCUErrorContext)#

Format NCU error context into user-friendly error message.

Parameters:

context (NCUErrorContext) – The error context containing all relevant information.

Return type:

str

nsight.utils.format_time(seconds: float)#

Convert seconds into HH:MM:SS format

Return type:

str

Parameters:

seconds (float)

nsight.utils.get_dummy_kernel_module()#

Returns a dummy kernel that does nothing. In case a provider fails for some, reason, but we want to keep benchmarking we launch this dummy kernel such that during our later analysis of the ncu-report we still find the expected number of measured kernels per provider.

The measured runtime of this kernel is ignored and the final result of the failed run will be reported as NaN.

Raises:

ImportError – If cuda-core is not installed.

Return type:

Any

nsight.utils.launch_dummy_kernel_module()#

Launch a dummy kernel module.

Raises:

ImportError – If cuda-core is not installed.

Return type:

None

nsight.utils.print_config(
total_configs: int,
curr_config: int,
c: Any,
overwrite_output: bool,
)#

Prints the current configuration being profiled.

Parameters:
  • total_configs (int) – Total number of configurations.

  • curr_config (int) – Current configuration index.

  • c (Any) – The current configuration parameters.

  • overwrite_output (bool) – Controls how configurations are printed: - True: The configuration is updated in-place - False: Each configuration is printed on a new line

Return type:

None

nsight.utils.print_header(*lines: str)#
Return type:

None

Parameters:

lines (str)

nsight.utils.print_progress_bar(
total_runs: int,
curr_run: int,
bar_length: int,
avg_time_per_run: float,
overwrite_output: bool,
)#

Prints a dynamic progress bar to the terminal.

Parameters:
  • total_runs (int) – Total number of runs to execute.

  • curr_run (int) – Current run index.

  • bar_length (int) – Length of the progress bar in characters.

  • avg_time_per_run (float) – Average time taken per run, used to estimate remaining time.

  • overwrite_output (bool) – Controls how configurations are printed: - True: Overwrites the existing progress bar - False: Writes a new progress bar

Return type:

None

nsight.utils.purple(msg: str)#

Prints msg in purple.

Return type:

str

Parameters:

msg (str)

class nsight.utils.row_panel#

Bases: object