Hardware Counter Guided Reinforcement Learning for Assembly and Kernel Superoptimization
Optimize low-level assembly code and GPU kernels using reinforcement learning rewarded by real-time hardware performance counters to prevent language models from copying unoptimized input code.
Time
Compute level
Resources
What the paper used
Prerequisites
Scope
The Gap
Section 6.1 highlights that on SuperCoder, 83% of failure cases reduce to the model simply copying the input x86-64 assembly without modification, while 33% of KernelBench failures produce functionally correct kernels that fail to achieve any speedup over baseline PyTorch implementations.
“on SuperCoder 83% of failures reduce to the model simply copying the input x86-64 assembly without modification.”
Limitation
Standard cross-entropy SFT and direct solution fine-tuning do not teach models microarchitectural performance reasoning, causing the model to collapse to conservative identity copies rather than attempting risky speedup transformations like instruction reordering or loop unrolling.
Proposed Solution
Implement an online reinforcement learning framework (e.g., PPO or GRPO) where reward signals are directly computed from hardware execution metrics. Combine a binary functional correctness reward with a continuous performance reward derived from CPU hardware counters (`perf` instruction-per-cycle, cache miss ratios) and GPU profiling counters (warp execution efficiency, memory bandwidth utilization). Include explicit assembly instruction mutation primitives to force exploration beyond the identity transformation.
The paper’s authors list this direction as future work, so they may already be pursuing it.
Why This Matters
Would transform code LLMs from conservative syntax transformers into active superoptimizers capable of discovering non-trivial low-level performance gains in assembly and GPU kernels.
How to Get Started
How to test it: Train on the SuperCoder dataset using GRPO and evaluate average execution speedup over `gcc -O3`. Stop if the RL agent fails to achieve at least a 10% speedup on >30% of assembly benchmarks compared to baseline SFT.
- Download the SuperCoder x86-64 assembly benchmark dataset (8,072 programs).
- Set up an automated Linux environment executing code under pinned CPU core affinity with `perf stat` hardware counter logging.
- Formulate a reward function penalizing identity outputs and rewarding functional pass + IPC speedup over GCC -O3.
- Fine-tune InCoder-32B or a smaller base code model using GRPO and track optimization rate over training steps.
Suggested by AI. Adapt it to your setup.
Has This Been Done?
AsmEvo: Agentic Assembly-Level Optimization of AMD GPU Kernels with Functional Equivalence Verification explores assembly-level optimization using agents, while SIP: Autotuning GPU Native Schedules via Stochastic Instruction Perturbation investigates instruction perturbation. However, using online reinforcement learning with reward signals computed directly from hardware execution metrics and performance counters with assembly mutation primitives is only partially covered.
- AsmEvo: Agentic Assembly-Level Optimization of AMD GPU Kernels with Functional Equivalence Verification · 2026 · 1 citations
- SIP: Autotuning GPU Native Schedules via Stochastic Instruction Perturbation · 2024 · 0 citations
We searched OpenAlex and arXiv for “assembly superoptimization reinforcement learning hardware performance counters GPU kernel optimization” and “Hardware Counter Guided Reinforcement Learning for Assembly and Kernel Superoptimization” and an AI compared the idea with the top 10 results. A small search can miss relevant work.
Source Paper
InCoder-32B: Code Foundation Model for Industrial ScenariosJian Yang, Wei Zhang, Jiajun Wu +25 more · 2026
This paper presents InCoder-32B, a 32-billion parameter code foundation model designed specifically for industrial software engineering tasks across chip design, GPU kernel optimization, embedded C programming, compiler assembly optimization, and parametric 3D CAD modeling. The authors introduce a three-stage Code-Flow training pipeline comprising curated pre-training with technical manual OCR data, mid-training with context extension up to 128K tokens using synthetic reasoning data, and post-training grounded in containerized execution environments. Across 14 general and 9 industrial benchmarks, InCoder-32B outperforms existing open-weight models on specialized tasks while maintaining high competitive performance on standard coding benchmarks.
Related Ideas
- Compiling Stochastic Agent Skills into Deterministic Unit-Tested Sub-ProgramsThe Resolution Hypothesis: Agent Evolution's Key Is Identifying Improvements🔴Hard
- Integration of Online Reinforcement Learning (PPO/GRPO)BitNet b1.58 2B4T Technical Report🟠Medium
- Roofline-Anchored Hardware Counter Feedback to Break the Kernel Optimization CeilingAscendGYM: A Cost-Aware Kernel Optimization Benchmark for Real-World Workloads on Ascend NPUs🟠Medium
- Workload-Adaptive Dynamic Expert Caching for Hybrid GPU-CPU On-Device ExecutionClover-35B-A3B-Preview Technical Report🟡Fairly easy
- Retrieval-Augmented Feedback for Code GenerationGEPA: Reflective Prompt Evolution Can Outperform Reinforcement Learning🟠Medium