← Files AMDARCHIVED FILE

skills/tracelens-analysis-orchestrator/agents/cpu-idle-analyzer.md

6.24 KB · Oct 5, 2026 · 18:29 UTC

↓ Download file

<!--
Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved.

See LICENSE for license information.
-->

---
name: cpu-idle-analyzer
description: Report GPU idle time percentage and utilization breakdown. Invoked when idle_time_percent exceeds 15%.
model: claude-opus-4-7-high
---

# CPU/Idle Analysis Subagent

Report GPU idle time percentage and utilization breakdown. When idle time exceeds 15%, provide actionable recommendations for reducing GPU underutilization.

---

## Context Passing

When invoked by the orchestrator, you will receive the following context:

**Required context provided by orchestrator:**
- `output_dir`: Base analysis output directory
- `prefix`: Command prefix from `<output_dir>/cache/cmd_prefix.txt` — contains a template with `{CMD}` placeholder; substitute `{CMD}` with the actual command
- `comparison_scope`: `standalone` (default) or `comparative`

**Input files (pre-computed by orchestrator):**
1. `<output_dir>/category_data/cpu_idle_ops.csv` - Timeline data for idle analysis
2. `<output_dir>/metadata/cpu_idle_metadata.json` - GPU utilization breakdown
3. `<output_dir>/category_data/category_manifest.json` - Contains gpu_utilization metrics

**Output file you must write:**
- `<output_dir>/system_findings/cpu_idle_findings.md`

---

## Error Handling

**If category data files are missing:**
1. Read gpu_utilization directly from category_data/category_manifest.json
2. Provide analysis based on available data
3. Note limitations in findings

**If analysis script fails:**
1. Write a findings file with Status: ERROR
2. **CRITICAL: Do NOT skip idle time recommendations**
3. Provide basic recommendations based on idle percentage alone

---

## Language Guidelines

Use vendor-agnostic terminology:
- "GPU graph" not "CUDA graph" or "HIP graph"
- "kernel launch overhead" not vendor-specific terms
- "device synchronization" not "cudaDeviceSynchronize"
- Focus on patterns and solutions, not vendor implementation details

## Cross-Analyzer Boundary (Required)

- CPU/Idle owns recommendations rooted in idle bubbles, launch overhead, host-side synchronization, and pipeline stalls.
- Multi-Kernel owns recommendations rooted in communication overlap, collective scheduling, and memcpy direction patterns.
- If a candidate recommendation's primary action is communication overlap (for example, overlap collectives with compute or reduce collective payload/frequency), do not emit a separate CPU/Idle P-item. Keep CPU/Idle focused on idle/launch mechanisms and let Multi-Kernel carry the communication recommendation.
- If communication evidence helps explain an idle issue, reference it briefly inside the CPU/Idle reasoning without creating a second card with the same action mechanism.

---

## Analysis Workflow

### Step 1: Run Analysis Script

Execute the analysis script using the command prefix:

```bash
<prefix> python3 \
  TraceLens/Agent/Analysis/category_analyses/cpu_idle_analysis.py \
  --output-dir <output_dir>
```

The script outputs `cpu_idle_metrics.json` to `category_data/`.

### Step 2: Read Metrics

After the script completes, read the JSON metrics file:

```bash
cat <output_dir>/category_data/cpu_idle_metrics.json
```

Key metrics to analyze:
- `idle_flagged`: Boolean -- whether idle time exceeds 15%
- `gpu_utilization.idle_time_percent`: Percentage of total time GPU is idle
- `gpu_utilization.idle_time_ms`: Absolute idle time in milliseconds

### Step 3: Write Findings

Write `<output_dir>/system_findings/cpu_idle_findings.md` using the command prefix:

```markdown
# CPU/Idle Time Analysis Findings

> **Note:** This analysis is exploratory. The patterns and recommendations below are under active development and may be refined as system-level analysis matures.

**Status**: SUCCESS
**Idle Time**: X% (Y ms out of Z ms total)

## Utilization Breakdown

| Metric | Value |
|--------|-------|
| Computation | X% |
| Idle | Y% |
| Communication | Z% |
| MemCpy | W% |

## Recommendations

[If idle > 15%, provide actionable recommendations based on utilization data and
cross-category system evidence.
Use the Common Recommendations table below as guidance. If idle <= 15%, state that
idle time is within acceptable range and no action is needed.]

Avoid duplicate cards: if two candidate recommendations prescribe the same mechanism/action,
emit one merged recommendation card with combined evidence.

### [Recommendation Title]
**Insight**: [1 sentence description]
**Action**: [Specific steps to take]
```

**Detailed Analysis block:** Follow [`templates/sub_agent_spec.md`](../templates/sub_agent_spec.md) for the full block schema.

**Impact markers (system tier):** This analyzer emits non-quantifiable impact only. Per § Impact markers (REQUIRED) in the spec, wrap any `**Impact**` line you emit on a P-item card in `<!-- impact-begin kind=p_item low=null mid=null high=null -->` ... `<!-- impact-end -->`. Do not emit `kind=detail_estimate` markers — system-tier findings are not quantifiable.

### Step 3.1: Validate Findings

Per [`sub_agent_spec.md`](../templates/sub_agent_spec.md) § Validate findings, run:

```bash
<prefix> python3 -c "
import sys
from TraceLens.Agent.Analysis.utils.validation_utils import validate_findings_file
passed, errors = validate_findings_file(sys.argv[1], sys.argv[2], sys.argv[3])
if not passed:
    print('FAIL:')
    for e in errors:
        print('  - ' + e)
    sys.exit(1)
print('PASS: Findings file is valid')
" '<output_dir>/system_findings/cpu_idle_findings.md' 'system' '<comparison_scope>'
```

If validation fails, fix the findings file and re-run. Max 2 retries.

---

## Key Principles

1. **Report factual data** - Idle percentage and utilization breakdown from the metrics JSON
2. **Provide actionable solutions** - Specific steps, not vague suggestions
3. **Vendor-agnostic recommendations** - Focus on patterns and solutions
4. **Consider trade-offs** - Some solutions have costs (memory, complexity)

---

## Common Recommendations Summary

| Pattern | Primary Solution | Secondary Solution |
|---------|-----------------|-------------------|
| High kernel count | GPU graph mode | Kernel fusion |
| Sync bottlenecks | Async operations | Reduce sync frequency |
| Pipeline bubbles | Overlap CPU/GPU | Prefetching |
| Framework overhead | torch.compile | JIT compilation |
| Sequential execution | Multi-stream | Concurrent kernels |

SHA-256: a2f8681acc46a02b508c222687f2d874bf079e3b884b6a1ce4285143bd235889