# Correct First, Fast Second: What a Local 7B Code Model Can and Cannot Do for GPU Kernel Optimization

まず正確に、次に速く：GPUカーネル最適化で、ローカル7Bコードモデルにできることとできないこと

Jui-Chien Tsou, Po-Yi Wu · arXiv · 2026年11月9日

- **課題** KernelBenchの30個の作業を使い、GPUカーネル最適化において固定したローカル7Bコードモデルの相互作用戦略が、精度と速度にどう影響するかを比べます。
- **手法** 同じQwen2.5-Coder-7B-Instructを、zero-shot、guided、iterative、agenticの4つの方法で動かします。agenticでは役割分担と、LLMではないEvaluatorによる実行ベースの選択を使います。
- **結果** v2の修正とbest-of-nサンプリングにより、正答率が大きく上がりました。

## 問題設定：固定したローカル7Bモデルで何ができるか

この論文は、GPU上でPyTorchの演算子をカスタムCUDAカーネルに置き換える課題を扱っています。参照モジュールと機能的に同じ動作を保ったまま、より速いModelNewを作るには、coalescing、shared memory、occupancy、数値的な意味を同時に考える必要があり、専門的な作業です。既存の結果の多くは大規模な商用モデルに頼っています。そこで著者らは、ローカルで運用できる中規模の公開重みモデルを一つ固定し、プロンプトやエージェント構成が性能をどの程度変えるかを調べます。実験対象はQwen2.5-Coder-7B-Instructで、KernelBenchのlevel 1~3からそれぞれ10個ずつ、計30個の作業を使います。

この設定では、モデルは統制変数で、相互作用戦略が処理変数です。戦略は、zero-shot、profilingに基づくguidedプロンプト、実行フィードバックを使うiterativeな改善、そして同じモデルが4つの役割を担うagenticループの4つで構成されます。

## 4つの相互作用戦略の実際の動作

zero-shotは、元のKernelBenchプロンプトをgreedyデコーディングで一度だけ試すベースラインです。guidedは、参照モジュールをPyTorchプロファイラで計測し、CUDA時間の大きい上位の演算をプロンプトに入れます。そのうえで、行列積と畳み込みはcuBLAS/cuDNNに任せ、メモリアクセスがボトルネックになっている後続の演算をまとめて融合するよう規則を加えます。iterativeは、生成、コンパイル、正しさの検査、時間計測を最大3ターンまで繰り返し、短縮したエラーと時間の報告を次の生成に戻します。提出されるカーネルは、（正確、コンパイル、速度）の順位で選んだ最良のターンのものです。

agenticは、同じモデルを、Code Analyzer、RAG Researcher、Kernel Generator、Feedback Analyzerの4つの役割に、それぞれ異なるシステムプロンプトで割り当てます。そして、LLMではないEvaluatorがコンパイル、正しさ、速度を判定する構成です。RAG ResearcherはBM25を使い、CUDA最適化ノートのコーパスから文書を探して、引用できる要約を作ります。Kernel Generatorは、ターンごとにn個の候補をサンプリングします。最終的な選択は、LLMの判断ではなく、実行評価器の基準で行われます。

![Figure 1: The agentic loop. Four roles are the same Qwen2.5-Coder-7B-Instruct under different system prompts (blue); a non-LLM Evaluator (orange) compiles, che…](https://refivu.com/papers/c3b651b8-c1a1-4b1a-8100-f3f953172b20/figures/figure-c7527a9711dfe3d2c99b5a32ad36f273.png?thumb=512)

**Fig. 1** . The agentic loop. Four roles are the same Qwen2.5-Coder-7B-Instruct under different system prompts (blue); a non-LLM Evaluator (orange) compiles, checks, and times each candidate and closes the feedback loop. Generation is best-of-n(n=4); the loop runs at most three turns.

[出典](https://arxiv.org/abs/2611.12079v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Jui-Chien Tsou, Po-Yi Wu · Correct First, Fast Second: What a Local 7B Code Model Can and Cannot Do for GPU Kernel Optimization · 論文の図を引用 · 元のPDFの3ページ目から図の部分を抽出しています。

## 初期のagentic版の失敗とv2の修正が示すこと

v1の生成プロンプトは、load\_inlineまたはTritonを使ったカスタムカーネルを求めていました。分析段階でも、すべての作業にタイリングとshared memoryを勧めていました。その結果、モデルはコンパイルできない、過度に複雑なCUDAを生成し、フィードバックループは同じ過剰な設計の傾向を繰り返しました。

v2の修正は4つです。1つ目は、すべての役割が、まず正しくコンパイルできるカーネルを得るようにし、重い演算にはtorchの演算を使い、メモリがボトルネックになるエピローグだけを融合するようにしたことです。2つ目は、ターンごとにn=4の候補を温度0.7でサンプリングし、実際の評価器で順位を付けたことです。3つ目は、提出するカーネルをターン単位で単調に選ぶようにし、後から出てくる壊れた再試行が、先の正常なカーネルを押し出さないようにしたことです。4つ目は、各候補を240秒の時間制限付きの子プロセスで評価したことです。著者らは、この変更をもとに、失敗の原因をプロンプトの過剰な設計と、生成器の弱点との不一致として解釈しています。

## 全体の比較：guidedが全体の正答率で最も高い

このため、この結果では精度が主な差であり、高速なカーネルの割合も正答率と連動していました。

難易度別に見ると、結果が分かれます。L1では、zero-shotとguidedがそれぞれ9/10と10/10で、agenticは5/10でした。L2では、agenticだけが3/10を解決し、残りの方法は0/10でした。L3では、guidedが3/10を解決しました。この結果は、本論文の30個の作業とQwen2.5-Coder-7B-Instructで得られたものであり、すべての課題で一つの方法が優れているという意味ではありません。

## best-of-nサンプリングとテスト時計算

アブレーション実験で最も大きな変化は、best-of-nサンプリングを取り除いた場合に現れました。n=1に下げると、正答率は3%、コンパイル率は23%に下がります。著者らは、この結果を、サンプリングの幅が実行ベースの検証器のもとで働く重要な構成要素であることの証拠と解釈しています。n=1からn=2に増やすと正答率は大きく上がり、n=4からn=8では3%pの増加にとどまりました。

![Figure 2: Test-time-compute scaling: full agent, varying only candidates per turn ( n∈ {1,2,4,8}; evaluator keeps the best). Correctness: 3/27/30/33%; compile:…](https://refivu.com/papers/c3b651b8-c1a1-4b1a-8100-f3f953172b20/figures/figure-1dd0bd9a26c57fe79ee66c44ee5931af.png?thumb=512)

**Fig. 2** . Test-time-compute scaling: full agent, varying only candidates per turn ( n∈ {1,2,4,8}; evaluator keeps the best). Correctness: 3/27/30/33%; compile: 23/53/73/80%. The first doubling is transformative; returns then diminish.

[出典](https://arxiv.org/abs/2611.12079v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Jui-Chien Tsou, Po-Yi Wu · Correct First, Fast Second: What a Local 7B Code Model Can and Cannot Do for GPU Kernel Optimization · 論文の図を引用 · 元のPDFの3ページ目から図の部分を抽出しています。

この結果は、追加の推論ステップを増やすより、候補数を増やすテスト時計算の方が、この設定では効果的だったことを示しています。ただし、候補数を増やすと評価コストも増えるため、この結果はコストを考慮した計算配分の問題として捉えるべきです。

## 解釈の範囲と残る限界

著者らは、30個の作業、1つのモデル、1つのシードだけを使ったため、1~2問の差はノイズの範囲にある可能性があると説明しています。そのため本文では、3%から30%への回復、L2での0対3の差、best-of-nの曲線のような大きな効果を中心に解釈します。greedyデコーディングを使う3つの非サンプリング方法はほぼ決定的で、サンプリングによるばらつきは、best-of-nのスイープでのみ特徴づけられました。

実験はV100上でfp32を使って行われました。テンソルコアを備えたGPUでは、ライブラリの優位性の限界が変わる可能性があります。また、小型モデルに関する適合性の主張だけが示されています。速度の面では、正しいカーネルは概ねeager PyTorchと同程度か、やや遅い程度でした。そのため、この研究の実質的な成果は、主に正確さと融合の範囲から読み取るべきです。

## 論文情報

- **著者**: Jui-Chien Tsou, Po-Yi Wu
- **学会・ジャーナル**: arXiv · プレプリント
- **公開日**: 2026年11月9日
- **登録日**: 2026年11月10日
- **更新日**: 2026年11月9日
- **バージョン**: v1
- **arXiv**: 2611.12079
- **カテゴリ**: cs.LG
- **ライセンス**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **掲載内容**: 論文情報・解説・論文の図

[元論文 ↗](https://arxiv.org/abs/2611.12079v1) · [PDF ↗](https://arxiv.org/pdf/2611.12079v1)

この解説は、Refivuの韓国語解説をAIで翻訳したものです。不正確な翻訳や誤りが含まれる可能性があります。論文と図の利用条件は各出典に従います。

## アブストラクト

We study how much the interaction strategy around a fixed, locally hosted 7B-parameter code model (Qwen2.5-Coder-7B-Instruct) affects its ability to replace PyTorch operators with custom CUDA kernels. On 30 KernelBench tasks (levels 1-3, first 10 each, evaluated on a V100), we compare four regimes of increasing structure: zero-shot prompting, profiling-guided prompting, iterative refinement on execution feedback, and a multi-agent loop (analysis, retrieval, generation, evaluation, feedback triage) in which the same model fills four roles around a non-LLM evaluator. Three findings stand out. (1) Correctness, not speed, is the binding constraint: even correct generated kernels average 0.97-0.99x the speed of eager PyTorch, because a 7B model cannot out-write cuBLAS/cuDNN on dense GEMM and convolution; the only real wins are fused memory-bound epilogues. (2) The best strategy depends on difficulty: profiling-guided prompting is strongest overall (43% correct, 27% faster than baseline), but the agent loop is the only method that solves any level-2 fusion problem (3/10 vs. 0/10 for all others). (3) Naive agentic scaffolding is actively harmful: our first agent scored 3% correct, below zero-shot's 30%, and the decisive repairs were matching the agent's ambition to the model's competence and spending compute on best-of-n sampling under a real execution oracle (3% to 33% correct from n=1 to n=8), not on more reasoning steps.

## この論文を引用

Jui-Chien Tsou, Po-Yi Wu (2026). Correct First, Fast Second: What a Local 7B Code Model Can and Cannot Do for GPU Kernel Optimization. arXiv:2611.12079v1. https://arxiv.org/abs/2611.12079v1

**BibTeX**

```
@misc{tsou2026correct,
  title = {{Correct First, Fast Second: What a Local 7B Code Model Can and Cannot Do for GPU Kernel Optimization}},
  author = {Jui-Chien Tsou and Po-Yi Wu},
  year = {2026},
  eprint = {2611.12079},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.12079v1}
}
```

## この論文の用語

- [greedy decoding](https://refivu.com/ja/terms/668f299cabe4-greedy-decoding)
- [BM25](https://refivu.com/ja/terms/64437f95755a-bm25)
- [Evaluator](https://refivu.com/ja/terms/4622c64de267-evaluator)
- [KernelBench](https://refivu.com/ja/terms/6fc3485d844c-kernelbench)
- [test-time compute](https://refivu.com/ja/terms/9d5edc8be48b-test-time-compute)

## ほかの論文解説

- [Resolvent Ellipsoid for Minty Set Inclusions](https://refivu.com/ja/papers/8cb5bcbc-0a5f-4fb9-8209-9514493fb2e2-resolvent-ellipsoid-for-minty-set-inclusions.md)
- [Regularization Amplifies Subliminal Learning](https://refivu.com/ja/papers/22f59d9c-4e53-44c9-9218-a8bd14a07d28-regularization-amplifies-subliminal-learning.md)
- [Match the Geometry Before the Surrogate: Extreme Low-Budget Optimization in High Dimensions](https://refivu.com/ja/papers/ea26beb1-1e63-4a93-a52d-77652ffeed9b-match-the-geometry-before-the-surrogate-extreme-low.md)
- [From PAC bounds on the generalization error to PAC bounds on the parameter estimation error](https://refivu.com/ja/papers/be31eafc-e4b3-426e-82fb-d392655c0bce-from-pac-bounds-on-the-generalization-error-to.md)
- [Solver-Admitted Metamorphic Testing of Learned Network Optimization Surrogates](https://refivu.com/ja/papers/bf8267ce-e77f-4570-a90e-1101d0d6d31b-solver-admitted-metamorphic-testing-of-learned-network.md)
- [On Lipschitz Explosion in Deep Neural Networks with Normalization: Consequences for Optimization and Adversarial Robustness](https://refivu.com/ja/papers/14b86801-511c-455f-9d92-3f267fde363d-on-lipschitz-explosion-in-deep-neural-networks-with.md)
- [Visible Tails: Characterizing Adaptation to Unknown Moments in Heavy-Tailed Bandits](https://refivu.com/ja/papers/f1ae0061-cbfa-4dd3-986a-8c849211e378-visible-tails-characterizing-adaptation-to-unknown-moments.md)
- [Detecting Shadow AI: Unsanctioned LLM Agents on Enterprise Endpoints: A Taxonomy, an Open Detector and a Controlled Evaluation](https://refivu.com/ja/papers/d6ef6ddd-294d-4140-b0a2-5d7ea62a3a83-detecting-shadow-ai-unsanctioned-llm-agents-on-enterprise.md)
- [The Deception Archive as a repository of standardized datasets for large-scale verbal deception detection research](https://refivu.com/ja/papers/f95b76de-44ef-4fb8-8569-db8fbbd13737-the-deception-archive-as-a-repository-of-standardized.md)
- [An Empirical Evaluation of Quantum Kernel Stability in Network Intrusion Detection](https://refivu.com/ja/papers/58dc059a-63f4-417c-80ed-46b5079a40eb-an-empirical-evaluation-of-quantum-kernel-stability-in.md)
- [Unprompted coordination through shared memory in LLM agents: a locked two-implementation replication and extension](https://refivu.com/ja/papers/d722655f-18c6-4697-a00b-ffc70d0fe50f-unprompted-coordination-through-shared-memory-in-llm-agents.md)
- [Clinical predictions using artificial intelligence in neurosurgery and its subspecialties: a systematic review and meta-analysis](https://refivu.com/ja/papers/e3d3232e-f5e4-4019-b6d8-2c6086c313d0-clinical-predictions-using-artificial-intelligence-in.md)

---

AI解説には誤りが含まれることがあります。 [Refivu](https://refivu.com/ja/papers/c3b651b8-c1a1-4b1a-8100-f3f953172b20-correct-first-fast-second-what-a-local-7b)
