A Multi-agent AI System for Deep Learning Model Migration from TensorFlow to JAX
Organizations: Google Munich, Germany · Google Mountain View, California, USA · Google Sunnyvale, California, USA
Abstract
The rapid development of AI-based products and their underlying models has led to constant innovation in deep learning frameworks. Google has been pioneering machine learning usage across dozens of products. Maintaining the multitude of model source codes in different ML frameworks and versions is a significant challenge. So far the maintenance and migration work was done largely manually by human experts. We describe an AI-based multi-agent system that we built to support automatic migration of TensorFlow-based deep learning models into JAX-based ones. We make three main contributions: First, we show how an AI planner that uses a mix of static analysis with AI instructions can create migration plans for very complex code components that are reliably followed by the combination of an orchestrator and coders, using AI-generated example-based playbooks. Second, we define quality metrics and AI-based judges that accelerate development when the code to evaluate has no tests and has to adhere to strict style and dependency requirements. Third, we demonstrate how the system accelerates code migrations in a large hyperscaler environment on commercial real-world use-cases. Our approach dramatically reduces the time (6.4x-8x speedup) for deep learning model migrations and creates a virtuous circle where effectively AI supports its own development workflow. We expect that the techniques and approaches described here can be generalized for other framework migrations and general code transformation tasks.
Figures & tables
| Playbook Type | Focus and Content | Role in Execution | Update Cadence |
|---|---|---|---|
| General Instruction | Provides fundamental capabilities, instructing the agent on tools necessary to read, write, search, and interact with Google’s monorepo system. | Used by almost every agent to interact with Google’s monorepo. | Updated only when new tools are added. |
| Style Playbook | Developed for focused tasks, such as a style playbook containing Google-specific coding style rules. | Used specifically for coding tasks. | Updated very rarely and manually when style guide violations are detected. |
| Task-Specific | Tailored for specific tasks, such as the TensorFlow to Flax Linen migration. | Provides generally applicable instructions for coding tasks. | Updated whenever we discover new generally applicable instructions for the task. |
| Client-Specific (e.g., YouTube) | Contains use-case-specific requirements and preferred libraries. | The primary source of task-relevant information, used as part of the prompt for both planning and coding tasks. | Updated iteratively after each full execution to improve capabilities for the specific task (e.g., refining imports). |
| Model | Line Count (Main/Deps.) | Layers | Metrics |
|---|---|---|---|
| small_1 | 0.5k / 500 | 20 | 20 |
| small_2 | 0.4k / 500 | 17 | 25 |
| medium_1 | 2.2k / 1k | 40 | 30 |
| medium_2 | 2.3k / 3k | 40 | 60 |
| large_1 | 2.7k / 13k | 250 | 400 |
| large_2 | 2.9k / 9k | 130 | 210 |
| Configuration | Style & Task | Client | Planner & |
|---|---|---|---|
| Playbook | Playbook | Orchestrator | |
| single_agent_baseline | No | No | No |
| single_agent_yt_specific | Yes | Yes | No |
| multi_agent | Yes | No | Yes |
| multi_agent_yt_specific | Yes | Yes | Yes |
| Model | multi_agent | multi_agent_yt_specific | single_agent_baseline | single_agent_yt_specific |
|---|---|---|---|---|
| large_1 | 0.31 | 0.65 | 0.09 | 0.14 |
| large_2 | 0.42 | 0.59 | 0.22 | 0.33 |
| medium_1 | 0.73 | 0.90 | 0.43 | 0.43 |
| medium_2 | 0.53 | 0.75 | 0.38 | 0.44 |
| small_1 | 0.70 | 0.95 | 0.66 | 0.48 |
| small_2 | 0.87 | 0.82 | 0.59 | 0.36 |
| Model | Line Count | Layers | Metrics | Pure Manual Migration | AI plus Review & Fix | Speed-up |
|---|---|---|---|---|---|---|
| model_1 | 0.6k / 3k | 15 | 50 | 16 hrs | 2 hrs | 8x |
| model_2 | 4k / 20k | 250 | 300 | 32 hrs | 5 hrs | 6.4x |
AI Coding Agents
AI coding agents use language models and software tools to plan, edit, test, and maintain code with varying levels of autonomy.
See all 326 papers