GRPong: A 56K-Parameter Raw-Pixel Policy
1. Motivation
After watching George Kurian and Susie Xia’s talk on World Action Models at PyTorch Conference in San Jose, I wanted to dig into robotics AI myself.
Thinking about how to approach this, the idea that came to mind was starting with models that play games. To make it a little more related to the problems in robotics, I set the following rules for myself: no reading of internal game state, raw pixel values as input, and raw actions as output.
Pong seemed like the right pick because of its simplicity. It’s a great game for a first dive into robotics, kind of like the MNIST of my robotics journey. After this, I want to push into more complex games.
2. Choosing the Architecture
I decided to start with a lightweight vision encoder inspired by the encoder used in RT-DETR: a ConvStem followed by full attention blocks on that downsampled grid. I’d used RT-DETR in prior computer vision projects and had great results, so I thought it might be a great fit here. To turn this 2D representation into a single token, I decided to use mean pooling. This was followed by a simple MHA causal transformer with sliding window attention (since Pong doesn’t need long context) and a learned BOS token that always stays visible to act as an attention sink for the model.
3. Pretraining
For pretraining, I briefly thought about recording myself playing Pong, then decided against it and wrote a simple randomized bot instead. At the start of each rally, the bot samples a random playstyle: predictive play, simple ball tracking without caring about wall bounces, aiming for angles, and always a little bit of noise in the actions.
I generated 6,000 bot-vs-bot rallies (around 3.6M frames) and trained the model for 1 epoch. This stage is meant to produce a model that knows what in the image is important and has a basic idea of what to do, while still keeping plenty of entropy in its decisions so pretraining doesn’t push a single playstyle.
After analyzing the first run, I noticed a discrepancy in the loss across the 3 classes (STAY 0.257, UP 0.647, DOWN 0.648), so I decided to run a second experiment with macro-averaged cross-entropy loss.
For evaluation, I run 1,000 live games with different seeds against two predictive bots (bots that read the game state to instantly calculate where the ball will land, including wall bounces) with different settings: Easy has 20% action noise and a wider deadzone, while Hard has 0% noise and returns to the center after every hit. I sample actions directly from the policy’s output distribution and track two main metrics: the average number of hits per rally and the number of wins against each bot.
| Loss | Val Loss | Val (S / U / D) | Easy (1k) | Hard (1k) |
|---|---|---|---|---|
| Standard CE | 0.407 |
0.257 / 0.647 / 0.648 |
44W (4.5h) |
0W (5.3h) |
| Macro CE | 0.448 |
0.469 / 0.434 / 0.440 |
126W (6.5h) |
1W (7.3h) |
Macro CE showed a slightly higher overall val loss, but a much more balanced distribution across all three classes. This resulted in a much higher win rate and longer rallies against both eval bots.
4. Pruning the Vision Layers
At this stage, I had the feeling the architecture might include things that aren’t really needed. For example, global attention across the whole 8×8 grid might not be needed at all. For other games global attention is probably necessary, but for Pong I decided to run a small ablation to see what impact removing the vision layers has.
| Vision Layers | Params | Val Loss | Easy (1k) | Hard (1k) |
|---|---|---|---|---|
2 |
76.4K |
0.448 |
126W (6.5h) |
1W (7.3h) |
1 |
66.1K |
0.452 |
65W (5.3h) |
1W (4.6h) |
0 |
55.7K |
0.617 |
2W (1.3h) |
0W (1.2h) |
Removing 1 layer had almost no impact on val loss, while 0 layers completely destroyed performance. I suspected this was because no positional encoding survived the mean pooling.
Then I had the idea to apply a RoPE2D transformation directly onto the grid, combined with learned softmax pooling so the positional information survives. To make sure RoPE2D did the heavy lifting, I also ran the softmax pooling without RoPE.
class RoPE2DLinearPool(nn.Module):
def __init__(self, d_model: int, base: float = 100.0, grid_size: int = 8):
super().__init__()
self.rope = RoPE2D(d_model, base=base, grid_size=grid_size)
self.score = nn.Linear(d_model, 1)
def forward(self, x: torch.Tensor, grid_h: int, grid_w: int):
x_rot = self.rope(x, grid_h, grid_w)
weights = self.score(x_rot).softmax(dim=1)
return (weights * x_rot).sum(dim=1)| Pooling | Params | Val Loss | Easy (1k) | Hard (1k) |
|---|---|---|---|---|
| Mean | 55.7K |
0.617 |
2W (1.3h) |
0W (1.2h) |
| Softmax | 55.8K |
0.499 |
8W (2.3h) |
0W (1.7h) |
| RoPE2D + Softmax | 55.8K |
0.460 |
188W (8.6h) |
1W (9.6h) |
RoPE2D recovered the val loss and set a new best score in my evaluation against both bots.
5. How Small Can I Go?
After the discovery with the vision layers, I suspected I might have gone too big overall in model size for a game like Pong. So I tested what impact the backbone dimension has on performance, sweeping d = 8, 16, 32 with n_heads = 1, 2, 4 as an additional hyperparameter while keeping 0 vision layers, 4 causal layers, and RoPE2D + Softmax pooling.
d |
Params | h = 1 (Easy / Hard) |
h = 2 (Easy / Hard) |
h = 4 (Easy / Hard) |
|---|---|---|---|---|
8 |
4.1K |
5W / 2.4h |
1W / 1.2h |
1W / 1.2h |
16 |
15.6K |
10W / 3.2h |
40W / 5.5h |
46W / 5.9h |
32 |
55.8K |
259W / 14.9h |
188W / 9.6h |
232W / 13.8h |
Lowering the dimension had a very detrimental effect on performance, so I kept d = 32 and chose 4 heads instead of 2, which performed better on evaluation.
After that, I tested how much performance depends on the number of causal layers:
| Causal Layers | Params | Val Loss | Easy (1k) | Hard (1k) |
|---|---|---|---|---|
1 |
24.9K |
0.537 |
193W (8.7h) |
2W (9.6h) |
2 |
35.2K |
0.489 |
234W (9.5h) |
3W (11.8h) |
4 |
55.8K |
0.459 |
232W (9.6h) |
4W (13.8h) |
6 |
76.4K |
0.450 |
279W (10.0h) |
4W / 3D (14.6h) |
8 |
97.0K |
0.434 |
223W (8.8h) |
3W (11.6h) |
Changing the number of causal layers didn’t produce a big performance drop-off or gain, so I stayed with my original value of 4.
6. Self-Play RL
Now the interesting part of this whole project: the post-training pipeline.
I went with GRPO using only terminal +1 / 0 / -1 win/draw/loss rewards (no reward shaping), specifically Dr. GRPO. In standard GRPO, two extra divisions create subtle biases:
Dividing each game by its own length () shrinks the penalty on longer losses, accidentally incentivizing the model to stall out losing rallies instead of taking risks to win. Dividing advantages by the group standard deviation () amplifies updates on easy, lopsided serves (e.g. 31/32 wins, where is tiny) and downweights contested 50/50 serves where the model actually has the most to learn.
Dr. GRPO removes both, dividing by a fixed constant ( across the batch) and simply centering rewards:
Self-play algorithms usually face an opponent sampling problem: you want to play against the latest version to keep improving, without forgetting how to beat earlier versions and falling into rock-paper-scissors cycling. To avoid this, I used an AlphaStar-inspired opponent pool (PFSP):
- Growing the pool: Starting from the pretrained
Refmodel, every10steps I run100eval games against the newest snapshot in the pool. If the current policy achieves a win rate , I freeze a copy of it and add it to the pool. - Picking opponents: Each step runs
2,048games (64groups32rollouts) to get a smooth gradient even with no intermediate rewards, split across up to8distinct opponents (always the latest snapshot, plus up to7older ones). Older snapshots are sampled with probability , where is the current policy’s estimated win rate against snapshot (starting at0.5and updated after each step from the rollout win rate via ).
For the final ablation, I ran 500 steps comparing a frozen vs unfrozen vision encoder. After training, I ran a round-robin tournament across every 50-step checkpoint from both runs (1,000 games per pair, 210,000 total) to estimate their relative strength with an Elo score anchored at Ref = 1000. Additionally, I played 25 games against the pretrained Ref policy to establish a human baseline (11W-14L, 958 Elo).
Frozen vision starts to slow down toward the end of training, while the unfrozen run is still climbing steadily at step 500 and pulls ahead by over 100 Elo. Even though it clearly had more room to grow, I decided to stop training here since I had already spent enough time and compute on this project.
| Policy | Elo | vs Ref | Easy (1k) | Hard (1k) |
|---|---|---|---|---|
Human (25g) |
958 |
44.0% |
- |
- |
Ref (55.8K) |
1000 |
50.0% |
232W (9.6h) |
4W (13.8h) |
Frozen (41.4K) |
1361 |
88.7% |
661W (15.7h) |
3W (27.2h) |
Unfrozen (55.8K) |
1464 |
92.6% |
766W (16.8h) |
15W (40.4h) |
References
- George Kurian and Susie Xia. From Pixels to Physical Motion: Building World Action Models (WAM) with PyTorch & NVIDIA Cosmos. PyTorch Conference, San Jose (2026). Video
- Yian Zhao, Wenyu Lv, Shangliang Xu, Jinman Wei, Guanzhong Wang, Qingqing Dang, Yi Liu, and Jie Chen. DETRs Beat YOLOs on Real-time Object Detection (RT-DETR) (2023). arXiv:2304.08069
- Guangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han, and Mike Lewis. Efficient Streaming Language Models with Attention Sinks (2023). arXiv:2309.17453
- Zichen Liu, Changyu Chen, Wenjun Li, Penghui Qi, Tianyu Pang, Chao Du, Wee Sun Lee, and Min Lin. Understanding R1-Zero-Like Training: A Critical Perspective (Dr. GRPO) (2025). arXiv:2503.20783
- Oriol Vinyals et al. Grandmaster level in StarCraft II using multi-agent reinforcement learning (AlphaStar). Nature 575, 350–354 (2019). Paper