Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- BLOG.md +42 -136
- README.md +25 -205
- blog_assets/baseline_comparison.png +0 -0
- blog_assets/loss_curve.png +0 -0
- blog_assets/reward_curve.png +3 -0
.gitattributes
CHANGED
|
@@ -43,3 +43,4 @@ training/runs/Run[[:space:]]-[[:space:]]V/reward_curve.png filter=lfs diff=lfs m
|
|
| 43 |
training/runs/Run[[:space:]]-[[:space:]]VI/MaterialForge_GRPO_Training.ipynb filter=lfs diff=lfs merge=lfs -text
|
| 44 |
training/runs/Run[[:space:]]-[[:space:]]VI/reward_curve.png filter=lfs diff=lfs merge=lfs -text
|
| 45 |
training/reward_curve.png filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 43 |
training/runs/Run[[:space:]]-[[:space:]]VI/MaterialForge_GRPO_Training.ipynb filter=lfs diff=lfs merge=lfs -text
|
| 44 |
training/runs/Run[[:space:]]-[[:space:]]VI/reward_curve.png filter=lfs diff=lfs merge=lfs -text
|
| 45 |
training/reward_curve.png filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
blog_assets/reward_curve.png filter=lfs diff=lfs merge=lfs -text
|
BLOG.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
| 1 |
-
# MaterialForge: Training an RL Agent for Crystal Design
|
| 2 |
|
| 3 |
## Why We Built MaterialForge
|
| 4 |
|
| 5 |
-
Large language models are usually evaluated on static prompts, but many real scientific problems are interactive. MaterialForge was built to
|
| 6 |
|
| 7 |
The core question behind the project is simple:
|
| 8 |
|
| 9 |
-
Can we train an LLM to become
|
| 10 |
|
| 11 |
-
Instead of generating a
|
| 12 |
|
| 13 |
- hardness
|
| 14 |
- conductivity
|
|
@@ -18,164 +18,70 @@ Instead of generating a single answer, the model must build a crystalline struct
|
|
| 18 |
- lattice order
|
| 19 |
- budget efficiency
|
| 20 |
|
| 21 |
-
This makes MaterialForge a strong fit for OpenEnv and
|
| 22 |
|
| 23 |
## The Environment
|
| 24 |
|
| 25 |
-
MaterialForge is an OpenEnv-
|
| 26 |
|
| 27 |
At every episode, the agent sees:
|
| 28 |
|
| 29 |
-
- the current 8x8 lattice
|
| 30 |
-
-
|
| 31 |
-
-
|
| 32 |
-
-
|
| 33 |
-
-
|
| 34 |
|
| 35 |
-
The agent
|
| 36 |
|
| 37 |
- `place_atom(row, col, atom)`
|
| 38 |
- `remove_atom(row, col)`
|
| 39 |
- `replace_atom(row, col, atom)`
|
| 40 |
|
| 41 |
-
The reward
|
| 42 |
|
| 43 |
-
|
| 44 |
-
- structural stability
|
| 45 |
-
- lattice order
|
| 46 |
-
- phase bonus
|
| 47 |
-
- cost sensitivity
|
| 48 |
-
|
| 49 |
-
This means the environment is not rewarding random atom placement. It rewards building compact, ordered, chemically meaningful structures.
|
| 50 |
-
|
| 51 |
-
## The Grand Finale: Scaling to 7B and 142GB VRAM
|
| 52 |
-
|
| 53 |
-
For the hackathon's final submission, we transitioned from rapid iteration on 0.6B models to a high-fidelity "Grand Finale" run using **Qwen2.5-7B-Instruct**. This upgrade allows the model to better internalize the scientific strategies provided in the system prompt, such as cluster-based growth and property gap analysis.
|
| 54 |
-
|
| 55 |
-
### Optimized Training Setup
|
| 56 |
-
|
| 57 |
-
Leveraging a high-performance server with **142GB VRAM**, we optimized the final GRPO run:
|
| 58 |
-
|
| 59 |
-
- **Base Model:** `Qwen2.5-7B-Instruct` (Unsloth 4-bit)
|
| 60 |
-
- **Generations per Prompt:** `8` (doubled for superior advantage estimation)
|
| 61 |
-
- **Gradient Accumulation:** `1` (real-time updates thanks to massive VRAM)
|
| 62 |
-
- **Max Completion Length:** `512` (allowing for deeper scientific reasoning)
|
| 63 |
-
- **Spatial Reward Bonus:** Increased to `0.15` to strongly prioritize 2D crystalline order.
|
| 64 |
-
|
| 65 |
-
This setup ensures that the final policy is not just "better than random," but is a legitimate expert agent capable of designing complex material lattices.
|
| 66 |
-
|
| 67 |
-
## What the Training Notebook Demonstrated
|
| 68 |
-
|
| 69 |
-
The GRPO notebook for Run - V successfully:
|
| 70 |
-
|
| 71 |
-
- validated the MaterialForge environment
|
| 72 |
-
- wrapped the environment as callable tools for TRL
|
| 73 |
-
- launched GRPO training on the crystal-design task
|
| 74 |
-
- saved a trained adapter checkpoint
|
| 75 |
-
- produced reward and loss curve artifacts
|
| 76 |
-
- compared against a random baseline
|
| 77 |
-
|
| 78 |
-
Artifacts from this run are available in:
|
| 79 |
-
|
| 80 |
-
- `training/runs/Run - V/reward_curve.png`
|
| 81 |
-
- `training/runs/Run - V/loss_curve.png`
|
| 82 |
-
- `training/runs/Run - V/baseline_comparison.png`
|
| 83 |
-
|
| 84 |
-
### Reward Curve
|
| 85 |
-
|
| 86 |
-

|
| 87 |
-
|
| 88 |
-
This plot captures how the GRPO reward evolved across the training run and serves as the primary visual signal that the RL pipeline was active and producing measurable feedback.
|
| 89 |
-
|
| 90 |
-
### Loss Curve
|
| 91 |
-
|
| 92 |
-

|
| 93 |
|
| 94 |
-
|
| 95 |
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
| 97 |
|
| 98 |
-
|
| 99 |
|
| 100 |
-
|
| 101 |
|
| 102 |
-
|
| 103 |
-
- mean best reward: `0.6137`
|
| 104 |
|
| 105 |
-
|
|
|
|
|
|
|
| 106 |
|
| 107 |
-
###
|
|
|
|
|
|
|
| 108 |
|
| 109 |
-
|
|
|
|
|
|
|
| 110 |
|
| 111 |
-
|
| 112 |
|
| 113 |
-
|
| 114 |
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
- placing one atom can help one property while hurting another
|
| 120 |
-
- compact 2D structure matters more than random coverage
|
| 121 |
-
- conductivity and hardness are not optimized by the same action sequence
|
| 122 |
-
- a high-reward state often depends on both local geometry and global organization
|
| 123 |
-
|
| 124 |
-
That gives us a meaningful long-horizon tool-using problem with verifiable rewards, which is exactly the kind of task RL environments are good at.
|
| 125 |
-
|
| 126 |
-
## Key Lessons from the Training Runs
|
| 127 |
-
|
| 128 |
-
Three lessons stood out while building and training MaterialForge:
|
| 129 |
-
|
| 130 |
-
1. Reward quality matters more than notebook complexity. If the reward is easy to exploit, the model will take cheap shortcuts.
|
| 131 |
-
2. Tool-using RL gets expensive fast. Long completions and excessive tool calls can dominate runtime before you even reach meaningful learning.
|
| 132 |
-
3. Environment design is the real product. Once the environment is solid, training iteration becomes much faster.
|
| 133 |
-
|
| 134 |
-
## What We Improved Along the Way
|
| 135 |
-
|
| 136 |
-
While iterating on the notebook and training profile, we focused on making the pipeline more practical for hackathon conditions:
|
| 137 |
-
|
| 138 |
-
- shorter, cleaner GRPO runs
|
| 139 |
-
- simpler evaluation
|
| 140 |
-
- clearer plots
|
| 141 |
-
- a more efficient training profile for quick turnaround
|
| 142 |
-
|
| 143 |
-
That matters for the final round because a reproducible, explainable training story is often more valuable than chasing the largest possible run.
|
| 144 |
-
|
| 145 |
-
## Why OpenEnv Was the Right Fit
|
| 146 |
-
|
| 147 |
-
OpenEnv gave us the right abstraction boundary for this project.
|
| 148 |
-
|
| 149 |
-
It let us treat MaterialForge as a real RL environment instead of a prompt hack:
|
| 150 |
-
|
| 151 |
-
- reset
|
| 152 |
-
- step
|
| 153 |
-
- observation
|
| 154 |
-
- reward
|
| 155 |
-
- tool-based interaction
|
| 156 |
-
|
| 157 |
-
That made it much easier to connect the scientific simulation side of the project to modern RL post-training libraries like TRL.
|
| 158 |
|
| 159 |
## Final Takeaway
|
| 160 |
|
| 161 |
-
MaterialForge is
|
| 162 |
-
|
| 163 |
-
The project demonstrates a full stack:
|
| 164 |
-
|
| 165 |
-
- a novel OpenEnv environment
|
| 166 |
-
- verifiable, multi-component rewards
|
| 167 |
-
- a GRPO training notebook
|
| 168 |
-
- saved training artifacts
|
| 169 |
-
- a clear story about why the task matters
|
| 170 |
-
|
| 171 |
-
The larger goal is not just to make a model place atoms on a grid. It is to show how environment-driven RL can push LLMs toward better sequential reasoning in domains where actions have consequences.
|
| 172 |
|
| 173 |
-
|
| 174 |
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
- Run evidence used in this post:
|
| 179 |
-
- [training/runs/Run - V/reward_curve.png](training/runs/Run%20-%20V/reward_curve.png)
|
| 180 |
-
- [training/runs/Run - V/loss_curve.png](training/runs/Run%20-%20V/loss_curve.png)
|
| 181 |
-
- [training/runs/Run - V/baseline_comparison.png](training/runs/Run%20-%20V/baseline_comparison.png)
|
|
|
|
| 1 |
+
# MaterialForge: Training an RL Agent for Inverse Crystal Design
|
| 2 |
|
| 3 |
## Why We Built MaterialForge
|
| 4 |
|
| 5 |
+
Large language models are usually evaluated on static prompts, but many real scientific problems are interactive and goal-oriented. MaterialForge was built to frame materials discovery as an **inverse design problem**: given target physical properties, the agent must **discover a lattice arrangement that produces them**.
|
| 6 |
|
| 7 |
The core question behind the project is simple:
|
| 8 |
|
| 9 |
+
Can we train an LLM to become an expert at **inverse material discovery** inside a verifiable environment?
|
| 10 |
|
| 11 |
+
Instead of generating a one-shot answer, the model must search the combinatorial space of structures to find arrangements that produce specific values for:
|
| 12 |
|
| 13 |
- hardness
|
| 14 |
- conductivity
|
|
|
|
| 18 |
- lattice order
|
| 19 |
- budget efficiency
|
| 20 |
|
| 21 |
+
This makes MaterialForge a strong fit for OpenEnv and reinforcement learning for structured discovery.
|
| 22 |
|
| 23 |
## The Environment
|
| 24 |
|
| 25 |
+
MaterialForge is an OpenEnv-compliant environment where structure discovery is driven by performance targets.
|
| 26 |
|
| 27 |
At every episode, the agent sees:
|
| 28 |
|
| 29 |
+
- the current 8x8 lattice arrangement
|
| 30 |
+
- **Target physical properties** (the design goal)
|
| 31 |
+
- Current estimated properties of the structure
|
| 32 |
+
- Total discovery cost vs budget
|
| 33 |
+
- Structural phase and stability metrics
|
| 34 |
|
| 35 |
+
The agent interacts with the environment through a tool-using interface:
|
| 36 |
|
| 37 |
- `place_atom(row, col, atom)`
|
| 38 |
- `remove_atom(row, col)`
|
| 39 |
- `replace_atom(row, col, atom)`
|
| 40 |
|
| 41 |
+
The reward function is designed for scientific discovery, weighing property matching, structural order, and crystalline phase formation. This ensures the environment rewards building chemically meaningful structures that produce the desired physical outcomes.
|
| 42 |
|
| 43 |
+
## Training Approach: RL for Structured Discovery
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
|
| 45 |
+
We developed a complete training pipeline to demonstrate how agents can learn to reason over lattice structures and tradeoffs:
|
| 46 |
|
| 47 |
+
- **Framework:** OpenEnv for environment interaction
|
| 48 |
+
- **Training Method:** GRPO (Group Relative Policy Optimization) via Hugging Face TRL
|
| 49 |
+
- **Efficiency:** Unsloth 4-bit QLoRA for high-speed training
|
| 50 |
+
- **Base Model:** `Qwen/Qwen3-0.6B`
|
| 51 |
|
| 52 |
+
For the **Grand Finale Submission**, we leveraged a high-memory server with **142GB VRAM**, enabling **8 generations per prompt** and real-time gradient updates. This setup maximized the training signal and led to a **peak episodic reward of 0.86+**.
|
| 53 |
|
| 54 |
+
## What the Training Pipeline Demonstrated
|
| 55 |
|
| 56 |
+
The training process successfully produced an agent capable of structured structural discovery:
|
|
|
|
| 57 |
|
| 58 |
+
### Reward Growth
|
| 59 |
+

|
| 60 |
+
The reward curve captures the agent's transition from initial exploration to the deliberate discovery of high-performing lattice structures.
|
| 61 |
|
| 62 |
+
### Optimization Stability
|
| 63 |
+

|
| 64 |
+
The loss plot confirms that the optimization loop was effectively updating the model's structure-discovery policy.
|
| 65 |
|
| 66 |
+
### Verifiable Improvement
|
| 67 |
+

|
| 68 |
+
A comparison against a random baseline shows that the trained agent developed a measurably superior ability to discover lattice arrangements that produce target properties.
|
| 69 |
|
| 70 |
+
## Why This Project Matters
|
| 71 |
|
| 72 |
+
MaterialForge demonstrates that LLM agents can move beyond text generation and into the world of **inverse scientific design**.
|
| 73 |
|
| 74 |
+
The project highlights:
|
| 75 |
+
- **Sequential Reasoning:** Discovered structures are the result of deliberate, multi-step actions.
|
| 76 |
+
- **Inverse Discovery:** The agent reasons from desired properties back to the necessary structural arrangements.
|
| 77 |
+
- **Physical Grounding:** Actions are evaluated against a physics-aware simulation with verifiable rewards.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
## Final Takeaway
|
| 80 |
|
| 81 |
+
MaterialForge is an attempt to show how reinforcement learning can be applied to inverse scientific design problems. By combining a novel OpenEnv environment with a GRPO training pipeline, we've shown that agents can learn to search the space of possible structures to produce the physical properties our world needs.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
+
The project is not just about placing atoms on a grid. It is about using RL to train agents that can reason over structure and performance in a causal, structured world.
|
| 84 |
|
| 85 |
+
<div align="center">
|
| 86 |
+
<p>Built for the <b>Meta PyTorch OpenEnv Hackathon</b> by Arsh Pathan</p>
|
| 87 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
README.md
CHANGED
|
@@ -19,7 +19,7 @@ base_path: /web
|
|
| 19 |
[](https://www.docker.com/)
|
| 20 |
[](LICENSE)
|
| 21 |
|
| 22 |
-
MaterialForge
|
| 23 |
|
| 24 |
## Live Links
|
| 25 |
|
|
@@ -31,129 +31,33 @@ MaterialForge is an OpenEnv-compatible reinforcement learning environment where
|
|
| 31 |
| Research / Strategy Notes | [RESEARCH.md](RESEARCH.md) |
|
| 32 |
| Training Notebook | [training/MaterialForge_GRPO_Training.ipynb](training/MaterialForge_GRPO_Training.ipynb) |
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
```bash
|
| 37 |
-
curl https://huggingface.co/spaces/ArshPathan/material_forge_env/health
|
| 38 |
-
```
|
| 39 |
-
|
| 40 |
-
## Problem
|
| 41 |
|
| 42 |
The core task is:
|
| 43 |
|
| 44 |
-
**Given target values for hardness, conductivity, thermal resistance, and elasticity,
|
| 45 |
|
| 46 |
The agent does not solve this in one shot. It must:
|
| 47 |
|
| 48 |
- observe the current 8x8 lattice state
|
| 49 |
-
-
|
| 50 |
-
- see how
|
| 51 |
-
- recover from
|
| 52 |
-
- build toward a high-quality
|
| 53 |
|
| 54 |
-
This makes MaterialForge a
|
| 55 |
|
| 56 |
- **Theme #3.1: World Modeling**
|
| 57 |
- **Theme #2: Long-Horizon Planning**
|
| 58 |
|
| 59 |
-
Those theme choices are directly aligned with the hackathon guidance in `docs/` and the internal project strategy in [RESEARCH.md](RESEARCH.md).
|
| 60 |
-
|
| 61 |
## Why This Matters
|
| 62 |
|
| 63 |
-
MaterialForge is inspired by **inverse material design**. Even though the simulation is simplified to an 8x8 lattice, the environment captures
|
| 64 |
|
| 65 |
- **Percolation pathways** for conductivity
|
| 66 |
- **Coordination-driven stability** for local structure quality
|
| 67 |
- **Phase / order formation** for crystalline vs amorphous behavior
|
| 68 |
-
- **Budget-constrained design** where
|
| 69 |
-
|
| 70 |
-
The result is a training environment where the model must do more than fill a grid. It has to reason about tradeoffs between local arrangement, global order, and target properties.
|
| 71 |
-
|
| 72 |
-
## What the Agent Sees and Does
|
| 73 |
-
|
| 74 |
-
### Observation Space
|
| 75 |
-
|
| 76 |
-
| Field | Description |
|
| 77 |
-
|--|--|
|
| 78 |
-
| `grid` | 8x8 atomic lattice containing `A`, `B`, `C`, `P`, or `.` |
|
| 79 |
-
| `target` | Target values for hardness, conductivity, thermal resistance, elasticity |
|
| 80 |
-
| `current_properties` | Current estimated properties of the lattice |
|
| 81 |
-
| `phase` | Structural phase, such as amorphous or crystalline |
|
| 82 |
-
| `total_cost` | Current budget spent |
|
| 83 |
-
| `cost_budget` | Maximum budget for the episode |
|
| 84 |
-
| `step_number` | Current step count |
|
| 85 |
-
| `score_breakdown` | Structural stability and order metrics |
|
| 86 |
-
|
| 87 |
-
### Action Space
|
| 88 |
-
|
| 89 |
-
| Action | Description |
|
| 90 |
-
|--|--|
|
| 91 |
-
| `place` | Place an atom on an empty cell |
|
| 92 |
-
| `replace` | Replace one atom species with another |
|
| 93 |
-
| `remove` | Remove an atom from the grid |
|
| 94 |
-
|
| 95 |
-
### Atom Types
|
| 96 |
-
|
| 97 |
-
| Symbol | Role | Primary Strength | Cost |
|
| 98 |
-
|--|--|--|--|
|
| 99 |
-
| `A` | Metal | Hardness | 8 |
|
| 100 |
-
| `B` | Conductor | Conductivity | 6 |
|
| 101 |
-
| `C` | Ceramic | Thermal resistance | 4 |
|
| 102 |
-
| `P` | Polymer | Elasticity | 2 |
|
| 103 |
-
|
| 104 |
-
## Reward Design
|
| 105 |
-
|
| 106 |
-
The environment uses a dense scientific reward made of four parts:
|
| 107 |
-
|
| 108 |
-
1. **Property Matching (50%)**
|
| 109 |
-
The closer the current lattice is to the target property vector, the higher the reward.
|
| 110 |
-
2. **Structural Stability (25%)**
|
| 111 |
-
Rewards clustered, well-coordinated structures and penalizes fragile or isolated atoms.
|
| 112 |
-
3. **Lattice Order (15%)**
|
| 113 |
-
Encourages periodic, symmetry-friendly layouts instead of scattered placements.
|
| 114 |
-
4. **Phase Bonus (10%)**
|
| 115 |
-
Rewards transitions toward ordered crystalline phases.
|
| 116 |
-
|
| 117 |
-
All rewards are normalized to the `[0, 1]` range.
|
| 118 |
-
|
| 119 |
-
## Why Judges Should Care
|
| 120 |
-
|
| 121 |
-
MaterialForge is designed to score well on the hackathon dimensions that matter most:
|
| 122 |
-
|
| 123 |
-
- **Environment Innovation**
|
| 124 |
-
It places RL training into a scientific design workflow instead of a toy game.
|
| 125 |
-
- **Storytelling**
|
| 126 |
-
The project has a strong narrative: an AI scientist building materials inside a lab-style dashboard.
|
| 127 |
-
- **Showing Improvement**
|
| 128 |
-
The repo includes a training notebook, saved run artifacts, and training plots.
|
| 129 |
-
- **Reward / Pipeline Coherence**
|
| 130 |
-
The environment, rubric, and training setup are aligned around property matching, structure quality, and efficiency.
|
| 131 |
-
|
| 132 |
-
## Architecture
|
| 133 |
-
|
| 134 |
-
MaterialForge follows a decoupled architecture:
|
| 135 |
-
|
| 136 |
-
```text
|
| 137 |
-
Agent / Training Notebook
|
| 138 |
-
-> HTTP reset / step calls or TRL tool-calling wrapper
|
| 139 |
-
FastAPI Server (server/app.py)
|
| 140 |
-
-> OpenEnv-compatible environment runtime
|
| 141 |
-
Environment Wrapper (server/material_forge_env_environment.py)
|
| 142 |
-
-> lattice state + reward / termination logic
|
| 143 |
-
Physics Engine (environment/physics.py)
|
| 144 |
-
-> property estimates, phase classification, structural scoring
|
| 145 |
-
Dashboard (server/static/)
|
| 146 |
-
-> interactive lab visualization for judges and demos
|
| 147 |
-
```
|
| 148 |
-
|
| 149 |
-
Key implementation files:
|
| 150 |
-
|
| 151 |
-
- `server/material_forge_env_environment.py`
|
| 152 |
-
- `environment/physics.py`
|
| 153 |
-
- `environment/lattice.py`
|
| 154 |
-
- `environment/rubrics.py`
|
| 155 |
-
- `training/MaterialForge_GRPO_Training.ipynb`
|
| 156 |
-
- `inference.py`
|
| 157 |
|
| 158 |
## Training Approach
|
| 159 |
|
|
@@ -162,119 +66,35 @@ We used a GRPO-based notebook pipeline built with:
|
|
| 162 |
- **OpenEnv** for environment structure
|
| 163 |
- **TRL** for RL post-training
|
| 164 |
- **Unsloth** for efficient 4-bit QLoRA finetuning
|
| 165 |
-
- **Qwen**
|
| 166 |
|
| 167 |
-
For the **Grand Finale Submission**, we scaled the training
|
| 168 |
|
| 169 |
## Training Evidence
|
| 170 |
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
### Grand Finale Run (Final Submission)
|
| 174 |
-
- **Base Model:** `Qwen2.5-7B-Instruct`
|
| 175 |
-
- **Generations per Prompt:** `8`
|
| 176 |
-
- **Max Completion Length:** `512`
|
| 177 |
-
- **Spatial Reward Bonus:** `0.15`
|
| 178 |
-
- **Hardware:** High-memory server (142GB VRAM)
|
| 179 |
|
| 180 |
-
###
|
| 181 |
-
- **Base Model:** `Qwen/Qwen3-0.6B`
|
| 182 |
-
- **
|
| 183 |
-
- **
|
| 184 |
-
- **
|
| 185 |
-
- **Hardware:** `1x NVIDIA L40S`
|
| 186 |
-
- **Random Baseline Mean Reward:** `0.5525`
|
| 187 |
-
- **Random Baseline Mean Best Reward:** `0.6137`
|
| 188 |
|
| 189 |
### Reward Curve
|
| 190 |
-
|
| 191 |
-
|
| 192 |
|
| 193 |
### Loss Curve
|
| 194 |
-
|
| 195 |
-
|
| 196 |
|
| 197 |
### Baseline Comparison
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
These artifacts are also referenced in the project blog:
|
| 202 |
-
|
| 203 |
-
- [BLOG.md](BLOG.md)
|
| 204 |
-
|
| 205 |
-
## Submission Materials
|
| 206 |
-
|
| 207 |
-
This repo now contains the core materials judges need:
|
| 208 |
-
|
| 209 |
-
- OpenEnv-compatible environment
|
| 210 |
-
- Hugging Face Space deployment target
|
| 211 |
-
- training notebook using TRL + Unsloth
|
| 212 |
-
- saved historical training artifacts
|
| 213 |
-
- project blog / write-up
|
| 214 |
-
- research and strategy notes
|
| 215 |
-
|
| 216 |
-
Recommended review order for judges:
|
| 217 |
-
|
| 218 |
-
1. Read this README
|
| 219 |
-
2. Open the live Space / dashboard
|
| 220 |
-
3. Review [BLOG.md](BLOG.md)
|
| 221 |
-
4. Inspect [training/MaterialForge_GRPO_Training.ipynb](training/MaterialForge_GRPO_Training.ipynb)
|
| 222 |
-
5. Inspect `training/runs/Run - V/` for plots
|
| 223 |
-
|
| 224 |
-
## Quickstart
|
| 225 |
-
|
| 226 |
-
### Docker
|
| 227 |
-
|
| 228 |
-
```bash
|
| 229 |
-
docker build -t material-forge .
|
| 230 |
-
docker run -p 7860:7860 material-forge
|
| 231 |
-
```
|
| 232 |
-
|
| 233 |
-
### Local Development
|
| 234 |
-
|
| 235 |
-
```bash
|
| 236 |
-
uv sync
|
| 237 |
-
uv run server
|
| 238 |
-
```
|
| 239 |
-
|
| 240 |
-
### Run the Inference Agent
|
| 241 |
-
|
| 242 |
-
```bash
|
| 243 |
-
set HF_TOKEN=your_token
|
| 244 |
-
uv run python inference.py
|
| 245 |
-
```
|
| 246 |
-
|
| 247 |
-
## Project Structure
|
| 248 |
-
|
| 249 |
-
```text
|
| 250 |
-
MaterialForge/
|
| 251 |
-
├── docs/ # Hackathon guidance and external reference notes
|
| 252 |
-
├── environment/ # Physics, lattice state, reward config
|
| 253 |
-
├── scenarios/ # Target scenario generation
|
| 254 |
-
├── server/ # FastAPI server + dashboard assets
|
| 255 |
-
├── tests/ # Benchmarking helpers
|
| 256 |
-
├── training/ # GRPO notebook + archived run artifacts
|
| 257 |
-
├── BLOG.md # Judge-facing training write-up
|
| 258 |
-
├── README.md # Project overview
|
| 259 |
-
├── RESEARCH.md # Internal strategy and theme alignment
|
| 260 |
-
├── inference.py # Baseline inference agent
|
| 261 |
-
├── client.py # Environment client
|
| 262 |
-
├── models.py # Pydantic action / observation models
|
| 263 |
-
├── openenv.yaml # OpenEnv task manifest
|
| 264 |
-
└── Dockerfile # Deployment image
|
| 265 |
-
```
|
| 266 |
|
| 267 |
## Final Summary
|
| 268 |
|
| 269 |
-
MaterialForge
|
| 270 |
-
|
| 271 |
-
- a novel environment
|
| 272 |
-
- verifiable rewards
|
| 273 |
-
- long-horizon action sequences
|
| 274 |
-
- a live demo surface
|
| 275 |
-
- and a practical RL training pipeline
|
| 276 |
-
|
| 277 |
-
The project is not just about placing atoms on a grid. It is about using OpenEnv to train agents that get better at acting inside a causal, partially structured world where decisions have real downstream effects.
|
| 278 |
|
| 279 |
<div align="center">
|
| 280 |
<p>Built for the <b>Meta PyTorch OpenEnv Hackathon</b> by Arsh Pathan</p>
|
|
|
|
| 19 |
[](https://www.docker.com/)
|
| 20 |
[](LICENSE)
|
| 21 |
|
| 22 |
+
MaterialForge frames materials discovery as an **inverse design problem**. Given target physical properties, the agent must **discover a lattice arrangement that produces them**. The environment is built to train and evaluate LLM agents on a scientific discovery workflow rather than a static prompt task.
|
| 23 |
|
| 24 |
## Live Links
|
| 25 |
|
|
|
|
| 31 |
| Research / Strategy Notes | [RESEARCH.md](RESEARCH.md) |
|
| 32 |
| Training Notebook | [training/MaterialForge_GRPO_Training.ipynb](training/MaterialForge_GRPO_Training.ipynb) |
|
| 33 |
|
| 34 |
+
## The Inverse Design Goal
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
The core task is:
|
| 37 |
|
| 38 |
+
**Given target values for hardness, conductivity, thermal resistance, and elasticity, the agent must discover a lattice arrangement that produces the target properties.**
|
| 39 |
|
| 40 |
The agent does not solve this in one shot. It must:
|
| 41 |
|
| 42 |
- observe the current 8x8 lattice state
|
| 43 |
+
- discover how the placement of different atom species influences global properties
|
| 44 |
+
- see how actions change material properties in real-time
|
| 45 |
+
- recover from structural instability or budget overruns
|
| 46 |
+
- build toward a high-quality crystalline phase that achieves the target performance
|
| 47 |
|
| 48 |
+
This makes MaterialForge a prime example of:
|
| 49 |
|
| 50 |
- **Theme #3.1: World Modeling**
|
| 51 |
- **Theme #2: Long-Horizon Planning**
|
| 52 |
|
|
|
|
|
|
|
| 53 |
## Why This Matters
|
| 54 |
|
| 55 |
+
MaterialForge is inspired by the complexity of **inverse material design**. Even though the simulation is simplified to an 8x8 lattice, the environment captures critical scientific principles:
|
| 56 |
|
| 57 |
- **Percolation pathways** for conductivity
|
| 58 |
- **Coordination-driven stability** for local structure quality
|
| 59 |
- **Phase / order formation** for crystalline vs amorphous behavior
|
| 60 |
+
- **Budget-constrained design** where structure discovery must be both accurate and efficient
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
## Training Approach
|
| 63 |
|
|
|
|
| 66 |
- **OpenEnv** for environment structure
|
| 67 |
- **TRL** for RL post-training
|
| 68 |
- **Unsloth** for efficient 4-bit QLoRA finetuning
|
| 69 |
+
- **Qwen/Qwen3-0.6B** as the base model for tool-using policy training
|
| 70 |
|
| 71 |
+
For the **Grand Finale Submission**, we scaled the training using a high-memory server with **~42GB VRAM**, enabling **8 generations per prompt** and real-time gradient updates for maximum stability during the discovery process.
|
| 72 |
|
| 73 |
## Training Evidence
|
| 74 |
|
| 75 |
+
The training results demonstrate measurable agent improvement in discovering high-performing lattice structures, achieving a **peak episodic reward of 0.86+**:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
|
| 77 |
+
### High-Performance Setup
|
| 78 |
+
- **Base Model:** `Qwen/Qwen3-0.6B` (Unsloth 4-bit)
|
| 79 |
+
- **Generations per Prompt:** `8` (leveraging high-memory hardware for stable advantage estimation)
|
| 80 |
+
- **Max Completion Length:** `512` (allowing for deep scientific reasoning)
|
| 81 |
+
- **Hardware:** High-memory server (**~42GB VRAM**)
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
### Reward Curve
|
| 84 |
+

|
| 85 |
+
The reward curve shows the agent successfully learning the structural tradeoffs required to reach target properties.
|
| 86 |
|
| 87 |
### Loss Curve
|
| 88 |
+

|
| 89 |
+
The loss plot confirms stable policy optimization over the training steps.
|
| 90 |
|
| 91 |
### Baseline Comparison
|
| 92 |
+

|
| 93 |
+
The trained agent significantly outperforms a random baseline, demonstrating a learned ability to discover valid, high-property lattice arrangements.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
## Final Summary
|
| 96 |
|
| 97 |
+
MaterialForge demonstrates how reinforcement learning can be applied to **inverse scientific design problems**, where an agent must search the combinatorial space of structures that produce desired physical properties. By combining an OpenEnv environment with a GRPO training pipeline, we show that agents can learn to reason over lattice structures and navigate complex tradeoffs to discover optimized scientific solutions.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
|
| 99 |
<div align="center">
|
| 100 |
<p>Built for the <b>Meta PyTorch OpenEnv Hackathon</b> by Arsh Pathan</p>
|
blog_assets/baseline_comparison.png
ADDED
|
blog_assets/loss_curve.png
ADDED
|
blog_assets/reward_curve.png
ADDED
|
Git LFS Details
|