Quantum Code Migration Automated with Large Language Models and Taxonomy.
The accelerating development of quantum computing necessitates robust software maintenance strategies, as application programming interfaces (APIs) within frameworks such as Qiskit undergo frequent revisions. Maintaining code compatibility across these updates presents a significant challenge for developers, demanding efficient methods for automated refactoring. Researchers at the Laboratory of Informatics of the National University of La Plata, specifically Jos´e Manuel Su´arez, Luis Mariano Bibb´o, Joaquin Bogado, and Alejandro Fernandez, address this issue in their work, “Automatic Qiskit Code Refactoring Using Large Language Models”. They present a methodology leveraging the capabilities of large language models (LLMs) to identify and resolve code migration issues, guided by a taxonomy of common API changes extracted from official Qiskit documentation. Their approach focuses on structuring input to overcome the context length limitations inherent in current LLM architectures, demonstrating a practical application of artificial intelligence to streamline quantum software development.
Quantum software development currently faces significant challenges in maintaining code compatibility as quantum computing frameworks, such as Qiskit, undergo rapid iteration and evolution This necessitates scalable and efficient maintenance strategies, prompting investigation into the application of large language models (LLMs) to automate the refactoring of Qiskit code. This work presents a methodology utilising LLMs to identify and resolve code migration issues arising from application programming interface (API) changes and deprecated functionalities, representing a crucial step towards sustainable quantum software engineering practices.
Researchers meticulously constructed a taxonomy of Qiskit migration scenarios, derived from official documentation including release notes. This taxonomy captures recurring patterns of code modification, such as the relocation of functionality between modules and the replacement of obsolete code with updated alternatives. The approach centres on providing LLMs with both the source code and this domain-specific migration knowledge, thereby enhancing their ability to accurately identify instances requiring refactoring and propose appropriate solutions. To mitigate the context length limitations inherent in current LLMs, a structured input and reasoning process ensures efficient processing of complex codebases.
Evaluation focuses on performance metrics to assess the effectiveness of the LLM-based refactoring tools. Comparisons are drawn against existing refactoring tools like RefactoringMiner 2.0 and established quantum software benchmarking tools such as MQT Bench, providing a comprehensive assessment of the new methodology. Researchers explore complex refactoring scenarios and address potential biases within LLMs to ensure the integrity of the generated code, establishing a robust and reliable system for quantum software maintenance. Techniques such as Retrieval-Augmented Generation (RAG), which enhances LLM performance by retrieving information from external knowledge sources, and instruction tuning, which refines the LLM’s understanding through specific prompts, improve the quality and reliability of the refactoring process. Furthermore, the development of multi-agent systems, utilising multiple LLMs for code translation and refactoring, represents a further avenue for exploration, increasing the scalability and efficiency of the automated system.
Future work prioritises quantifying the impact of these refactoring processes on the performance of quantum algorithms, providing a comprehensive assessment of the benefits of automated code migration. Expanding the existing taxonomy of migration scenarios remains a key objective, alongside ensuring compatibility and effectiveness with the latest Qiskit version, currently v1.0, maintaining the relevance and utility of the methodology. Addressing more complex refactoring scenarios, extending beyond basic code improvements, also forms a central part of ongoing research, pushing the boundaries of automated quantum software maintenance.
Investigation into zero-shot reasoning capabilities, where LLMs perform refactoring without specific training examples, promises to enhance the adaptability and generalisability of the system, reducing the need for extensive training data. Researchers also plan to explore further applications of retrieval-augmented generation techniques, leveraging external knowledge sources to improve the accuracy and sophistication of refactoring suggestions, enhancing the quality and reliability of the generated code.
👉 More information
🗞 Automatic Qiskit Code Refactoring Using Large Language Models
🧠 DOI: https://doi.org/10.48550/arXiv.2506.14535