How to import SAPI


I'm testing a project developed by a colleague which makes use of the SAPI library. I'm having trouble running the code because it gets stuck on the import phase, specifically on all calls to "from dwave_sapi2.*". I have already installed the Ocean SDK but this didn't seem to help. How do I fix it?




  • At this time the SAPI library is only available to users on a custom contract. It's great that you have Ocean installed though! Ocean has all the same functionality as SAPI, so with a little refactoring you can run your colleague's project. You will have to replace the SAPI function calls with Ocean functions and import the libraries they belong to. 

    Searching for the SAPI function call in the Ocean documentation may help you find the Ocean functions you need. The naming is quite similar between the packages.

    Let us know if there are any functions you can't find in Ocean and we can help you sort that out! 

    Comment actions Permalink
  • Thank you for your answer and availability.

    I have a problem to do the embedding of the logical formulation of QUBO/Ising in the physical system.
    My problem is mapped in Ising via the "dimod" function "qubo_to_ising(Q)".

    In my colleague's code to perform embedding is used the "get_hardware_adjacency(solver_name)" function, then the "find_embedding(S, A)" function is called, where S is the form of the problem in QUBO and A is the return value of the call "get_hardware_adjacency(solver_name)".

    I found the "find_embedding()" function in Ocean but I can't find a function that matches "get_hardware_adjacency(solver_name)".

    It's possible to do it? Did I do something wrong?

    Thank you very much

    Comment actions Permalink
  • Francesco,

    Here are two forum posts which should help in modifying your colleague's code to work with the Ocean software: 

    and .


    Comment actions Permalink
  • Thank you so much for the answer.

    Comment actions Permalink

Please sign in to leave a comment.

Didn't find what you were looking for?

New post