dwavesystems / dwave-system

An API for easily incorporating the D-Wave system as a sampler, either directly or through Leap's cloud-based hybrid samplers
https://docs.ocean.dwavesys.com/
Apache License 2.0
87 stars 63 forks source link

Raise a more informative error message when passing BQM to DQM sampler #375

Open arcondello opened 3 years ago

arcondello commented 3 years ago

Currently LeapHybridDQMSampler().sample_dqm(bqm) raises AttributeError: 'BinaryQuadraticModel' object has no attribute 'num_variable_interactions', this should be more informative.

Abdullahjavednesar commented 2 years ago

Hi @arcondello, I am a newbie and would like to try this out.

As a first step, how can I reproduce this issue in my local?

arcondello commented 2 years ago

Hi @Abdullahjavednesar , something like

import dimod

from dwave.system import LeapHybridDQMSampler

bqm = dimod.BinaryQuadraticModel('SPIN')

LeapHybridDQMSampler().sample_dqm(bqm)

should reproduce it.

davidmerwin commented 2 years ago

❤️

Abdullahjavednesar commented 2 years ago

I am facing an issue installing minorminer in my mac, getting the following error.

Building wheels for collected packages: minorminer
  Building wheel for minorminer (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for minorminer (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [2280 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-10.15-x86_64-3.7
      creating build/lib.macosx-10.15-x86_64-3.7/minorminer
      copying minorminer/package_info.py -> build/lib.macosx-10.15-x86_64-3.7/minorminer
      copying minorminer/minorminer.py -> build/lib.macosx-10.15-x86_64-3.7/minorminer
      copying minorminer/__init__.py -> build/lib.macosx-10.15-x86_64-3.7/minorminer
      creating build/lib.macosx-10.15-x86_64-3.7/minorminer/layout
      copying minorminer/layout/layout.py -> build/lib.macosx-10.15-x86_64-3.7/minorminer/layout
      copying minorminer/layout/__init__.py -> build/lib.macosx-10.15-x86_64-3.7/minorminer/layout
      copying minorminer/layout/placement.py -> build/lib.macosx-10.15-x86_64-3.7/minorminer/layout
      creating build/lib.macosx-10.15-x86_64-3.7/minorminer/utils
      copying minorminer/utils/__init__.py -> build/lib.macosx-10.15-x86_64-3.7/minorminer/utils
      copying minorminer/utils/pegasus.py -> build/lib.macosx-10.15-x86_64-3.7/minorminer/utils
      copying minorminer/utils/diagnostic.py -> build/lib.macosx-10.15-x86_64-3.7/minorminer/utils
      copying minorminer/utils/polynomialembedder.py -> build/lib.macosx-10.15-x86_64-3.7/minorminer/utils
      copying minorminer/utils/chimera.py -> build/lib.macosx-10.15-x86_64-3.7/minorminer/utils
      copying minorminer/utils/exceptions.py -> build/lib.macosx-10.15-x86_64-3.7/minorminer/utils
      running build_ext
      building 'minorminer._minorminer' extension
      creating build/temp.macosx-10.15-x86_64-3.7
      creating build/temp.macosx-10.15-x86_64-3.7/minorminer
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -Iminorminer -I -I./include/ -I./include/find_embedding -I/Users/anesa00/.pyenv/versions/3.7.8/envs/dwave-system/include -I/Users/anesa00/.pyenv/versions/3.7.8/include/python3.7m -c ./minorminer/_minorminer.cpp -o build/temp.macosx-10.15-x86_64-3.7/./minorminer/_minorminer.o -std=c++11 -Wall -Wno-format-security -Ofast -fomit-frame-pointer -DNDEBUG -fno-rtti
      In file included from ./minorminer/_minorminer.cpp:35:
      In file included from /Users/anesa00/.pyenv/versions/3.7.8/include/python3.7m/Python.h:25:
      In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:64:
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:93:16: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
              unsigned char   *_base;
                              ^
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:93:16: note: insert '_Nullable' if the pointer may be null
              unsigned char   *_base;
                              ^
                                _Nullable
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:93:16: note: insert '_Nonnull' if the pointer should never be null
              unsigned char   *_base;
                              ^
                                _Nonnull
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:138:32: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
              int     (* _Nullable _read) (void *, char *, int);
                                                ^
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:138:32: note: insert '_Nullable' if the pointer may be null
              int     (* _Nullable _read) (void *, char *, int);
                                                ^
                                                 _Nullable
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:138:32: note: insert '_Nonnull' if the pointer should never be null
              int     (* _Nullable _read) (void *, char *, int);
                                                ^
                                                 _Nonnull
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:138:40: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
              int     (* _Nullable _read) (void *, char *, int);
                                                        ^
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:138:40: note: insert '_Nullable' if the pointer may be null
              int     (* _Nullable _read) (void *, char *, int);
                                                        ^
                                                         _Nullable
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:138:40: note: insert '_Nonnull' if the pointer should never be null
              int     (* _Nullable _read) (void *, char *, int);
                                                        ^
                                                         _Nonnull
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:139:35: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
              fpos_t  (* _Nullable _seek) (void *, fpos_t, int);
                                                ^
      /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/_stdio.h:139:35: note: insert '_Nullable' if the pointer may be null
              fpos_t  (* _Nullable _seek) (void *, fpos_t, int);
                                                ^
                                                 _Nullable
...
...
...
      ./minorminer/_minorminer.cpp:794:34: note: expanded from macro '__Pyx_sst_abs'
          #define __Pyx_sst_abs(value) std::abs(value)
                                       ^
      ./minorminer/_minorminer.cpp:18292:16: note: use function 'std::abs' instead
      ./minorminer/_minorminer.cpp:794:34: note: expanded from macro '__Pyx_sst_abs'
          #define __Pyx_sst_abs(value) std::abs(value)
                                       ^
      ./minorminer/_minorminer.cpp:18292:16: note: include the header <cstdlib> or explicitly provide a declaration for 'std::abs'
      ./minorminer/_minorminer.cpp:794:34: note: expanded from macro '__Pyx_sst_abs'
          #define __Pyx_sst_abs(value) std::abs(value)
                                       ^
      200 warnings and 13 errors generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for minorminer
Failed to build minorminer
ERROR: Could not build wheels for minorminer, which is required to install pyproject.toml-based projects

Can anyone please help.

arcondello commented 2 years ago

Hi @Abdullahjavednesar , can you try upgrading your pip and setuptools? pip install pip setuptools --upgrade. Also, do you happen to have an M1 mac?

Abdullahjavednesar commented 2 years ago

Hi @arcondello, I have tried upgrading pip and setuptools, didn't work, still the same issue. Tried multiple things nothing worked :/

Also, do you happen to have an M1 mac?

No, its an intel core i7 processor. macOS Catalina v10.15.7.

Anyways, I could reproduce the issue in another system. Can you help me as to what should be the Exception raised? Does TypeError(f"Expecting DiscreteQuadraticModel object, got {type(dqm)}" look good?

arcondello commented 2 years ago

Yes, that looks good!