kernel-env / index.html
Shreyansh327's picture
Publish OpenEnv kernel environment and bounded GRPO proof artifacts
e313085 verified
Raw History Blame Contribute Delete
10.1 kB
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Kernel Env · OpenEnv GPU kernel RL</title><style>
:root{--bg:#f6f7f5;--surface:#fff;--ink:#1b211e;--muted:#5d6862;--line:#d9ded9;--accent:#0d6b5f;--code:#eef1ee;--green:#e3f3e6;--purple:#795cb8;color-scheme:light}
@media(prefers-color-scheme:dark){:root{--bg:#121614;--surface:#1a201d;--ink:#e3e8e4;--muted:#9aa59f;--line:#2c3430;--accent:#4fc2ae;--code:#161b18;--green:#173322;--purple:#b29bf7;color-scheme:dark}}
*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink);font:16px/1.65 system-ui,-apple-system,sans-serif}main{max-width:1120px;margin:auto;padding:36px 24px 80px}h1,h2,h3{line-height:1.2;letter-spacing:-.025em}h1{font-size:clamp(30px,5vw,48px);max-width:850px;margin:14px 0}h2{font-size:27px;margin:0 0 16px}h3{font-size:18px;margin:0 0 10px}p{margin:10px 0}.eyebrow{color:var(--accent);font:600 12px ui-monospace,monospace;text-transform:uppercase;letter-spacing:.1em}.sub,.note{color:var(--muted)}.sub{font-size:18px;max-width:850px}.note{font-size:13px}a{color:var(--accent)}nav{display:flex;gap:20px;flex-wrap:wrap;padding:16px 0;border-block:1px solid var(--line);margin:24px 0 36px}.jump{gap:8px 20px;font-size:13px;border:0;margin:0 0 36px;padding:0}section{margin:0 0 48px;scroll-margin-top:20px}.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:18px}.card{background:var(--surface);border:1px solid var(--line);border-radius:8px;padding:22px}.callout{border-left:4px solid var(--accent);background:var(--surface);padding:18px 22px;margin:24px 0}.number{font-size:34px;line-height:1.15;font-weight:650;color:var(--accent)}.diagram{overflow-x:auto;background:var(--surface);border:1px solid var(--line);border-radius:8px;padding:16px}.diagram svg{display:block;width:100%;min-width:760px}.diagram text{fill:var(--ink);font-family:system-ui,sans-serif}.diagram .box{fill:var(--code);stroke:var(--line);stroke-width:1.5}.diagram .gpu{fill:none;stroke:var(--accent);stroke-width:2;stroke-dasharray:6 5}.diagram .arrow{fill:none;stroke:var(--accent);stroke-width:2;marker-end:url(#arrow)}.diagram .muted{fill:var(--muted);font-size:13px}.flow{display:grid;grid-template-columns:repeat(auto-fit,minmax(145px,1fr));gap:10px;margin:20px 0}.flow div{padding:18px;background:var(--surface);border:1px solid var(--line);border-top:3px solid var(--accent);border-radius:5px}.flow b{display:block;font-size:13px;color:var(--accent);margin-bottom:5px}table{border-collapse:collapse;width:100%;font-size:14px}td,th{text-align:left;padding:11px 12px;border-bottom:1px solid var(--line);vertical-align:top}th{color:var(--muted);font-size:12px;text-transform:uppercase;letter-spacing:.04em}.scroll{overflow:auto}code{background:var(--code);font:13px ui-monospace,monospace;padding:2px 5px;border-radius:3px}pre{background:var(--code);padding:20px;overflow:auto;border-radius:6px;font:14px/1.7 ui-monospace,monospace}.formula{font-size:clamp(16px,2.4vw,23px);font-family:ui-monospace,monospace;margin:16px 0}.metric{color:var(--accent);font-weight:600}input[type=range]{width:100%;accent-color:var(--accent)}.result{display:flex;justify-content:space-between;gap:18px;flex-wrap:wrap;padding:16px 0}label{display:block}.tag{border:1px solid var(--accent);color:var(--accent);padding:2px 8px;border-radius:3px;font-size:12px}li{margin:8px 0}footer{border-top:1px solid var(--line);padding-top:20px;font-size:13px;color:var(--muted)}
</style></head><body><main><div class="eyebrow">Kernel Env / OpenEnv / Free static release</div>
<h1>GPU execution feedback for better kernel generation.</h1>
<p class="sub">An OpenEnv environment, a trained LoRA adapter, and the evidence from a small real-GPU experiment.</p>
<nav aria-label="Sections"><a href="#run">Run the environment</a><a href="#architecture">How it works</a><a href="#results">Measured results</a><a href="https://huggingface.co/Shreyansh327/Qwen2.5-Coder-7B-KernelEnv-GRPO-16">Trained model ↗</a><a href="https://huggingface.co/spaces/Shreyansh327/kernel-env/tree/main">Source files ↗</a></nav>
<div class="callout"><strong>Free static hosting · no GPU server here.</strong><p>This Space publishes the environment source, Docker recipe and documentation. It does not execute submitted kernels, expose a live OpenEnv API, run model inference, or allocate paid resources. Run the downloaded environment on your own NVIDIA GPU.</p></div>
<section id="run"><h2>Run the real environment</h2><p>Download the <a href="./kernel-env-source.tar.gz" download>source bundle</a>, or clone the Space repository. You need Docker and NVIDIA Container Toolkit on a CUDA-capable host.</p><pre>git clone https://huggingface.co/spaces/Shreyansh327/kernel-env
cd kernel-env
docker build -t kernel-env:latest .
docker run --rm --gpus all -p 127.0.0.1:8000:8000 kernel-env:latest</pre><p>The service starts on <code>http://127.0.0.1:8000</code>. Test it from another shell:</p><pre>python -m pip install 'openenv-core[core]==0.3.0' ./kernel_env
python examples/client_smoke.py --url http://127.0.0.1:8000</pre><p>The smoke example resets a ReLU task, saves its prompt to <code>task_prompt.txt</code>, submits a real Triton implementation and requires a correct GPU result. The static Space URL cannot be used as this client's API endpoint.</p><p class="note">Keep execution private and isolated: source checks and worker subprocesses are not a general security sandbox for native code. The release Dockerfile was statically checked; its full image was not built locally. Its evaluator source previously passed 116 real-GPU tests.</p></section>
<section id="architecture"><h2>From a reference task to a policy update</h2><div class="flow"><div><b>01 / TASK</b>OpenEnv reset returns the PyTorch reference and rules.</div><div><b>02 / GENERATE</b>The coding policy writes a complete Triton or CUDA module.</div><div><b>03 / EXECUTE</b>Checks → compile → hidden-seed correctness → GPU timing.</div><div><b>04 / REPAIR</b>Feedback lets the model revise within the episode budget.</div><div><b>05 / LEARN</b>GRPO compares returns and updates LoRA weights.</div></div>
<div class="grid"><div class="card"><h3>OpenEnv server</h3><p>WebSocket sessions, typed actions and observations, per-episode state and reward rubrics.</p></div><div class="card"><h3>GPU evaluator</h3><p>Fresh worker subprocesses, static checks, numerical controls, synchronized timing and timeouts.</p></div><div class="card"><h3>Model trainer</h3><p>The proof used a separate H100 for generation/training and another H100 for kernel evaluation.</p></div></div>
<h3 style="margin-top:24px">Correctness-gated reward</h3><pre>incorrect kernel → reward 0
correct kernel → 0.3 + 2.7 × min(t_min / t_kernel, 1)
episode return → reward₁ + 0.4 × reward₂</pre><p><code>t_min</code> estimates the hardware roofline floor. A correct kernel can earn reward without beating PyTorch. Feedback tokens are masked from the loss; generated tokens carry episode-level GRPO advantages. This pilot does not reproduce full staged actor–critic PPO or implement TRLOO.</p></section>
<section id="results"><h2>What the small run showed</h2><div class="grid"><div class="card"><div class="number">5/10 → 6/10</div><p>Correct tasks, matched greedy evaluation with two attempts.</p></div><div class="card"><div class="number">16 updates</div><p>Four recorded epochs, 64 training episodes, 128 training submissions.</p></div><div class="card"><div class="number">0/3 → 1/3</div><p>Official held-out tasks solved; the new success was GELU.</p></div></div>
<div class="scroll" style="margin-top:24px"><table><thead><tr><th>Task group</th><th>Before</th><th>After</th></tr></thead><tbody><tr><td>Training: ReLU, LeakyReLU, Sigmoid, Tanh</td><td>3/4</td><td>3/4</td></tr><tr><td>Reserved: Swish, HardSigmoid, HardTanh</td><td>2/3</td><td>2/3</td></tr><tr><td>Held-out: Softmax, LogSoftmax, MinGPT GELU</td><td>0/3</td><td>1/3</td></tr><tr><td>Overall first turn</td><td>5/10</td><td>5/10</td></tr></tbody></table></div>
<p>The new GELU solution appeared on the second turn after compilation feedback. Its runtime was about 0.184 ms against 1.624 ms eager PyTorch (8.83× for this one task). It passed five additional signed-input seeds at the original shape. Existing solved kernels stayed essentially unchanged in speed.</p><div class="callout"><strong>A modest observation, not broad proof.</strong><p>One seed, ten tasks and related operator families do not establish statistically robust or unseen-family generalization. Pretraining contamination is not excluded. The generated erf GELU agrees with the tanh reference within tolerance, not bit for bit.</p></div><p><a href="https://huggingface.co/Shreyansh327/Qwen2.5-Coder-7B-KernelEnv-GRPO-16/tree/main/evaluation">Inspect comparison data, all optimizer metrics and validation records →</a></p></section>
<section><h2>Use the trained adapter</h2><p><a href="https://huggingface.co/Shreyansh327/Qwen2.5-Coder-7B-KernelEnv-GRPO-16">Qwen2.5-Coder-7B-KernelEnv-GRPO-16</a> contains the actual saved step-16 LoRA weights. Load with PEFT on the pinned Qwen2.5-Coder-7B-Instruct base; the model card includes code and the full protocol. It is an adapter, not standalone 7B weights or a hosted inference service.</p><p class="note">LoRA rank 16, alpha 32; 16 Dr. GRPO updates; training temperature 0.8; 2,048 tokens per turn; seed 42. KernelBench revision <code>423217d9fda91e0c2d67e4a43bf62f96f6d104f1</code>. Runtime provenance and weight hashes accompany the model.</p></section>
<footer><p>Published 19 October 2026. OpenEnv-derived source retains Meta's BSD 3-Clause notice; adapter weights use Apache 2.0. Downloading and viewing are separate from any GPU compute you choose to run.</p><a href="https://huggingface.co/spaces/Shreyansh327/kernel-env/blob/main/README.md">Full environment instructions</a> · <a href="https://huggingface.co/Shreyansh327/Qwen2.5-Coder-7B-KernelEnv-GRPO-16">Model &amp; evidence</a> · <a href="https://huggingface.co/docs/openenv">OpenEnv</a></footer></main></body></html>