ArshPathan commited on
Commit
53efd7c
·
verified ·
1 Parent(s): 2e64fde

Upload folder using huggingface_hub

Browse files
.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 with OpenEnv, TRL, and Unsloth
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 push an LLM into a more realistic setting: an 8x8 atomic lattice design task where the model must act step by step, observe the consequences, and optimize toward a target set of material properties.
6
 
7
  The core question behind the project is simple:
8
 
9
- Can we train an LLM to become better at **inverse material design** inside a verifiable environment?
10
 
11
- Instead of generating a single answer, the model must build a crystalline structure over multiple actions while balancing:
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 RL post-training.
22
 
23
  ## The Environment
24
 
25
- MaterialForge is an OpenEnv-compatible reinforcement learning environment focused on crystal synthesis.
26
 
27
  At every episode, the agent sees:
28
 
29
- - the current 8x8 lattice
30
- - target material properties
31
- - current estimated properties
32
- - total cost vs budget
33
- - lattice phase and structural metrics
34
 
35
- The agent can take three actions:
36
 
37
  - `place_atom(row, col, atom)`
38
  - `remove_atom(row, col)`
39
  - `replace_atom(row, col, atom)`
40
 
41
- The reward combines several scientific signals:
42
 
43
- - property matching
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
- ![Run V Reward Curve](blog_assets/run_v_reward_curve.png)
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
- ![Run V Loss Curve](blog_assets/run_v_loss_curve.png)
93
 
94
- The loss plot complements the reward curve by showing that the optimization loop was functioning end to end rather than just generating trajectories without updating the policy.
95
 
96
- ## Baseline Results
 
 
 
97
 
98
- As a lightweight sanity check, the notebook also ran a random baseline across 20 episodes.
99
 
100
- Recorded random-baseline performance from Run - V:
101
 
102
- - mean reward: `0.5525`
103
- - mean best reward: `0.6137`
104
 
105
- These baseline numbers matter because they establish a floor for the environment. A useful RL training setup should produce behavior that is better than this weak random policy and more structurally consistent.
 
 
106
 
107
- ### Baseline Comparison
 
 
108
 
109
- ![Run V Baseline Comparison](blog_assets/run_v_baseline_comparison.png)
 
 
110
 
111
- This comparison chart is useful for judges because it quickly communicates that the project is not only an environment demo; it also includes a measurable training-and-evaluation loop with saved evidence.
112
 
113
- ## Why This Project Is Interesting
114
 
115
- MaterialForge is not just another toy grid world.
116
-
117
- What makes it interesting is that the model must learn tradeoffs that feel closer to scientific reasoning:
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 our attempt to show that LLM RL environments can go beyond games and into structured scientific workflows.
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
- ## References
174
 
175
- - Environment: [README.md](README.md)
176
- - Research context: [RESEARCH.md](RESEARCH.md)
177
- - Training notebook: [training/MaterialForge_GRPO_Training.ipynb](training/MaterialForge_GRPO_Training.ipynb)
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
+ ![Reward Curve](training/reward_curve.png)
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
+ ![Loss Curve](training/loss_curve.png)
64
+ The loss plot confirms that the optimization loop was effectively updating the model's structure-discovery policy.
65
 
66
+ ### Verifiable Improvement
67
+ ![Baseline Comparison](training/baseline_comparison.png)
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
  [![Docker Ready](https://img.shields.io/badge/Docker-Ready-2496ED)](https://www.docker.com/)
20
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
21
 
22
- MaterialForge is an OpenEnv-compatible reinforcement learning environment where an agent must **design crystalline structures step by step** to match target physical properties under a finite budget. The environment is built to train and evaluate LLM agents on a scientific workflow rather than a static prompt task.
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
- Quick health check:
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, can an agent construct a stable, ordered crystal lattice that matches those targets without wasting budget?**
45
 
46
  The agent does not solve this in one shot. It must:
47
 
48
  - observe the current 8x8 lattice state
49
- - choose an action
50
- - see how the action changes material properties
51
- - recover from overshooting and bad structure
52
- - build toward a high-quality final phase
53
 
54
- This makes MaterialForge a good fit for:
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 several real scientific ideas:
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 good science is not only about accuracy but also efficiency
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** family models for tool-using policy training
166
 
167
- For the **Grand Finale Submission**, we scaled the training to **Qwen2.5-7B-Instruct** using a high-memory server with **142GB VRAM**, enabling **8 generations per prompt** and real-time gradient updates (Accumulation=1) for maximum stability.
168
 
169
  ## Training Evidence
170
 
171
- While we provide historical artifacts from **Run - V** (0.6B model) as a baseline for rapid iteration, the final submission policy is derived from the **Grand Finale** run:
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
- ### Historical Baseline (Run - V)
181
- - **Base Model:** `Qwen/Qwen3-0.6B`
182
- - **Dataset Size:** `100` episodes
183
- - **Trainable Parameters:** `10,092,544`
184
- - **Trainable Fraction:** `1.67%`
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
- ![Run V Reward Curve](training/runs/Run%20-%20V/reward_curve.png)
192
 
193
  ### Loss Curve
194
-
195
- ![Run V Loss Curve](training/runs/Run%20-%20V/loss_curve.png)
196
 
197
  ### Baseline Comparison
198
-
199
- ![Run V Baseline Comparison](training/runs/Run%20-%20V/baseline_comparison.png)
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 is our attempt to show that RL environments for LLMs can move beyond toy games into structured scientific workflows. It combines:
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
  [![Docker Ready](https://img.shields.io/badge/Docker-Ready-2496ED)](https://www.docker.com/)
20
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](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
+ ![Reward Curve](training/reward_curve.png)
85
+ The reward curve shows the agent successfully learning the structural tradeoffs required to reach target properties.
86
 
87
  ### Loss Curve
88
+ ![Loss Curve](training/loss_curve.png)
89
+ The loss plot confirms stable policy optimization over the training steps.
90
 
91
  ### Baseline Comparison
92
+ ![Baseline Comparison](training/baseline_comparison.png)
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

  • SHA256: 791918ed5aced8163c4a2cc2a023187818e76e6f3628e52e07584505251189ec
  • Pointer size: 131 Bytes
  • Size of remote file: 136 kB