CoolFace
Apppublic

Swastikr/polyglot-optima-openenv

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
App README

Polyglot-Optima

Polyglot-Optima is an OpenEnv environment for training an LLM to translate Python functions into hardware-aware C++ that is both fast and correct.

Problem

LLMs can generate optimized code, but often fail on edge-case correctness, portability, and anti-gaming behavior (fast but wrong outputs). This environment targets that gap with closed-loop tool use and verifiable rewards.

Environment Design

  • —API shape: Gym-style reset, step, state.
  • —3-round episodes: iterative refinement, final submission at round 3.
  • —9 tools: profiling, complexity analysis, memory analysis, compile+benchmark, equivalence verifier, portability checker, and final submit.
  • —Reward DAG: composable rubrics for speedup, correctness, diagnosis quality, portability, and self-correction.
  • —Continuous rewards: no hard 0/1 optimization cliff in the main learning path.

Innovation Highlights

  1. 1.Adaptive 4-axis curriculum updates global difficulty over batches.
  2. 2.Adversarial trap library with category-focused adaptive resampling from recent failures.
  3. 3.Semantic trap variation (AST-level no-op rewrites) to reduce memorization.
  4. 4.Roofline-aware speedup scoring for hardware-grounded performance reward.
  5. 5.Anti-gaming verification through fuzzing + adversarial pass checks.

Why This Matters

The target behavior is not just "compile and run", but robust optimization under realistic constraints: correctness under adversarial inputs, reasoning about bottlenecks, and hardware-aware strategy selection.

Local Usage

bash
python -m pytest -q
python -m ruff check .

Run smoke LLM integration:

bash
python tests/smoke_llm_hf.py

Cursor/OpenAI-compatible provider mode:

bash
export LLM_PROVIDER=cursor
export CURSOR_API_KEY=...
export CURSOR_MODEL=gpt-4.1-nano
python tests/smoke_llm_hf.py

Notebook Usage and HF Spaces

You can use this environment directly in a local notebook without deploying to HF Spaces.

  • —For development/training: local usage is enough.
  • —For hackathon submission: deploy to HF Spaces and link it in README per requirements.

Current Validation Snapshot

  • —Unit/integration tests passing.
  • —Smoke integration path validates parseability/tool-loop behavior.
  • —Reward and gate tests verify coherent scoring behavior.

Results (Judge-facing)

After running training/openenv_hackathon_training.ipynb, add:

  • —Reward distribution plot: docs/plots/reward_distribution_baseline_vs_trained.png
  • —Correctness curve plot: docs/plots/correctness_baseline_vs_trained.png
  • —Baseline vs trained metrics table (reward mean, correctness, compile rate, portability).

Required Submission Links

Add these links before final submission:

  • —HF Space (environment URL judges will pull): TODO_ADD_HF_SPACE_URL
  • —Training notebook/script: training/openenv_hackathon_training.ipynb
  • —W&B run (or equivalent training evidence): TODO_ADD_WANDB_RUN_URL
  • —Short writeup/video/slides (<2 min video or mini blog): TODO_ADD_STORY_URL

Submission Checklist (from hackathon PDF)

  • —[ ] Environment deployed to HF Space and URL added above
  • —[x] Valid OpenEnv manifest (openenv.yaml) present
  • —[x] Training notebook/script using TRL/Unsloth path present
  • —[ ] Real training evidence linked (loss/reward curves from an actual run)
  • —[ ] README includes all judge-facing links (Space + writeup/video/slides + run logs)
  • —[ ] Key plots embedded and committed in repo (docs/plots/*.png)