theformalera.gym turns a spec node into a task. The policy writes a Triton kernel, the engine verifies it, and only verified kernels earn a reward.
theformalera pull); the environment verifies against the locked specs.
The task
env.reset() returns a Task:
The step
env.step(source) removes any @tfe.implements the policy wrote, attaches the environment’s annotation to @triton.jit def <kernel_name>, and verifies the result.
Rewards
- Correctness is a gate, not a bonus. FAILED and UNKNOWN earn
0. UNSAFE earnsunsafe_reward(default0; set it negative to penalise). - A PASS earns
1.0, or1 / latency_uswhen you passperf=:
Why it resists reward hacking
- The annotation, the shape domain and the assumptions belong to the environment. The policy writes only the kernel body, so it cannot narrow the domain to “prove” a wrong kernel.
- A proof holds for every input in the domain, so tampering with test inputs gains nothing.
- The policy cannot write lemmas. Lemmas are extracted by the engine, only from proofs that passed the Lean check.
allclose reward check and are all rejected by the spec gate.
Throughput
- Use
level="quick"(the default) for dense signals, andlevel="proof"for the final candidates. - Rollouts of the same task share the project’s results cache and lemma base, so a sub-proof one rollout pays for is a hit for the next ones.
