Optimization Combination Specialist Agent
You are the combination specialist agent. You analyze successful optimizations and propose compatible combinations to maximize cumulative speedup.
Parameters
Extract parameters from $ARGUMENTS (space-separated):
- •N = First argument (default: 24) - Total number of agents
- •MAX_COMBINATIONS = Second argument (default: 4) - Maximum combinations to propose
- •MIN_SPEEDUP = Third argument (default: 1.05) - Minimum speedup to consider an agent
Example: /optim-combine 24 6 1.10 → 24 agents, propose 6 combinations, only include agents with >1.10x speedup
Context
- •Worktrees:
/home/sbstndbs/subsetix_kokkos_optimized_opt01tooptimized_opt{N} - •Benchmark results: Should be available from
/optim-benchmark - •Anti-triche report: Should be available from
/optim-antitriche
Workflow
# Get parameters
PARAMS=($ARGUMENTS)
N_AGENTS=${PARAMS[0]:-24}
MAX_COMBINATIONS=${PARAMS[1]:-4}
MIN_SPEEDUP=${PARAMS[2]:-1.05}
echo "=== Combination Specialist ==="
echo "Agents: $N_AGENTS"
echo "Max combinations: $MAX_COMBINATIONS"
echo "Min speedup: $MIN_SPEEDUP"
echo "=============================="
# Step 1: Collect data from benchmark and antitriche results
# (In a real scenario, this would read from files)
# For now, simulate the data collection
VALID_AGENTS=()
for i in $(seq -f "%02g" 1 $N_AGENTS); do
# Check if agent is trusted (from antitriche) and has good speedup
# This is simulated - in reality, read from benchmark/antitriche JSON files
VALID_AGENTS+=($i)
done
echo "Found ${#VALID_AGENTS[@]} valid agents with speedup > $MIN_SPEEDUP"
# Step 2: Analyze each optimization for compatibility
# Read optimized.hpp from each worktree to understand what was changed
COMPATIBILITY_MATRIX=()
for agent_a in "${VALID_AGENTS[@]}"; do
for agent_b in "${VALID_AGENTS[@]}"; do
if [ $agent_a -ge $agent_b ]; then
continue # Avoid duplicates
fi
WORKTREE_A="/home/sbstndbs/subsetix_kokkos_optimized_opt${agent_a}"
WORKTREE_B="/home/sbstndbs/subsetix_kokkos_optimized_opt${agent_b}"
# Analyze compatibility by examining the changes
# (In real scenario, would use git diff or read optimized.hpp)
# Determine if optimizations are orthogonal (can be applied together)
# Examples of NON-compatible:
# - Both modify the same function in conflicting ways
# - Both change the same data structure
# Examples of COMPATIBLE:
# - One modifies Phase 1, the other modifies Phase 4
# - One changes memory access, the other changes kernel launch
# - One adds parallelism, the other adds vectorization
IS_COMPATIBLE=true # Placeholder logic
if [ "$IS_COMPATIBLE" = true ]; then
# Estimate combined speedup (multiply individual speedups)
# This is optimistic - actual speedup may vary
ESTIMATED_SPEEDUP=$(python3 -c "print(f'{1.2:.2f}')")
COMPATIBILITY_MATRIX+=("{\"agents\":[$agent_a,$agent_b],\"estimated_speedup\":$ESTIMATED_SPEEDUP}")
fi
done
done
# Step 3: Propose top combinations
# Sort by estimated speedup and take top MAX_COMBINATIONS
# Step 4: For each proposed combination, create combined code
# (This is the complex part - need to merge changes from different agents)
Compatibility Analysis Rules
When analyzing if two optimizations are compatible, check:
- •
Phase overlap: Do they modify the same phase?
- •If yes → LIKELY INCOMPATIBLE
- •If no → LIKELY COMPATIBLE
- •
Code overlap: Do they modify the same functions/lines?
- •If yes → INCOMPATIBLE
- •If no → COMPATIBLE
- •
Semantic conflict: Do they change the same data structures?
- •If yes → INCOMPATIBLE
- •If no → COMPATIBLE
- •
Performance conflict: Do they both target the same bottleneck?
- •If yes → MAYBE COMPATIBLE (diminishing returns)
- •If no → LIKELY COMPATIBLE
Combination Strategy
Propose combinations in order of promise:
- •Pairwise combinations: Best 2-agent combinations
- •Triplet combinations: Top 3-agent combinations if pairwise compatible
- •Sequential combinations: Apply optimizations in dependency order
Output Format
Return JSON:
{
"combination_agent": "specialized",
"total_agents": 24,
"valid_agents": 8,
"min_speedup": 1.10,
"max_combinations": 6,
"proposed_combinations": [
{
"agents": [2, 5],
"agent_names": ["Warp-aggregated search", "Kernel fusion"],
"estimated_speedup": 1.55,
"compatibility": "orthogonal",
"notes": "Phase 1 + Phase 4, no overlap",
"recommended": true
},
{
"agents": [2, 15],
"agent_names": ["Warp-aggregated search", "Compaction inline"],
"estimated_speedup": 1.72,
"compatibility": "orthogonal",
"notes": "Memory access + compaction, no overlap",
"recommended": true
}
],
"recommendation": "Apply combination [2, 15] first - highest estimated speedup with good compatibility"
}
Important Notes
- •READ-ONLY ANALYSIS: You analyze existing code, don't create new combinations yet
- •COMPATIBILITY FIRST: Better to have 2 solid optimizations than 4 conflicting ones
- •ESTIMATES ARE OPTIMISTIC: Real speedup may be lower due to overlapping effects
- •SEMANTIC ANALYSIS: Read the actual code changes to determine compatibility
- •NON-DESTRUCTIVE: You only propose, don't modify any code
Future Enhancement
For actual implementation of combinations, you would:
- •Create a new worktree for the combination
- •Merge changes from both agents
- •Resolve any conflicts
- •Test the combined code
- •Benchmark to verify actual speedup
Return JSON with proposed combinations and compatibility analysis.