Git Product home page Git Product logo

z-quantum-qubo's Introduction

z-quantum-qubo

codecov

What is it?

z-quantum-qubo is a library with functions for manipulating Quadratic Unconstrained Binary Optimization problems (QUBO) used for Orquestra โ€“ the platform developed by Zapata Computing for performing computations on quantum computers. It's mostly a wrapper around the dimod package.

Usage

Workflow

In order to use z-quantum-qubo in your workflow, you need to add it as an import in your Orquestra workflow:

imports:
- name: z-quantum-qubo
  type: git
  parameters:
    repository: "[email protected]:zapatacomputing/z-quantum-qubo.git"
    branch: "main"

and then add it in the imports argument of your step:

- name: my-step
  config:
    runtime:
      language: python3
      imports: [z-quantum-qubo]

Once that is done you can:

  • use any z-quantum-qubo function by specifying its name and path as follows:
- name: generate-random-qubo
  config:
    runtime:
      language: python3
      imports: [z-quantum-qubo]
      parameters:
        file: z-quantum-qubo/steps/utils.py
        function: generate_random_qubo
  • use tasks which import zquantum.qubo in the python code (see below)

Python

Here's an example of how to use methods from z-quantum-qubo in a python task:

from zquantum.qubo import generate_random_qubo
qubo = generate_random_qubo(10)

Even though it's intended to be used with Orquestra, z-quantum-qubo can be also used as a standalone Python module. To install it, you just need to run pip install -e . from the main directory.

Development and Contribution

  • If you'd like to report a bug/issue please create a new issue in this repository.
  • If you'd like to contribute, please create a pull request.

Running tests

Unit tests for this project can be run using pytest . from the main directory.

z-quantum-qubo's People

Contributors

alexjuda avatar dexter2206 avatar jamesclark-zapata avatar max-radin avatar mstechly avatar shiro-raven avatar simonwa7 avatar vsergeyev avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

00mjk

z-quantum-qubo's Issues

Saving BinaryQuadraticModel with save_qubo() not preserve variables defined as Python tuples

This issue occurs when using save_qubo function to save BinaryQuadraticModel.

It saves model good, except for a Python tuples converted to JSON arrays. Need to note, this is normal behavior for JSON format.

One gotcha maybe when it will be required to use tuple format for BQM variables.

Below is a slightly modified example from dimod's BinaryQuadraticModel documentation with demo of issue:

>>> bqm = dimod.BinaryQuadraticModel({(0, 0): 1, (1, 0): -1, (2, 0): .5}, {((0, 0), (1, 0)): .5, ((1, 0), (2, 0)): 1.5}, 1.4, dimod.Vartype.SPIN)
>>> bqm
BinaryQuadraticModel({(0, 0): 1.0, (1, 0): -1.0, (2, 0): 0.5}, {((0, 0), (1, 0)): 0.5, ((1, 0), (2, 0)): 1.5}, 1.4, 'SPIN')
>>> save_qubo(bqm, '42.json')
>>> load_qubo('42.json')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/vova/z-quantum-qubo/src/python/zquantum/qubo/io.py", line 68, in load_qubo
    return bqm_from_serializable(qubo_dict)
  File "/home/vova/z-quantum-qubo/src/python/zquantum/qubo/io.py", line 53, in bqm_from_serializable
    {i: coef for i, coef in serializable["linear"]},
  File "/home/vova/z-quantum-qubo/src/python/zquantum/qubo/io.py", line 53, in <dictcomp>
    {i: coef for i, coef in serializable["linear"]},
TypeError: unhashable type: 'list'
>>> with open('42.json') as f:
...     print(f.read())
... 
{"linear": [[[0, 0], 1.0], [[1, 0], -1.0], [[2, 0], 0.5]], "quadratic": [[[0, 0], [1, 0], 0.5], [[1, 0], [2, 0], 1.5]], "offset": 1.4, "vartype": "SPIN", "schema": "zapata-v1-qubo"}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.