Published on March 5, 2026

AI improves its own code: how large language models self-optimize

How AI Learns to Improve Its Own Code: An Experiment in Self-Optimization

AMD researchers have demonstrated how an AI agent can iteratively optimize high-performance code without human intervention.

Research / Technical context 4 – 6 minutes min read
Event Source: AMD 4 – 6 minutes min read

Large language models are quite good at writing code. This is hardly news – millions of developers use AI assistants in their daily work. But it's one thing to write a functional snippet and quite another to write the fastest possible code. This is especially true for computations where every millisecond counts: scientific simulations, data processing, and machine learning tasks.

This is precisely what the new experiment from the AMD team addresses. In the second part of their series on AI agents for high-performance computing (HPC), researchers showed how a language model can be made to not just generate code, but to iteratively improve it – repeatedly, until performance reaches the desired level.

Writing code versus optimizing it effectively

The Problem: Writing Isn't Optimizing

When we ask an AI to write code, it usually produces something that works. But 'working' and 'fast' are not the same thing. In high-performance computing, code must make the most of the hardware's capabilities: parallel computing, memory features, and the specifics of a particular processor or graphics card.

A human expert handles this through iterations: writing, running, measuring, and rewriting. And the rewriting isn't random; it's based on an understanding of what is slowing the program down. Can an AI be taught to do the same?

The answer proposed by the authors of the publication is yes – if you give the model the right tools and the right feedback.

OpenEvolve: how AI optimizes code through evolution

OpenEvolve: Code Evolution as a Strategy

At the core of the experiment is a tool called OpenEvolve. Simply put, it's a system that approaches code optimization in the same way biological evolution approaches survival: through numerous attempts, selection of the best variants, and gradual improvement.

Here's how it works in practice:

  1. The AI agent receives the source code and the task – to make it faster.
  2. The model suggests changes: rewriting snippets, trying different approaches.
  3. Each variant is run and measured to see how fast it is compared to the previous one.
  4. The best variants 'survive' and become the basis for the next round of changes.
  5. The cycle repeats.

This isn't just 'asking the AI to rewrite the code.' It's a guided iterative process, where each iteration is based on actual performance measurements, not on the model's intuition.

MCP: AI agent interaction with optimization tools

MCP: How the Agent 'Talks' to Tools

A separate part of the experiment deals with how precisely the AI agent interacts with optimization tools. It uses an approach called MCP (Model Context Protocol), which is, in short, a standardized way for a language model to call external tools and receive results from them.

Imagine the agent has 'hands': it can run the code, get the measurement result, pass it back to the model, and the model then decides on the next step. MCP describes precisely how these 'hands' are structured and how to use them.

This is a crucial point because, without this connection, the agent would be limited to its own internal assumptions about what works well and what doesn't. With MCP, it receives real data from a real environment, and this fundamentally changes the quality of the optimization.

Experiment results: AI code optimization for HPC

The End Result

The experiment was conducted on tasks from the field of high-performance computing – those where GPU speed is critical. The results showed that the iterative approach with OpenEvolve genuinely allows the agent to find more performant solutions than what it would have proposed on the first try.

This doesn't mean the AI has surpassed an experienced optimization engineer. But it does demonstrate a working concept: automated optimization through iterations and measurements is a feasible idea, not just a theory.

For developers working on computationally intensive tasks, this could mean a new tool in their arsenal: not 'ask an AI to write fast code,' but 'launch an agent that will improve the code until it reaches the goal.'

Broader impact of iterative AI code improvement

Why This Is Interesting Beyond HPC

High-performance computing is a rather specific field. But the logic demonstrated by this experiment has broader applications.

Iterative improvement with feedback is, in essence, how any good engineering process works. And if an AI agent can integrate into this process not as a generator of ready-made solutions, but as a participant in the 'try-measure-improve' cycle, it changes how we think about development automation as a whole.

For now, such systems require configuration, contextual understanding, and a clear definition of what exactly we want to optimize. The agent doesn't know on its own that 'faster' is better until we tell it how to measure it. But this is a reasonable limitation, not a fundamental barrier.

Future directions and open questions for AI code optimization

Open Questions

Like any experiment, this work leaves some questions open.

How well does the approach scale to more complex codebases? What happens when optimizing one snippet degrades another? How does the agent handle situations where 'faster' is difficult to measure directly?

These questions don't devalue the result – they simply point the way for the next steps. And the very fact that AMD is publicly sharing such experiments suggests that the topic of AI agents for development is moving beyond research labs and becoming part of the practical engineering agenda.

Original Title: HPC Coding Agent – Part 2: An MCP Tool for Code Optimization with OpenEvolve – ROCm Blogs
Publication Date: Mar 4, 2026
AMD www.amd.com An international company manufacturing processors and computing accelerators for AI workloads.
Previous Article How Helion Automatically Tunes Itself for a Task Next Article SysOM MCP: When AI Figures Out What's Wrong with Your Server

Related Publications

You May Also Like

Explore Other Events

Events are only part of the bigger picture. These materials help you see more broadly: the context, the consequences, and the ideas behind the news.

From Source to Analysis

How This Text Was Created

This material is not a direct retelling of the original publication. First, the news item itself was selected as an event important for understanding AI development. Then a processing framework was set: what needs clarification, what context to add, and where to place emphasis. This allowed us to turn a single announcement or update into a coherent and meaningful analysis.

Neural Networks Involved in the Process

We openly show which models were used at different stages of processing. Each performed its own role — analyzing the source, rewriting, fact-checking, and visual interpretation. This approach maintains transparency and clearly demonstrates how technologies participated in creating the material.

1.
Claude Sonnet 4.6 Anthropic Analyzing the Original Publication and Writing the Text The neural network studies the original material and generates a coherent text

1. Analyzing the Original Publication and Writing the Text

The neural network studies the original material and generates a coherent text

Claude Sonnet 4.6 Anthropic
2.
Gemini 2.5 Pro Google DeepMind step.translate-en.title

2. step.translate-en.title

Gemini 2.5 Pro Google DeepMind
3.
Gemini 2.5 Flash Google DeepMind Text Review and Editing Correction of errors, inaccuracies, and ambiguous phrasing

3. Text Review and Editing

Correction of errors, inaccuracies, and ambiguous phrasing

Gemini 2.5 Flash Google DeepMind
4.
DeepSeek-V3.2 DeepSeek Preparing the Illustration Description Generating a textual prompt for the visual model

4. Preparing the Illustration Description

Generating a textual prompt for the visual model

DeepSeek-V3.2 DeepSeek
5.
FLUX.2 Pro Black Forest Labs Creating the Illustration Generating an image based on the prepared prompt

5. Creating the Illustration

Generating an image based on the prepared prompt

FLUX.2 Pro Black Forest Labs

Want to know about new
experiments first?

Subscribe to our Telegram channel — we share all the latest
and exciting updates from NeuraBooks.

Subscribe