Omnisolver: an extensible interface to Ising spin glass 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 input/output system, thus heavily reducing the eﬀort required for implementing new algorithms for solving BQMs. The proposed software should be of beneﬁt 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.One of the potential obstacles in developing quantum software, 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 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 architecture -the D-Wave annealer.The behavior of this machine can be simulated using a tensor network approach [2,3], dynamical system approach [4], neural networks [5] and, for sufficiently small problem sizes, through a brute-force 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.

Software description
Describe the software in as much as is necessary to establish a vocabulary needed to explain its impact.

Software Architecture
Omnisolver is built in a modular fashion and comprises the following elements: • main Omnisolver framework, • plugins providing samplers built on top of dimod library [7].
The framework handles input/output operations, including parsing command line arguments, reading an input problem file, and outputting solutions computed by samplers.It can be extended via plugin system built using pluggy [8] library.The plugins are responsible for implementing algorithms solving Binary Quadratic Models and providing descriptions of available parameters. Figure 1 demonstrates the relationship between the main framework and plugins, as well as the typical execution flow of the solver.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 relationship between package's essential components.The dummysolver/solver.py file, presented in Listing 2, contains the actual implementation of the solver.The DummySolver class inherits from dimod.Sampler and provides implementation of 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 omnisolver's plugin system about DummySolver, one needs to provide information about solver's class, displayed name, 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 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.

optional arguments :
-h , --help show this help message and exit Solvers : { pt , dummy , random } Listing 6: Example of running omnisolver -h Help for the specific solver 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.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 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 application, we refer an interested reader to the works [9,10].
Secondly, Omnisolver provides new, faster implementation of the bruteforce algorithm utilizing Gray's codes.As such, it allows us to find exact low-energy spectrum for larger (up to 64 variables) problems, similar in size to the largest cliques embeddable on present-day D-Wave hardware.

Conclusions
We provide the community interested in quantum computing with a tool which provides an extensible framework allowing for communication with various computational backends.These can include various numerical solvers to these instances as well as actual quantum computing devices, such as the D-Wave annealer.
During the development of our future solver backends, we will provide accompanying plugins for omnisolver in order to provide a unified input/output interface.The broader 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.