# Optimization Profile: {kernel}

> Generated by Profiler Agent (Stage 1)
> Date: {date}

## Kernel Identity

| Field | Value |
|-------|-------|
| Kernel Name | `{kernel}` |
| Source File | `src/liger_kernel/ops/{kernel}.py` |
| Benchmark Script | `benchmark/scripts/benchmark_{kernel}.py` |
| Test File | `test/transformers/test_{kernel}.py` |
| Tier Classification | {tier} ({tier_description}) |

## GPU Information

| Property | Value |
|----------|-------|
| GPU Name | {gpu_name} |
| Architecture | {gpu_arch} (SM {sm_version}) |
| SM Count | {sm_count} |
| Total Memory | {gpu_memory_gb} GB |
| Target GPU (user-specified) | {target_gpu} |
| Hardware Match | {hardware_match} |

## Baseline Benchmarks

### Speed (median ms)

| x_value | Mode | {kernel} (Liger) | {baseline_provider} | Speedup |
|---------|------|-------------------|----------------------|---------|
| {x_val_1} | forward | {liger_fwd_1} | {baseline_fwd_1} | {speedup_fwd_1}x |
| {x_val_1} | backward | {liger_bwd_1} | {baseline_bwd_1} | {speedup_bwd_1}x |
| {x_val_1} | full | {liger_full_1} | {baseline_full_1} | {speedup_full_1}x |
| {x_val_2} | forward | {liger_fwd_2} | {baseline_fwd_2} | {speedup_fwd_2}x |
| {x_val_2} | backward | {liger_bwd_2} | {baseline_bwd_2} | {speedup_bwd_2}x |
| {x_val_2} | full | {liger_full_2} | {baseline_full_2} | {speedup_full_2}x |
| ... | ... | ... | ... | ... |

### Memory (median MB)

| x_value | {kernel} (Liger) | {baseline_provider} | Savings |
|---------|-------------------|----------------------|---------|
| {x_val_1} | {liger_mem_1} | {baseline_mem_1} | {mem_savings_1}% |
| {x_val_2} | {liger_mem_2} | {baseline_mem_2} | {mem_savings_2}% |
| ... | ... | ... | ... |

### Observations

- Slowest mode: {slowest_mode} ({slowest_mode_reason})
- Largest x_value tested: {largest_x_val}
- Performance scaling trend: {scaling_trend}

## NCU Profiling Summary

> Status: {ncu_status}

{ncu_available_section_start}

| Metric | Value | Assessment |
|--------|-------|------------|
| SM Occupancy | {sm_occupancy}% | {occupancy_assessment} |
| Compute Throughput | {compute_throughput}% of peak | {compute_assessment} |
| Memory Throughput | {memory_throughput}% of peak | {memory_assessment} |
| L1 Cache Hit Rate | {l1_hit_rate}% | {l1_assessment} |
| L2 Cache Hit Rate | {l2_hit_rate}% | {l2_assessment} |

### Top Warp Stall Reasons

1. {warp_stall_1} ({warp_stall_pct_1}%)
2. {warp_stall_2} ({warp_stall_pct_2}%)
3. {warp_stall_3} ({warp_stall_pct_3}%)

{ncu_available_section_end}

{ncu_unavailable_section_start}

NCU is not available on this system. Bottleneck classification is based on code heuristics only.

{ncu_unavailable_section_end}

## Bottleneck Classification

**Classification: {bottleneck_class}**

### Evidence

| Signal | Observation | Supports |
|--------|-------------|----------|
| {evidence_signal_1} | {evidence_obs_1} | {evidence_supports_1} |
| {evidence_signal_2} | {evidence_obs_2} | {evidence_supports_2} |
| {evidence_signal_3} | {evidence_obs_3} | {evidence_supports_3} |
| ... | ... | ... |

### Reasoning

{bottleneck_reasoning}

## Current Configuration Analysis

| Parameter | Current Value | How Set | Notes |
|-----------|--------------|---------|-------|
| BLOCK_SIZE | {block_size} | {block_size_source} | {block_size_notes} |
| num_warps | {num_warps} | {num_warps_source} | {num_warps_notes} |
| num_stages | {num_stages} | {num_stages_source} | {num_stages_notes} |
| Grid Dimensions | {grid_dims} | {grid_dims_source} | {grid_dims_notes} |

### Memory Access Patterns

- Stride pattern: {stride_pattern}
- Cache modifiers: {cache_modifiers}
- In-place operations: {in_place_ops}
- Saved for backward vs recomputed: {save_vs_recompute}

### Compute Patterns

- Precision-sensitive ops: {precision_ops}
- Casting mode: {casting_mode}
- Algorithm type: {algorithm_type}
- constexpr parameters: {constexpr_params}

## Identified Optimization Opportunities

{opportunity_list}

## Recommended Strategy Order

Based on the bottleneck classification ({bottleneck_class}) and kernel analysis:

{strategy_order}

### Estimated Iterations

- Expected variants: {estimated_variants}
- Rationale: {variants_rationale}

---

*Profile saved to `optimization/{kernel}/profile.md`*
