OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[Skills] Debug skill: add transformations component (#35363)
Vladislav Golubevdf21653702b5
diff --git a/.claude/skills/debug-matcher-pass/SKILL.md b/.claude/skills/debug-matcher-pass/SKILL.mdindex bd2eeac25d8..a942132ff50 100644--- a/.claude/skills/debug-matcher-pass/SKILL.md+++ b/.claude/skills/debug-matcher-pass/SKILL.md@@ -1,6 +1,7 @@---name: debug-matcher-pass-description: Debug why an OpenVINO MatcherPass transformation is not firing. Use this skill immediately when a user says a transformation is "not applied", a "pass has no effect", a "matcher never triggers", a pattern "doesn't match", a "callback never fires", "WrapType predicate is too strict", a subgraph "not fused" despite the pass being registered, or they see "END: PATTERN DIDN'T MATCH" in matcher logs. Also trigger when a MatcherPass works on one model but silently skips another, when the user wants to add a reproducer test for a transformation that should fire but doesn't, or when they suspect an opset version mismatch preventing a match. Do NOT trigger for: writing a new MatcherPass from scratch, debugging a pass that fires but produces wrong numerical results, crashes in pass registration, or general questions about what MatcherPass is.+description: >+ Debug why an OpenVINO MatcherPass transformation is not firing. Use this skill immediately when a user says a transformation is "not applied", a "pass has no effect", a "matcher never triggers", a pattern "doesn't match", a "callback never fires", "WrapType predicate is too strict", a subgraph "not fused" despite the pass being registered, or they see "END: PATTERN DIDN'T MATCH" in matcher logs. Also trigger when a MatcherPass works on one model but silently skips another, when the user wants to add a reproducer test for a transformation that should fire but doesn't, or when they suspect an opset version mismatch preventing a match. Do NOT trigger for: writing a new MatcherPass from scratch, debugging a pass that fires but produces wrong numerical results, crashes in pass registration, or general questions about what MatcherPass is.---# Debug MatcherPass Skill@@ -15,6 +16,8 @@ Produce two deliverables before finishing:The only filesystem change should be the test file edit. Do not create additional output files.+**Early exit — all passes fired:** If Step 2a shows `CALLBACK SUCCEDED > 0` for every pass under investigation, skip Steps 3–6. Post a lightweight confirmation summary (use the "all fired" variant in the Diagnosis Report Template) and do not write a reproducer test. There is no bug to reproduce.+---## Step 0: Gather Prerequisites@@ -68,6 +71,42 @@ Additional env vars:- **`OV_MATCHERS_TO_LOG`** — comma-separated list of matcher names to filter (omit to log all matchers, which produces very large output).- **`OV_VERBOSE_LOGGING=true`** — prints additional node details (element type, shape, attributes); use when the basic log does not identify the failure clearly.+### Wait for the command to complete++Matcher logs are interleaved with normal output. If the command is long-running (e.g., model compilation on GPU), **wait for it to finish before analyzing**. Parsing a partial log will produce incorrect statistics (e.g., undercounting successful callbacks). Verify completion by checking for the final your_run_command output line or the process exit code.++---++## Step 2a: Collect Per-Pass Statistics++Before diving into detailed log analysis, run a quick tally to build an overview of which passes fired and how many times. This is especially important for **pipeline cascade** investigations with multiple passes.++Use this Python snippet (adjust the `pass_names` list):++```bash+python3 -c "+import re, sys+pass_names = ['PassA', 'PassB'] # <-- replace with actual pass names+with open('matcher.log') as f:+ content = f.read()+for p in pass_names:+ s = len(re.findall(rf'\[{p}\] END: PATTERN MATCHED, CALLBACK SUCCEDED', content))+ m = len(re.findall(rf'\[{p}\] END: PATTERN MATCHED', content))+ d = len(re.findall(rf'\[{p}\] END: PATTERN DIDN.T MATCH', content))+ print(f'{p}: CALLBACK SUCCEDED={s} MATCHED={m} DIDN\'T MATCH={d}')+"+```++Interpret the output:+- **CALLBACK SUCCEDED > 0** → pass fired and transformed nodes.+- **MATCHED > 0 but SUCCEDED = 0** → pattern matched but the callback returned `false` (check callback logic).+- **DIDN'T MATCH > 0 and MATCHED = 0** → pattern was attempted but never matched any node (proceed to Step 3 for root cause).+- **All counts = 0** → pass name not found in the log at all (not registered, or the pass is a `GraphRewrite` wrapper — log the inner `MatcherPass` names instead).++> **Note on `GraphRewrite` wrappers:** If a pass is a `GraphRewrite` that calls `add_matcher<InnerPass>()`, the matcher log will use the inner pass names, not the wrapper name. Check the header for inner pass names and use those in `OV_MATCHERS_TO_LOG`.++For pipeline cascades, use the tally to quickly classify each pass as ✅ fired / ❌ root cause / ❌ downstream casualty before spending time on detailed log analysis.+---## Step 3: Analyze the Log — Identify Root Cause@@ -128,6 +167,7 @@ Work inward through the nested blocks to find the deepest `}` labeled with a fai7. **Attribute value mismatch** — Pattern constrains an attribute (e.g., `group == 1`, `axis == 0`) that doesn't match the actual node.8. **Transformation was already applied** — Graph was modified by a symmetric or overlapping pass earlier; the target op no longer exists.9. **Wrong opset version** — Pattern uses `opset::OpX` but the frontend or a prior pass has already replaced it with a different version or a decomposed form.+10. **Argument count mismatch** — The graph node has a different number of inputs than the pattern expects (e.g., an op with shared-expert inputs has 23 inputs but the pattern only covers the 11-input or 13-input variant). Common when ops have multiple configurations (with/without bias, with/without shared experts).### 3e. No output at all from OV_MATCHER_LOGGING@@ -280,11 +320,11 @@ See [references/example-diagnosis-report.md](references/example-diagnosis-report<!-- If multiple passes were investigated, add this table: -->## Summary of passes-| Pass | Result |-|---|---|-| `PassA` | ✅ Fired (`CALLBACK SUCCEEDED`) |-| `PassB` | ❌ Did not fire — root cause |-| `PassC` | ❌ Did not fire — downstream: PassB never produced its expected input |+| Pass | Result | Callbacks | Matches |+|---|---|---|---|+| `PassA` | ✅ Fired | 40 | 40 |+| `PassB` | ❌ Did not fire — root cause | 0 | 0 |+| `PassC` | ❌ Did not fire — downstream casualty | 0 | 0 |**Root cause:** <one-sentence summary>**Log evidence:** `<exact log phrase that identified the failure>`@@ -297,6 +337,25 @@ Test name: `<TEST_F name>`Status before fix: PASS (transformation did not fire — model unchanged, matches auto-cloned ref; confirms bug reproduced)```+### All-fired variant (early exit)++When all passes fired successfully (Step 2a), use this shorter template instead:++```+## MatcherPass Diagnosis: <TransformationName(s)>++## Summary of passes+| Pass | Result | Callbacks | Matches |+|---|---|---|---|+| `PassA` | ✅ Fired | <N> | <N> |+| `PassB` | ✅ Fired | <N> | <N> |++**All transformations fired successfully.** No issues found.++## Reproducer Test+Not needed — no bug to reproduce.+```+---## Referencesdiff --git a/.claude/skills/debug/SKILL.md b/.claude/skills/debug/SKILL.mdindex c42898cd708..bab6c8f1bcb 100644--- a/.claude/skills/debug/SKILL.md+++ b/.claude/skills/debug/SKILL.md@@ -1,22 +1,24 @@---name: debug-description: Troubleshooting all sorts of failures, crashes, exceptions and errors using debug capabilities. Analyze accuracy, performance, or memory issues. Dump tensors and intermediate blobs. Serialize IRs, execution graphs. Enable verbose, logging. Profile execution. Compare layer outputs. Inspect, trace or dump transformations. Identify executed operations, nodes, primitives, kernels.+description: Troubleshooting all sorts of failures, crashes, exceptions and errors using debug capabilities. Analyze accuracy, performance, model compilation, or memory issues. Dump tensors and intermediate blobs. Serialize and visualize IRs, execution graphs. Enable verbose, logging. Profile execution. Compare layer outputs. Inspect, trace or dump transformations. Identify executed operations, nodes, primitives, kernels.---# Debug Skill## Prerequisites-Many debug env vars require the build flag `-DENABLE_DEBUG_CAPS=ON`.-Before suggesting env vars, verify the build was configured with this flag-(check CMakeCache.txt in the build dir).+Build flags that enable debug capabilities (check CMakeCache.txt in the build dir):+- `-DENABLE_DEBUG_CAPS=ON` — CPU/GPU plugin debug env vars+- `-DENABLE_OPENVINO_DEBUG=ON` — transformation matcher logging## Components-| Component | Reference file to read |-|---------------------------|---------------------------------------|-| openvino_intel_cpu_plugin | @components/debug-intel-cpu-plugin.md |-| openvino_intel_gpu_plugin | @components/debug-intel-gpu-plugin.md |+| Component | Reference file to read | Routing hints |+|---------------------------|---------------------------------------|-------------------------------------------------------------------------------|+| openvino_intel_cpu_plugin | @components/debug-intel-cpu-plugin.md | CPU: inference issues, wrong results, slow inference, tensor dumps, execution graphs |+| openvino_intel_gpu_plugin | @components/debug-intel-gpu-plugin.md | GPU: inference issues, wrong results, slow inference, tensor dumps, execution graphs |+| transformations | @components/debug-transformations.md | transformation not applied, pass not firing, slow compilation, graph inspection |## Steps-1. Identify the component (or multiple components), then load its reference file-2. Use the instructions and recommendations for debugging+1. Match the user's symptom to the routing hints above to identify the component(s)+2. Load the component's reference file+3. Follow the instructions and recommendations for debuggingdiff --git a/.claude/skills/debug/components/debug-transformations.md b/.claude/skills/debug/components/debug-transformations.mdnew file mode 100644index 00000000000..0deb5c0ce6c--- /dev/null+++ b/.claude/skills/debug/components/debug-transformations.md@@ -0,0 +1,17 @@+The debug and troubleshooting of OpenVINO transformations can be performed using various debug capabilities activated via environment variables.++# Prerequisites+Matcher logging requires `-DENABLE_OPENVINO_DEBUG=ON`. Verify in CMakeCache.txt before suggesting `OV_MATCHER_LOGGING`.++# Reference+Read `src/common/transformations/docs/debug_capabilities/README.md` — use the "When to use" guidance to match the observed problem to the right capability.++# Handoff+If the symptom is specifically a MatcherPass not firing (transformation not applied, pattern not matching, callback never called), hand off to the `/debug-matcher-pass` skill — it provides a deeper automated diagnosis workflow with matcher log analysis and reproducer test generation.++# Steps+1. Read the debug capabilities README+2. Match the observed symptom to the relevant "When to use" entries+3. If the issue is a MatcherPass not firing — invoke `/debug-matcher-pass` instead of continuing+4. Read the linked detail doc for the chosen capability+5. Use suitable environment variablesdiff --git a/src/common/transformations/docs/debug_capabilities/README.md b/src/common/transformations/docs/debug_capabilities/README.mdnew file mode 100644index 00000000000..3c0eb6ea317--- /dev/null+++ b/src/common/transformations/docs/debug_capabilities/README.md@@ -0,0 +1,25 @@+# Debug capabilities+Debug capabilities are the set of useful debug features for OpenVINO transformations, controlled by environment variables.++They can be activated at runtime and are useful for analyzing transformation behavior, profiling pass execution, and inspecting model state between passes.++* [Matcher logging](matcher_logging.md)+ When to use: a MatcherPass transformation is not firing or matching unexpectedly — logs the pattern matching process to show why matches succeed or fail.+ Requires: `-DENABLE_OPENVINO_DEBUG=ON`+ Example: `OV_MATCHER_LOGGING=true OV_MATCHERS_TO_LOG=EliminateSplitConcat ./your_program`++* [Transformation profiling](transformation_profiling.md)+ When to use: slow model compilation or need to identify which transformation passes take the most time.+ Example: `OV_ENABLE_PROFILE_PASS=true`++* [Model visualization](model_visualization.md)+ When to use: need to see the model graph structure after specific passes — generates .svg files.+ Example: `OV_ENABLE_VISUALIZE_TRACING=true` or `OV_ENABLE_VISUALIZE_TRACING="Pass1,Pass2"`++* [Model serialization](model_serialization.md)+ When to use: need to inspect model IR (.xml/.bin) after specific passes — useful for diffing model state before and after a transformation.+ Example: `OV_ENABLE_SERIALIZE_TRACING=true` or `OV_ENABLE_SERIALIZE_TRACING="Pass1,Pass2"`++## See also++* [debug-matcher-pass skill](../../../../.claude/skills/debug-matcher-pass/SKILL.md) — automated diagnosis workflow for MatcherPass transformations that are not firing. Collects matcher logs, identifies root cause, and generates a reproducer test.diff --git a/src/common/transformations/docs/debug_capabilities/model_serialization.md b/src/common/transformations/docs/debug_capabilities/model_serialization.mdnew file mode 100644index 00000000000..a9e00dabf86--- /dev/null+++ b/src/common/transformations/docs/debug_capabilities/model_serialization.md@@ -0,0 +1,19 @@+# Model serialization++Enables serialization of the model to .xml/.bin after each transformation pass.++## Usage++Set the `OV_ENABLE_SERIALIZE_TRACING` environment variable to `"true"`, `"on"` or `"1"` to enable serialization for all transformations.++### Filtering++You can specify filters to control which passes are serialized.+If the variable is set to a specific filter string (e.g., `"PassName"`, `"PassName1,PassName2"`),+only transformations matching that filter will be serialized. Delimiter is `,`.++Example:+```+export OV_ENABLE_SERIALIZE_TRACING=true+export OV_ENABLE_SERIALIZE_TRACING="Pass1,Pass2,Pass3"+```\ No newline at end of filediff --git a/src/common/transformations/docs/debug_capabilities/model_visualization.md b/src/common/transformations/docs/debug_capabilities/model_visualization.mdnew file mode 100644index 00000000000..67dfa0b9f9a--- /dev/null+++ b/src/common/transformations/docs/debug_capabilities/model_visualization.md@@ -0,0 +1,19 @@+# Model visualization++Enables visualization of the model to .svg file after each transformation pass.++## Usage++Set the `OV_ENABLE_VISUALIZE_TRACING` environment variable to `"true"`, `"on"` or `"1"` to enable visualization for all transformations.++### Filtering++You can specify filters to control which passes are visualized.+If the variable is set to a specific filter string (e.g., `"PassName"`, `"PassName1,PassName2"`),+only transformations matching that filter will be visualized. Delimiter is `,`.++Example:+```+export OV_ENABLE_VISUALIZE_TRACING=true+export OV_ENABLE_VISUALIZE_TRACING="Pass1,Pass2,Pass3"+```diff --git a/src/common/transformations/docs/debug_capabilities/transformation_profiling.md b/src/common/transformations/docs/debug_capabilities/transformation_profiling.mdnew file mode 100644index 00000000000..08cd48342c1--- /dev/null+++ b/src/common/transformations/docs/debug_capabilities/transformation_profiling.md@@ -0,0 +1,14 @@+# Transformation profiling++Enables profiling of transformation passes to log their execution times.++## Usage++Set the `OV_ENABLE_PROFILE_PASS` environment variable to `"true"` to enable profiling.+Alternatively, specify a file path where the execution times will be saved.++Example:+```+export OV_ENABLE_PROFILE_PASS=true+export OV_ENABLE_PROFILE_PASS="/path/to/save/profiling/results"+```diff --git a/src/common/transformations/docs/debug_capabilities/transformation_statistics_collection.md b/src/common/transformations/docs/debug_capabilities/transformation_statistics_collection.mddeleted file mode 100644index e8457af464b..00000000000--- a/src/common/transformations/docs/debug_capabilities/transformation_statistics_collection.md+++ /dev/null@@ -1,43 +0,0 @@-# Transformation statistics collection and visualization--There are 3 environment variables which can be set for Transformations debugging:--1. OV_ENABLE_PROFILE_PASS - Enables profiling of transformation passes to log their execution times.--- Usage: Set this environment variable to "true" to enable visualizations.- Alternatively, specify a file path where the execution times will be saved.-- Example:- export OV_ENABLE_PROFILE_PASS=true- export OV_ENABLE_PROFILE_PASS="/path/to/save/profiling/results"---2. OV_ENABLE_VISUALIZE_TRACING - Enables visualization of the model to .svg file after each transformation pass.--- Usage: Set this environment variable to "true", "on" or "1" to enable visualization for all Transformations.-- Filtering: You can specify filters to control which passes are visualized.- If the variable is set to a specific filter string (e.g., "PassName", "PassName1,PassName2"),- only transformations matching that filter will be visualized. Delimiter is ",".-- Example:- export OV_ENABLE_VISUALIZE_TRACING=true- export OV_ENABLE_VISUALIZE_TRACING="Pass1,Pass2,Pass3"---3. OV_ENABLE_SERIALIZE_TRACING - Enables serialization of the model to .xml/.bin after each transformation pass.--- Usage: Set this environment variable to "true", "on" or "1" to enable serialization for all Transformations.-- Filtering: You can specify filters to control which passes are serialized.- If the variable is set to a specific filter string (e.g., "PassName", "PassName1,PassName2"),- only transformations matching that filter will be serialized. Delimiter is ",".-- Example:- export OV_ENABLE_SERIALIZE_TRACING=true- export OV_ENABLE_SERIALIZE_TRACING="Pass1,Pass2,Pass3"--If you have suggestions for improvements or encounter any issues with statistics collection, feel free to submit your feedback or contact Ivan Tikhonov <[email protected]>\ No newline at end of file