Omnisolver: an extensible interface to Ising spin–glass and QUBO solvers

We introduce a new framework for implementing Binary Quadratic Model (BQM) solvers called Omnisolver. The framework provides an out-of-the-box dynamically built command-line interface as well as an input/output system, thus heavily reducing the effort required for implementing new algorithms for solving BQMs. The proposed software should be of benefit for researchers focusing on quantum annealers or discrete optimization algorithms as well as groups utilizing discrete optimization as a part of their daily work. We demonstrate the ease of use of the proposed software by presenting a step-by-step, concise implementation of an example plugin.


Motivation and significance
The rapidly developing field of quantum information brings us ever closer to developing practical quantum computers.Currently, we are living in an era marked by the so-called Noisy Intermediate-Scale Quantum (NISQ) [1] devices.It comes as no surprise that these machines have attracted attention from both the scientific and business communities.This attention results in a myriad of proposed potential applications for NISQ devices.Implementing these applications requires developing appropriate software, which comes with its own set of challenges.One of such potential obstacles, which this work aims to remedy, is the cost of testing on actual NISQ devices.
The main way to cut quantum infrastructure access costs is to utilize frameworks that simulate or approximate their behavior.Nonetheless, if we try this approach, we quickly run into another problem: there are multiple frameworks available, each of which can be based on different numerical algorithms.Here, we are concerned with one particular NISQ architecturethe D-Wave annealer.The behavior of this machine can be simulated using tensor networks [2,3], approximated using dynamical systems approach [4], neural networks [5] and, for sufficiently small problem sizes, through a bruteforce approach [6].
The downside of this multitude of options is that the implementations of each of these approaches have incompatible input/output APIs.In this work, we introduce the Omnisolver package which provides an extensible, unified API for Ising spin-glass solvers and the actual D-Wave annealer.
The Omnisolver's core motivation lies in addressing the fragmentation and compatibility issues that can often stymie the development of quantum software.By providing a unified API for Ising spin-glass solvers and the D-Wave annealer, our solution presents a uniform interface to the users, allowing the development of algorithms to be performed in a more simplified, streamlined manner.
One of the significant advantages of this approach is that it eliminates the need for developers to learn and adapt to the varied input/output APIs of different solvers or to become entwined in the technical complexities of switching between them.Instead, they can devote their full attention and resources to designing, implementing, and fine-tuning their algorithms, hence accelerating the overall development process.The ease of integration further encourages experimentation with different approaches, fostering innovation within the field.
Omnisolver is builds upon the D-Wave's dimod framework.Our software extends dimod's capabilities in two ways.Firstly, Omnisolver's plugin library provides additional, high-performance algorithms readily usable from Python scripts or command line.Secondly, and more importantly, the Omnisolver's core library provides an automatic construction of a command line interface and a unified input/output system automatically wired to the implemented solvers.Having a framework that not only consolidates existing methods but also allows for the easy addition and integration of new ones is in our opinion a valuable asset.
In this context, the claim about a reduction in the effort required to write new algorithms is not meant to indicate that Omnisolver directly simplifies the algorithm-writing process, but rather that it facilitates and expedites the process by providing a more consistent, comprehensive, and accommodating environment for developers.By simplifying the integration with various solvers and enabling easy swapping of them for testing and comparison, Omnisolver significantly reduces the peripheral tasks associated with quantum software development, leaving developers more time and energy to focus on their core task: creating and optimizing algorithms.
Compared to other similarly looking libraries like pyQUBO or QUBOTools.jlour package provides a significant new feature.pyQUBO [7,8] provides a platform to formulate and solve QUBO and Ising problems.It does this by converting combinatorial optimization problems to QUBO or Ising problems, which can then be solved by annealing machines.While pyQUBO is a valu-able tool, its scope is limited to problem formulation and conversion; it does not provide an integrated approach to using various solving methods.
In contrast, Omnisolver's unified API allows it to handle a broader set of tasks.By providing a consistent interface to multiple solvers, including both Ising spin-glass solvers and D-Wave annealer, it significantly simplifies the process of experimenting with different approaches and offers greater flexibility to the user.
QUBO.jl [9], a Julia library, shares a similar purpose with pyQUBO.It assists in the formulation of QUBO problems from a combinatorial optimization standpoint, offering various utility functions for working with QUBO matrices.The use of Julia allows for high-performance computations, particularly beneficial when dealing with large-scale problems.Compared to Omnisolver, QUBO.jl provides similar problem formulation capabilities and offers a similar, extensible platform for integrating and testing various QUBO and Ising solvers.The main difference between QUBO.jl and Omnisolver is the underlying technology.Omnisolver, beeing written in pure Python, allows for seamless integration with external solvers accessed via public APIs, like for example D-Wave's quantum annealer.Additionally, we provide a specialized plugin for brute-force solving of QUBO problems, which guarantees finding the optimal solution and has a reasonable execution time for instances of up to 50 variables which allows for certification of results obtained from other methods.These features make Omnisolver a more comprehensive tool, catering to a broader spectrum of the QUBO and Ising problem-solving workflows.
Furthermore, it is important to acknowledge the vast landscape of Ising machines, as reviewed in [10].These machines, both software and hardwarebased, have made significant strides in solving complex combinatorial problems.However, many of these implementations operate in isolation and come with their own specific input/output requirements, adding to the complexity of algorithm development and testing.

Software Architecture
Omnisolver is built in a modular fashion and comprises the following elements: • core Omnisolver package, • plugins providing samplers built on top of dimod library [11].
The architecture of the Omnisolver, as well as the typical execution flow, is presented in Fig. 1.The core package handles input/output operations, including parsing the command line arguments, reading an input problem file, and outputting solutions computed by samplers.It can be extended via a plugin system built using the pluggy [12] library.The plugins are responsible for implementing algorithms solving instances of Ising spin-glass or QUBO models (collectively known as Binary Quadratic Models) and providing descriptions of available parameters.At the start of the program the core package auto-discovers the plugins, and collects the description of the samplers they implement.Based on those descriptions, a Command Line Interface (CLI) is constructed and exposed to the user.Using the CLI, the user selects which sampler, and with what parameters, should be used.The core package then asks the plugin to instantiate the sampler, uses it to solve the provided problem instance, and then serializes the output.
The plugin definition comprises: • name of the plugin, • the create sampler function used to construct new sampler instances, • the populate parser callback used for defining command line arguments used for creating sampler and running its sample method.
• init args and sample args determining which command line arguments should be passed respectively to sampler's initializer and sample method.
Omnisolver extensions should provide one or more callables decorated with omnisolver.plugin.pluginimpl returning an instance of Plugin class.

Software Functionalities
The major functionality of the Omnisolver project is providing a framework for implementing arbitrary solvers of classical Ising spin-glasses.To this end, the core omnisolver package provides: • plugin system for registering solvers inheriting from dimod.Sampler, • helper functions for implementing most typical plugins which remove the burden of writing plugin boilerplate from the end-user, • input/output system automatically wired to the plugins.Currently, this allows reading spin-glass instances from coordinate format and writing solutions as a comma-separated value (CSV) file, • dynamically generated command line interface (CLI).The CLI takes into account information provided by the registered plugins, and hence is able to correctly recognize parameters that need to be passed to each solver.

Sample code snippets analysis
Code snippets in this section demonstrate an example implementation of an Omnisolver plugin, providing a dummy solver returning random solutions.While this example is clearly artificial, it should be easy for the reader to extend it to an implementation of an arbitrary nontrivial solver.The plugin is implemented as a Python package called dummysolver.The layout of the package is shown in the Listing 1, and the Fig. 2 summarizes the relationship between the package's essential components.The dummysolver/solver.py file, presented in Listing 2, contains the implementation of the solver.The DummySolver class inherits from dimod.Sampler and implements its abstract sample method.This method accepts an instance of dimod.BinaryQuadraticModel (required by the base class' sample method) and an additional keyword parameter num solutions indicating how many solutions should be returned.To inform the Omnisolver's plugin system about DummySolver, one needs to provide information about the solver's class, displayed name, and parameters accepted by the solver and their command line counterparts.The easiest way to achieve this is by providing the information in the YAML file, as exemplified by Listing 3. schema_version : 1 name : " dummy " sampler_class : " dummysolver .solver .DummySolver " description : " Uniformly random dummy sampler " init_args : [] sample_args : -name : " num_solutions " help : " number of sampled solutions " type : int default : 1 Listing 3: dummysolver/dummy.yml The init args field, specified as an empty list in the example, defines parameters for the solver's init method.The sample args list describes the parameters of the solver's sample method.In principle, one could always design the plugin in such a way that all parameters are passed to the sample method of the sampler, and thus it might seem redundant to include init args as well.However, to support samplers with a parametrized initializer that already exist on the market, we decided to include the initializer's args as well.An example of such a sampler is the D-Wave's DWaveSampler, which can accept several parameters during its initialization [13].
One also needs to define the plugin's entrypoint, which in this case is located in the package's initialization file (Listing 4).Here, we used Omnisolver's convenience function plugin from specification for building the plugin from the definition read from the YAML file.Finally, the entrypoint has to be defined in the package's setup file (Listing 5) to be picked up by the plugin system.from omnisolver .plugin import ( plugin_from_specification , plugin_impl , ) from pkg_resources import resource_stream from yaml import safe_load @plugin_impl def get_plugin () : """ Construct plugin from given yaml file .""" specification = safe_load ( resource_stream ( " dummysolver " , " dummy .yml " ) ) return p l u g i n _ f r o m _ s p e c i f i c a t i o n ( specification ) Listing 4: dummysolver/ init .py

Illustrative Examples
Examples in this section assume that omnisolver, omnisolver-pt and dummysolver (presented in Subsection 2.3) are installed in the current Python environment.
The available solvers can be displayed by running omnisolver -h, as exemplified in Listing 6 Help for the specific solver, automatically constructed using Python's standard library argparse module, can be obtained by running omnisolver <solver-name> -h.Listing 7 shows an example output of running command omnisolver pt -h.Finally, let us demonstrate solving an instance of the Ising spin-glass using a chosen solver.To this end, let us assume that the instance file instance.txtas presented in Listing 8 is present in the current directory.The input file comprises rows of the form "i j J ij".Here, i and j are indices of variables and J ij is the coupling coefficient between them.In the case of i = j, the J ii coefficient is treated as linear bias (magnetic field) acting on the i-th spin.For the QUBO formulation, the last element in the row is naturally interpreted as either the quadratic or linear term.
Running omnisolver pt instance.txt--vartype=SPIN yields result similar to the one presented in Listing 9.

Impact
This software has two main contributions.Firstly, it provides a unified framework for implementing Ising or QUBO solvers.As such, it should accelerate the process of implementing new algorithms, saving the developers the time needed for writing code handling CLI and input/output system.For the researchers, common CLI and input/output interface should make it easier to interchangeably use a variety of solvers, thus decreasing time needed for preparing and running experiments.In particular, this will mainly benefit entities that face combinatorial optimization problems in their daily routine, such as railway companies.As an example of such an application, we refer an interested reader to the works [14,15].
Secondly, Omnisolver provides several readily available samplers implemented as its plugins, including the parallel-tempering sampler and the brute-force sampler capable of finding low-energy spectra of instances with sizes similar to the largest cliques embeddable on present-day D-Wave hardware.To emphasize the usefulness of the currently implemented solver, in Fig. 3 we present initial performance benchmarks for Omnisolver's bruteforce sampler.

Conclusions
We provide the community interested in quantum computing with an extensible framework allowing for communication with various computational backend for solving Ising spin-glasses or QUBOs.The plugins for the framework may implement numerical algorithms as well as serve as interfaces to actual computing devices.
We plan further development of plugins for Omnisolver, which already contains implementations of such algorithms as exhaustive search or parallel tempering.The community is also encouraged to provide their own implementations when coming up with interesting approaches to solving Ising instances.

Conflict of Interest
No conflict of interest exists: We wish to confirm that there are no known conflicts of interest associated with this publication and there has been no significant financial support for this work that could have influenced its outcome.

Figure 3 :
Figure3: Performance of the GPU-accelerated Omnisolver-bruteforce sampler using a variable number of GPUs.The x-axis shows the problem size, and the y-axis shows the time needed to solve it using 1,2,4 and 8 NVIDIA A100 GPUs.

Table 1 :
Code metadata