Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

26.1 KB
Raw Blame

GPU Plugin Debug Utils

This document is a list of useful debug features / tricks that might be used to find root cause of performance / functional issues. Some of them are available by default, but some others might require plugin recompilation.

How to use it

First, debug features should be enabled from cmake configuration ENABLE_DEBUG_CAPS. When OpenVINO is released, it is turned off by default.

The parameters can be set from an environment variable when calling inference engine API. The environment variable name is concatenation of OV_ prefix and string identifier of corresponding ov property (for instance, one of the properties here src/plugins/intel_gpu/include/intel_gpu/runtime/internal_properties.hpp)

$ OV_VERBOSE=1 ./benchmark_app ...                       # Run benchmark_app with OV_VERBOSE option
$ OV_GPU_DUMP_TENSORS_PATH="dump/" ./benchmark_app ...   # Run benchmark_app and store intermediate buffers into dump/ directory.

For Windows OS, use the following syntax:

Windows Power Shell:
> $env:OV_VERBOSE=1
> .\benchmark_app.exe ...      # Run benchmark_app with OV_VERBOSE option

Windows cmd.exe:
> set "OV_VERBOSE=1"
> benchmark_app.exe ...      # Run benchmark_app with OV_VERBOSE option

Alternative approach, is to prepate config file in json format and set path to it via OV_DEBUG_CONFIG=path option. NOTE: 1. Options set via environment has higher priority than options from the config file. 2. Global options can't be activated via config to avoid mess when the finalize() call changes the value of globally visible variable which may lead to some weird behavior. Config example:

{"GPU.1":{"OV_VERBOSE":"ON","PERF_COUNT":"ON"}}

Option types

Plugin config supports 4 option types:

  1. OV_CONFIG_RELEASE_OPTION - options that are available via public API for any kind of builds
  2. OV_CONFIG_RELEASE_INTERNAL_OPTION - available for any build type, but can't be set via public API.
  3. OV_CONFIG_DEBUG_OPTION - these options are available for the builds with ENABLE_DEBUG_CAPS only.
  4. OV_CONFIG_DEBUG_GLOBAL_OPTION - same as above, but a little bit different behavior (see below).

The difference between "local" and "global" options is that value for local option is resolved during "finalize" call for the config class which typically happens somewhere after Core::{compile,import,query}_model() call. That means that the local options can be set per-model basis for the multi model pipelines if env is modified from the code for each model.

Value of the global options is read from env on the first access to the option, or set as default value if not present in environment. Global option variables are static members of the config which is needed to activate some basic debug capabilities (such as logging) in the arbitrary part of the project w/o need to pass ExecutionConfig object to all the places where we need to log something.

List of parameters

Full options list is defined in src/plugins/intel_gpu/include/intel_gpu/runtime/options.inl file. This can also be printed to console by setting OV_HELP=1 option

Quick lookup table for debug configuration

These are the most commonly used GPU debug knobs.

Env variable name When/how to use
OV_VERBOSE Verbosity level. Supported range: 0 (disabled) to 4 (maximum).
OV_GPU_LOG_TO_FILE Saves verbose logs to the specified file.
OV_GPU_LIST_LAYERS Set to 1 to print the list of executed primitives. This is a subset of the OV_VERBOSE log.
OV_GPU_FORCE_FP32_LAYER_TYPES Space-separated operation types, including the optional PASSTHROUGH_OPS alias, to promote from FP16 to FP32. See Selective FP32 precision.
OV_GPU_FORCE_FP32_LAYER_NAMES Space-separated friendly-name substrings to select for FP32 promotion. Combined with the type filter using AND.
OV_DYNAMIC_QUANTIZATION_GROUP_SIZE Sets the dynamic quantization group size. For best accuracy, disable dynamic quantization by setting this value to 0.
OV_ACTIVATIONS_SCALE_FACTOR Scalar floating-point value used for runtime activation tensor scaling. This is mainly useful for accuracy troubleshooting where NaN or inf is created in the middle of network execution.
OV_GPU_DUMP_GRAPHS_PATH Saves intermediate graph representations during model compilation to the specified directory. Useful for debugging fusion, layout selection, or opt-out decisions. See the graph dump section below for details.
OV_GPU_DUMP_MEMORY_POOL Enables verbose output for the memory pool. Supported values: 0 (disabled), 1 (summary), 2 (detailed entries).
OV_GPU_DUMP_SOURCES_PATH Saves generated OpenCL sources for each kernel to the specified directory. Useful for debugging kernel generation and source-level issues. See the source dump section below for details.
OV_GPU_ENABLE_LARGE_ALLOCATIONS Allows buffer allocations that exceed the device maximum allocation size. This is enabled by default on Xe2+ platforms.
OV_GPU_HOST_TIME_PROFILING Measures and prints host-side time spent from the beginning of inference until all host work is done and the plugin is ready to block on the final clFinish() call. It reports enqueue and wait times separately. Set to 1 for enqueue time only; set to 2 for detailed breakdown (input processing, enqueue, wait, and output processing).
OV_GPU_NETWORK_MARKER Inserts named OpenCL marker kernels at the start and end of network execution for tools such as CLIntercept. Useful for low-level debugging of execution traces and device timeline data.
OV_GPU_PRINT_INPUT_DATA_SHAPES Prints network input tensor shapes. Useful for understanding runtime behavior and shape-related issues.
OV_GPU_VALIDATE_OUTPUT_BUFFER Validates output buffers for all layers with fp16 data type to detect inf and nan values.

Family of debug configuration options for inspecting intermediate data (primitive output)

These options enable inspection of intermediate tensor data and are primarily used for accuracy troubleshooting.

Env variable name When/how to use
OV_GPU_DUMP_TENSORS_PATH Saves intermediate input/output tensors for each primitive to the specified directory. This is the main switch for tensor dump mode. See the tensor dump section below for details.
OV_GPU_DUMP_SINCOS_PATH Saves raw binary input/output of every Sin/Cos activation to the specified directory (must end with /). Files are named SINCOS__<seq>__p<program>_n<network>_i<iteration>__<sin|cos>__<src0|dst0>__<dtype>__<AxBxC>__<layer>.bin. Synchronizes the stream on every Sin/Cos node. Useful for troubleshooting position-embedding accuracy.
OV_GPU_DUMP_TENSORS Tensor types to dump. Supported values: all, in, out.
OV_GPU_DUMP_ITERATIONS Space-separated list of iterations when the other dump options should be enabled.
OV_GPU_DUMP_LAYER_NAMES Enables dumping only for the specified layer names.
OV_GPU_DUMP_SRC_TENSORS_AFTER_EXEC Enables source data dump after layer execution. Useful for capturing updated state in stateful models.
OV_GPU_DUMP_TENSORS_FORMAT Tensor dump format. Supported values: binary, text, text_raw. Text dumps are planar and are slower because of in-flight reorder. text_raw dumps without reordering. For weights, binary or text is usually preferred because weight-reorder support is not available for all formats.
OV_GPU_LOAD_DUMP_RAW_BINARY Load input data of layers from raw binary dump files. When tensors are dumped in binary format, this allows them to be loaded during inference for accuracy debugging.

How to check debug-config works

All options that are found in environment or config file are printed to stdout:

$ OV_VERBOSE=1 ./benchmark_app
...
Non default env value for VERBOSE = 1
...

Selective FP32 precision

Use ForceFP32Selective to investigate FP16 accuracy issues by promoting selected operations' FP16 inputs and outputs to FP32. This feature requires ENABLE_DEBUG_CAPS=ON and ENABLE_GPU_DEBUG_CAPS=ON. Sources remain in the build lists, following the GPU debug helper pattern. When GPU debug caps are disabled, GPU_DEBUG_CONFIG guards exclude the pass declaration, implementation, registration, and unit tests during preprocessing. Configuration options use the standard OV_CONFIG_DEBUG_OPTION mechanism, controlled by ENABLE_DEBUG_CAPS.

The pass runs at the end of the GPU model transformation pipeline, after precision conversion and fusion. Filters use the operation's current type (get_type_name()) and friendly name at this stage. For example, an original MatMul may already be FullyConnected, and an RMS pattern may be fused into the internal RMS operation. Use types and names from the transformed model; names from the original model may have changed.

Filters and examples

Both variables accept space-separated values. Quote a list in the shell; commas do not separate values. Operation type matching is exact and case-sensitive; PASSTHROUGH_OPS is a reserved type-list alias. Name matching uses case-sensitive substrings, with no regular expressions or wildcards.

Type list Name list Initial selection
Empty Empty No changes.
Set Empty Any listed type (OR).
Empty Set Any listed name substring (OR).
Set Set A listed type AND a listed name substring.

A matching operation must have at least one FP16 output. If no operation qualifies, the pass makes no changes. GPU Placeholder, model Parameter/Result, and operations with no outputs are excluded from initial selection.

The examples below set only the filters shown. Leave the other filter unset when using type-only or name-only selection. Replace the example names with friendly-name substrings present in your transformed model.

# Type-only: select FullyConnected OR RMS.
OV_GPU_FORCE_FP32_LAYER_TYPES="FullyConnected RMS" ./benchmark_app -m model.xml -d GPU

# Name-only: select names containing block.19 OR ff.net.0.proj.
OV_GPU_FORCE_FP32_LAYER_NAMES="block.19 ff.net.0.proj" ./benchmark_app -m model.xml -d GPU

# Combined: select RMS nodes whose names contain block.19; print changed ports.
OV_GPU_FORCE_FP32_LAYER_TYPES="RMS" OV_GPU_FORCE_FP32_LAYER_NAMES="block.19" \
OV_VERBOSE=2 ./benchmark_app -m model.xml -d GPU

# Opt in to FP32 data movement operations as well as RMS.
OV_GPU_FORCE_FP32_LAYER_TYPES="RMS PASSTHROUGH_OPS" ./benchmark_app -m model.xml -d GPU

Selection region and precision boundaries

The region contains only operations selected by the filters; there is no automatic propagation to neighboring operations. To include intermediate data movement operations, list their types or names explicitly, or add PASSTHROUGH_OPS to the type list.

PASSTHROUGH_OPS matches Reshape, Transpose, Squeeze, Unsqueeze, StridedSlice, Gather, Concat, Split, VariadicSplit, ShapeOf, and Broadcast. This is a model-wide type alias, not a search for paths between target operations. Without a name filter, it also selects disconnected operations and branches of these types. With a name filter, alias matches must satisfy the same name condition. Only FP16 outputs qualify, so integer ShapeOf outputs are preserved.

For example, OV_GPU_FORCE_FP32_LAYER_TYPES="RMS PASSTHROUGH_OPS" selects RMS and the listed data movement types across the model. Adding OV_GPU_FORCE_FP32_LAYER_NAMES="block.19" restricts both groups to matching names; intermediate nodes with other names remain unselected.

Only originally FP16 output ports are promoted. Existing FP32, integer, boolean, and BF16 outputs keep their types; for example, TopK values are promoted while its integer indices remain unchanged. External FP16 inputs get FP32 Converts, and outputs leaving the region are restored to their original FP16 type. Model input and output types remain unchanged.

Unselected intermediate operations keep their FP16 boundaries. A path such as selected FP32 operation → FP16 Reshape/Transpose → selected FP32 operation still introduces FP16 rounding. Select all required intermediate operations to keep that path FP32; the alias makes this an explicit user choice.

Region nodes connect directly where possible. FP16/FP32 Convert chains can be bypassed on a selected input edge when they lead back to a promoted region output or an external FP32 source. Other consumers keep the original chain. Chains containing integer, boolean, or BF16 conversions, or starting from an external FP16 producer, are preserved.

Supported scope and limits

The unit suite covers filtering (type-only, name-only, OR within lists, AND between lists, and no matches), internal RMS and GPU FullyConnected precision attributes, TypeRelaxed overrides, mixed output types, internal and shared Convert edges, explicit pass-through selection and alias/name filtering, and Placeholder inputs. Selected arithmetic graphs are also evaluated to check rounding and preservation of unselected branches. The pass updates recognized FP16 output precision attributes as well as output descriptors; these tests do not establish GPU kernel execution precision.

Constant data, shared state (ReadValue/Assign and caches), and Loop/If boundaries are not fully supported. The pass does not recursively select operations inside subgraph bodies. Constant, state, and subgraph operations are excluded from precision attribute updates, but are not all excluded by the initial filters; avoid selecting them until coordinated type handling is implemented. Separate calculation attributes such as RMSNorm::compute_type are not updated.

Widening an already rounded FP16 value to FP32 does not recover the lost precision. This applies to previously compressed constants and values produced outside the region. Check the compiled runtime graph and GPU results to confirm the execution precision and accuracy of the selected operations.

With OV_VERBOSE=2 or higher, the pass logs changed graph output ports. Example output (without the file/line prefix):

[ForceFP32Selective] FORCED: type=RMS  name=block.19.rms  output=0 f16->f32
[ForceFP32Selective] Done. Region=1  Forced=1  Outputs=1

Region is the number of operations selected by the filters, Forced counts nodes with logged promotions still present in the model, and Outputs counts their promoted ports. Unmatched or unchanged nodes have no FORCED entry. Logs describe the graph at the end of this pass, before automatic validation and GPU kernel selection; they do not confirm kernel execution precision.

Tagged verbose logs

Some verbose logs belong to a feature family and carry a tag right after the regular log prefix, so all decisions of one feature can be collected with a single grep:

GPU_Debug: dynamic_quantize.cpp:43:should_skip_execution: [dynquan] dynamicquantize:DynamicQuantize_155332 skipped at runtime: ...

In code, use GPU_DEBUG_TAGGED(level, "tag") where level is one of COUT, INFO, LOG, TRACE, TRACE_DETAIL (the same levels as OV_VERBOSE):

GPU_DEBUG_TAGGED(TRACE, "dynquan") << node.id() << " turned off: <reason>" << std::endl;

Tag naming convention: a short string literal of lowercase letters and digits only, without separators (no _ or -). Reuse an existing tag for the same family and add new tags to the table below.

Tag Feature Useful OV_VERBOSE level
dynquan Dynamic quantization of fully connected activations 3

Why was dynamic quantization (not) applied?

Dynamic quantization quantizes the activation of a fully connected (FC) layer with compressed (4/8-bit) weights to int8 at runtime, so that the matmul runs in int8. It is enabled by default, but the plugin decides per -FC and per-inference whether to use it. Every decision is logged with the dynquan tag:

$ OV_VERBOSE=3 OV_GPU_LOG_TO_FILE=dq.log ./benchmark_app ...    # or any application
$ grep "\[dynquan\]" dq.log

Example of grep "\[dynquan\]" dq.log on an XMX GPU:

GPU_Debug: transformations_pipeline.cpp:1942:operator(): [dynquan] __module.lm_head/aten::linear/MatMul turned off: N == 1 (activation quantization is unprofitable; keep weight-only quantization with f16 activation)
GPU_Debug: dynamic_quantize_fully_connected.cpp:159:operator(): [dynquan] __module.model.layers.0.mlp.down_proj/aten::linear/MatMul applied: group_size per-token, dt i8, sym
GPU_Debug: dynamic_quantize.cpp:43:should_skip_execution: [dynquan] dynamicquantize:DynamicQuantize_155332 skipped at runtime: token count 1 <= dynamic_quantization_threshold 64

Dump execution graph

The execution graph (also known as a runtime graph) is a device-specific graph after all transformations applied by the plugin. It is a very useful feature for performance analysis and it allows finding a source of performance regressions quickly. The execution graph can be retrieved from the plugin using get_runtime_model() method of ov::CompiledModel and then serialized as usual IR:

    ov::CompiledModel compiled_model;
    // Load some model into the plugin
    std::shared_ptr<ov::Model> runtime_model = compiled_model.get_runtime_model();
    ov::serialize(runtime_model, "/path/to/serialized/exec/graph.xml");

The capability to retrieve the execution graph and store it on the disk is integrated into benchmark_app. The execution graph can be simply dumped by setting an additional parameter -exec_graph_path exec_graph.xml for benchmark_app. Output xml file has a format similar to usual IR, but contains execution nodes with some runtime info such as:

  • Execution time of each node
  • Mapping between nodes in final device specific graph and original input graph operations
  • Output layout
  • Output precision
  • Primitive type
  • Inference precision

A typical node in GPU execution graph looks as follows:

<layer id="0" name="convolution" type="Convolution">
    <data execOrder="1" execTimeMcs="500" originalLayersNames="convolution,relu" outputLayouts="b_fs_yx_fsv16" outputPrecisions="FP16" primitiveType="convolution_gpu_bfyx_to_bfyx_f16" />
    <input>
        <port id="0">
            <dim>1</dim>
            <dim>3</dim>
            <dim>224</dim>
            <dim>224</dim>
        </port>
    </input>
    <output>
        <port id="1" precision="FP16">
            <dim>1</dim>
            <dim>64</dim>
            <dim>112</dim>
            <dim>112</dim>
        </port>
    </output>
</layer>

Most of the data here is very handy for performance analysis. For example, for each node you can check whether:

  • Nodes fusion works as expected on given models (that is, some node is missing in the execution graph and its name is a part of originalLayersNames list for some other node)
  • Input and output layouts of a node are optimal in each case
  • Input and output precisions are valid in each case
  • The node used the expected kernel for execution
  • And most important: the actual execution time of each operation

This graph can be visualized using Netron tool and all these properties can be analyzed there.

NOTE: execution time collection for each primitive requires ov::enable_profiling to be enabled (benchmark_app does it automatically). Therefore, the overall model execution time is usually much worse in such use cases.

Performance counters

This feature is a simplified version of the execution graph as it provides much less information, but it might be more suitable for quick analysis and some kind of processing with scripts.

Performance counters can be retrieved from each ov::InferRequest object using get_profiling_info() method. This feature is also integrated into benchmark_app and the counters can be printed to count using -pc parameter.

The format looks as follows:

${layer_name}      ${exec_status}  layerType: ${type}            realTime: ${device_time}  cpu: ${host_time}    execType: ${kernel_name}
Total time: ${sum_of_device_times} microseconds

For example:

convolution         EXECUTED       layerType: Convolution        realTime: 500             cpu: 3               execType: convolution_gpu_bfyx_os_iyx_osv16
relu                OPTIMIZED_OUT  layerType: ReLU               realTime: 0               cpu: 0               execType: undef
Total time: 53877 microseconds

So it allows you to quickly check the execution time of some operation on the device and make sure that the correct primitive is used. Also, the output can be easily converted into the .csv format and then used to collect any kind of statistics (for example, execution time distribution by layer types).

Graph dumps

Intel_GPU plugin allows you to dump some info about intermediate stages in the graph optimizer.

  • You can dump graphs with OV_GPU_DUMP_GRAPHS_PATH of debug config. For the usage of debug config, see the link.

For each stage, it dumps:

- cldnn_program_${program_id}_${stage_id}_${stage_name}.graph - graph saved in dot format which can be visualized via graphviz tool
- cldnn_program_${program_id}_${stage_id}_${stage_name}.info - graph in text format
- cldnn_program_${program_id}_${stage_id}_${stage_name}.optimized - the list of nodes optimized out up to this stage
- cldnn_program_${program_id}_${stage_id}_${stage_name}.order - processing order in text format
- ${program_id}_${stage_id}_${stage_name}.xml - graph in a format of execution graph

The main graph usually has program_id = 0. Graphs with other program_id values are usually created internally for constant propagation or some other purposes.

Sources dumps

Since Intel_GPU source tree contains only templates of the OpenCL™ kernels, it is quite important to get full kernels source code.

  • You can use OV_GPU_DUMP_SOURCES_PATH of debug config. For the usage of debug config, see link.

When this key is enabled, the plugin dumps multiple files with the following names:

clDNN_program_${program_id}_part_${bucket_id}.cl

Note: program_id here might differ from program_id for the graph dumps, as it is just a static counter for enumerating incoming programs.

Each file contains a bucket of kernels that are compiled together. In case of any compilation errors, Intel_GPU plugin will append compiler output to the end of the corresponding source file.

To find a specific layer, use "Debug/RelWithDebInfo" build or modify the base jitter method to append LayerID in the release build:

// inference-engine/thirdparty/clDNN/kernel_selector/core/kernel_base.cpp
JitConstants KernelBase::MakeBaseParamsJitConstants(const base_params& params) const {
    // ...
#ifndef NDEBUG                             <--- should be removed
    jit.AddConstant(MakeJitConstant("LayerID", params.layerID));
#endif
}

When the source is dumped, it contains a huge amount of macros(#define). For readability, you can run c preprocessor to apply the macros.

$ cpp dumped_source.cl > clean_source.cl

Forcing implementations

You can force a specific implementation for chosen primitives by setting OV_GPU_FORCE_IMPLEMENTATIONS option. Variable expects strings with the following format:

OV_GPU_FORCE_IMPLEMENTATIONS={Name:Impl:Kernel:Layout}, where

  • Name is the name of the primitive, for which you'd like to force a specific implementation. Name used in this context has the following form: 'layer_name:primitive_id'. Use quotation marks, otherwise the colon in the name will be treated as a separator.
  • Impl is the forced implementation name, available: any, ocl, cm, sycl, onednn, common, cpu
  • Kernel is the name of the kernel you'd like to be executed. Please note that currently forcing the specific kernel works only for ocl implementation
  • Layout is the output layout. The full list of available layouts is available here

You can force implementation for more than 1 primitive:

OV_GPU_FORCE_IMPLEMENTATIONS={Name:Impl:Kernel:Layout},{Name:Impl:Kernel:Layout},...

Layer in/out buffer dumps

In some cases, you might want to get actual values in each layer execution to compare it with some reference blob. To do that, choose the OV_GPU_DUMP_TENSORS_PATH option in debug config. For the usage of debug config, see [link](#how-to-check-debug-config-works.

As a prerequisite, enable ENABLE_DEBUG_CAPS from the cmake configuration.

Then, check the runtime layer name by executing benchmark_app with OV_VERBOSE=1. It is better to check it with OV_VERBOSE=1 than through IR because this may be slightly different. OV_VERBOSE=1 will show the log of execution of each layer.

# As a prerequisite, enable ENABLE_DEBUG_CAPS from cmake configuration.
export OV_GPU_DUMP_TENSORS_PATH=path/to/dir
export OV_GPU_DUMP_LAYER_NAMES="layer_name_to_dump1 layer_name_to_dump2"
export OV_GPU_DUMP_TENSORS=out              # only out tensors should be saved

Dump files are named in the following convention:

${layer_name_with_underscores}_${src/dst}_${port_id}.txt

Each file contains a single buffer in a common planar format (bfyx, bfzyx, or bfwzyx), where each value is stored on a separate line. The first line in the file contains a buffer description, for example:

shape: [b:1, f:1280, x:1, y:1, z:1, w:1, g:1] (count: 1280, original format: b_fs_yx_fsv16)

For troubleshooting the accuracy, you may want to compare the results of GPU plugin and CPU plugin. For CPU dump, see Blob dumping

Checking OpenCL execution

OpenVINO GPU plugin runs on top of opencl. opencl-intercept-layer is a very handy tool to check opencl execution.

You can clone the repo and build it, you can use it to profile OpenVINO GPU plugin from various perspective. cliloader will be created when you build the repo. Here are some examples:

# See OpenCL call log
$ CLI_CallLogging=1 /path/to/cliloader /path/to/benchmark_app ...

# Profile device timing for kernel execution
$ CLI_DevicePerformanceTiming=1 /path/to/cliloader /path/to/benchmark_app ...

See also