Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
4.84k stars 2.29k forks source link

Error: qiskit.exceptions.QiskitError: 'Cannot apply Operation: reset' #10781

Closed vandit2209 closed 10 months ago

vandit2209 commented 10 months ago

Environment

What is happening?

The code is working on colab with the same versions of the libraries. But on M1 Mac and OS: Ventura 13.5.1

Name: tqdm
Version: 4.66.1
Summary: Fast, Extensible Progress Meter
Home-page: 
Author: 
Author-email: 
License: MPL-2.0 AND MIT
Location: /usr/local/lib/python3.10/dist-packages
Requires: 
Required-by: cmdstanpy, gdown, hyperopt, kaggle, moviepy, nltk, panel, proglog, prophet, spacy, tensorflow-datasets, torchtext
---
Name: numpy
Version: 1.23.5
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org/
Author: Travis E. Oliphant et al.
Author-email: 
License: BSD
Location: /usr/local/lib/python3.10/dist-packages
Requires: 
Required-by: albumentations, altair, arviz, astropy, autograd, blis, bokeh, chex, cmdstanpy, contourpy, cufflinks, cvxpy, datascience, db-dtypes, dopamine-rl, ecos, fastdtw, flax, folium, gensim, gym, h5py, holoviews, hyperopt, imageio, imbalanced-learn, imgaug, jax, jaxlib, librosa, lightgbm, matplotlib, matplotlib-venn, missingno, mizani, ml-dtypes, mlxtend, moviepy, music21, nibabel, numba, numexpr, opencv-contrib-python, opencv-python, opencv-python-headless, opt-einsum, optax, orbax-checkpoint, osqp, pandas, pandas-gbq, patsy, plotnine, prophet, pyarrow, pycocotools, pyerfa, pymc, pytensor, python-louvain, PyWavelets, qdldl, qiskit-aer, qiskit-ibmq-provider, qiskit-machine-learning, qiskit-terra, qudida, rustworkx, scikit-image, scikit-learn, scipy, scs, seaborn, shapely, sklearn-pandas, soxr, spacy, statsmodels, tables, tensorboard, tensorflow, tensorflow-datasets, tensorflow-hub, tensorflow-probability, tensorstore, thinc, tifffile, torchtext, torchvision, wordcloud, xarray, xarray-einstats, xgboost, yellowbrick, yfinance
---
Name: pandas
Version: 1.5.3
Summary: Powerful data structures for data analysis, time series, and statistics
Home-page: https://pandas.pydata.org/
Author: The Pandas Development Team
Author-email: [pandas-dev@python.org](mailto:pandas-dev@python.org)
License: BSD-3-Clause
Location: /usr/local/lib/python3.10/dist-packages
Requires: numpy, python-dateutil, pytz
Required-by: altair, arviz, bokeh, cmdstanpy, cufflinks, datascience, db-dtypes, dopamine-rl, fastai, geopandas, google-colab, gspread-dataframe, holoviews, mizani, mlxtend, pandas-datareader, pandas-gbq, panel, plotnine, prophet, pymc, seaborn, sklearn-pandas, statsmodels, vega-datasets, xarray, yfinance
---
Name: matplotlib
Version: 3.7.1
Summary: Python plotting package
Home-page: https://matplotlib.org/
Author: John D. Hunter, Michael Droettboom
Author-email: [matplotlib-users@python.org](mailto:matplotlib-users@python.org)
License: PSF
Location: /usr/local/lib/python3.10/dist-packages
Requires: contourpy, cycler, fonttools, kiwisolver, numpy, packaging, pillow, pyparsing, python-dateutil
Required-by: arviz, datascience, fastai, imgaug, matplotlib-venn, missingno, mizani, mlxtend, music21, plotnine, prophet, pycocotools, seaborn, wordcloud, yellowbrick
---
Name: seaborn
Version: 0.12.2
Summary: Statistical data visualization
Home-page: 
Author: 
Author-email: Michael Waskom <[mwaskom@gmail.com](mailto:mwaskom@gmail.com)>
License: 
Location: /usr/local/lib/python3.10/dist-packages
Requires: matplotlib, numpy, pandas
Required-by: missingno
---
Name: scikit-learn
Version: 1.2.2
Summary: A set of python modules for machine learning and data mining
Home-page: http://scikit-learn.org/
Author: 
Author-email: 
License: new BSD
Location: /usr/local/lib/python3.10/dist-packages
Requires: joblib, numpy, scipy, threadpoolctl
Required-by: fastai, imbalanced-learn, librosa, mlxtend, qiskit-machine-learning, qudida, sklearn-pandas, yellowbrick
---
Name: qiskit
Version: 0.43.0
Summary: Software for developing quantum computing programs
Home-page: https://qiskit.org/
Author: Qiskit Development Team
Author-email: [hello@qiskit.org](mailto:hello@qiskit.org)
License: Apache 2.0
Location: /usr/local/lib/python3.10/dist-packages
Requires: qiskit-aer, qiskit-ibmq-provider, qiskit-terra
Required-by: 
---
Name: qiskit-machine-learning
Version: 0.6.1
Summary: Qiskit Machine Learning: A library of quantum computing machine learning experiments
Home-page: https://github.com/Qiskit/qiskit-machine-learning
Author: Qiskit Machine Learning Development Team
Author-email: [hello@qiskit.org](mailto:hello@qiskit.org)
License: Apache-2.0
Location: /usr/local/lib/python3.10/dist-packages
Requires: dill, fastdtw, numpy, psutil, qiskit-terra, scikit-learn, scipy, setuptools
Required-by: 
---
Name: torch
Version: 2.0.1+cu118
Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration
Home-page: https://pytorch.org/
Author: PyTorch Team
Author-email: [packages@pytorch.org](mailto:packages@pytorch.org)
License: BSD-3
Location: /usr/local/lib/python3.10/dist-packages
Requires: filelock, jinja2, networkx, sympy, triton, typing-extensions
Required-by: fastai, torchaudio, torchdata, torchtext, torchvision, triton
---
Name: gym
Version: 0.26.0
Summary: Gym: A universal API for reinforcement learning environments
Home-page: https://www.gymlibrary.dev/
Author: Gym Community
Author-email: [jkterry@umd.edu](mailto:jkterry@umd.edu)
License: MIT
Location: /usr/local/lib/python3.10/dist-packages
Requires: cloudpickle, gym-notices, numpy
Required-by: dopamine-rl

How can we reproduce the issue?

The code is private. If possible to help from error kindly do so. I am sorry for the inconvenience.

What should happen?

Dataset Type:  NvsBU
Train Data Shape:  (1231, 67)
/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/gym/utils/passive_env_checker.py:31: UserWarning: WARN: A Box observation space has an unconventional shape (neither an image, nor a 1D vector). We recommend flattening the observation to have only a 1D vector or use a custom policy to properly process the data. Actual observation shape: (120, 1)
  logger.warn(
Dataset Type:  NvsBU
Train Data Shape:  (1231, 67)
/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/gym/utils/passive_env_checker.py:137: UserWarning: WARN: The obs returned by the `reset()` method was expecting a numpy array, actual type: <class 'torch.Tensor'>
  logger.warn(
/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/gym/spaces/box.py:227: UserWarning: WARN: Casting input x to numpy array.
  logger.warn("Casting input x to numpy array.")
/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/gym/utils/passive_env_checker.py:165: UserWarning: WARN: The obs returned by the `reset()` method is not within the observation space.
  logger.warn(f"{pre} is not within the observation space.")
Experiment has already been stored. Do you want to load it?
Enter (yes/no): 
yes

Do you want to save the current experiment?
This will overwrite the model and experiment data if already present.
Enter (yes/no): 
no
Initiating Experiment Number:  3
n_obs:  120
n_act:  49
n_obs:  120
n_act:  49

 INITIAL LOAD CHECK

Model Parameters
tensor([[-0.0390,  0.0364, -0.0004,  ..., -0.0662,  0.0892,  0.0864],
        [ 0.0824,  0.0824,  0.0832,  ...,  0.0905, -0.0157, -0.0834],
        [-0.0304, -0.0852, -0.0845,  ..., -0.0470, -0.0427, -0.0395],
        ...,
        [-0.0003, -0.0650,  0.0175,  ...,  0.0255, -0.0640, -0.0224],
        [ 0.0853,  0.0053,  0.0221,  ...,  0.0647,  0.0064,  0.0842],
        [ 0.0858, -0.0208,  0.0718,  ...,  0.0512,  0.0411, -0.0490]])
tensor([ 0.0810, -0.0753,  0.0432, -0.0347, -0.0769, -0.0678, -0.0102,  0.0887,
        -0.0565,  0.0146,  0.0722, -0.0292, -0.0563,  0.0534, -0.0484,  0.0284,
        -0.0018, -0.0318,  0.0039, -0.0412,  0.0264, -0.0063,  0.0895,  0.0855,
        -0.0601, -0.0886,  0.0023, -0.0437, -0.0282,  0.0418,  0.0322, -0.0410,
        -0.0473,  0.0725, -0.0406, -0.0512,  0.0712, -0.0187, -0.0359, -0.0025,
         0.0096,  0.0418, -0.0499, -0.0018,  0.0378,  0.0737,  0.0524,  0.0892,
        -0.0447,  0.0033,  0.0775, -0.0031, -0.0722, -0.0843, -0.0294,  0.0824,
         0.0895,  0.0355,  0.0294, -0.0817,  0.0403,  0.0435,  0.0572, -0.0539,
        -0.0646, -0.0550,  0.0766,  0.0813, -0.0169, -0.0788,  0.0105,  0.0532,
        -0.0217,  0.0717,  0.0043,  0.0315,  0.0711,  0.0157,  0.0365,  0.0402,
         0.0194,  0.0170,  0.0826,  0.0450,  0.0274, -0.0384,  0.0116,  0.0851,
        -0.0751, -0.0362, -0.0321, -0.0078, -0.0349,  0.0858, -0.0384, -0.0433,
         0.0641,  0.0171, -0.0354, -0.0619,  0.0364, -0.0069,  0.0019,  0.0072,
        -0.0539,  0.0551,  0.0587, -0.0890, -0.0312,  0.0788, -0.0374,  0.0537,
         0.0564,  0.0528,  0.0093,  0.0634, -0.0167, -0.0583, -0.0075,  0.0240,
         0.0494,  0.0537, -0.0437, -0.0125,  0.0296, -0.0399, -0.0136, -0.0119])
tensor([[ 0.0675,  0.0330,  0.0613,  ..., -0.0330,  0.0730,  0.0293],
        [-0.0643,  0.0239, -0.0206,  ...,  0.0529,  0.0856,  0.0065],
        [-0.0020, -0.0047, -0.0423,  ..., -0.0383,  0.0062, -0.0223],
        ...,
        [-0.0148,  0.0403, -0.0839,  ...,  0.0324, -0.0109,  0.0050],
        [ 0.0462,  0.0645, -0.0487,  ..., -0.0059,  0.0201, -0.0322],
        [ 0.0617, -0.0672, -0.0161,  ...,  0.0365,  0.0349, -0.0841]])
tensor([-7.8322e-02,  4.7142e-02,  5.6855e-02,  1.3001e-02,  4.4692e-02,
         1.9217e-02, -1.5397e-02,  3.1954e-02,  5.1587e-02, -3.5374e-02,
         4.8527e-02, -3.8343e-03,  8.3373e-02, -7.2836e-02,  2.4736e-02,
         6.0430e-02, -1.8734e-02, -7.6804e-02,  7.3436e-02, -4.6375e-02,
         8.5307e-03,  5.6246e-02,  5.8160e-02,  1.5312e-02,  8.8863e-03,
        -8.1544e-02, -2.2561e-02, -7.0429e-02, -2.4187e-02,  5.1244e-02,
         3.6478e-02, -7.5585e-02, -3.0990e-02, -2.5597e-02, -4.9830e-02,
         2.8722e-02, -7.2697e-02, -6.2624e-02,  2.2637e-02,  1.7114e-02,
         4.9243e-03,  6.2529e-02, -8.0330e-02,  8.1696e-02, -6.2179e-02,
        -2.5852e-02, -7.5925e-02,  1.6111e-02,  1.6183e-02,  6.7026e-03,
        -6.4437e-02, -7.2001e-02,  1.9743e-03,  5.2899e-02, -5.1006e-02,
        -4.4404e-02, -6.9825e-02,  3.7560e-02,  2.4501e-02, -7.7342e-02,
        -2.3042e-02,  4.8499e-02,  6.9959e-03, -2.8391e-02,  1.1539e-02,
         4.1027e-02, -6.7782e-02, -7.2656e-03, -8.4493e-02, -5.7257e-02,
        -3.8759e-02, -6.3473e-03,  3.0351e-02, -6.0422e-02, -8.7236e-03,
         6.4170e-02, -5.0843e-02, -2.2535e-02, -4.5629e-03,  4.4059e-02,
         2.7578e-02,  6.1333e-02,  5.2173e-02, -4.2749e-02,  6.4779e-02,
         5.1118e-02,  8.2096e-02, -1.2113e-02,  5.8346e-02,  3.0311e-02,
         5.2989e-03,  7.6314e-02, -5.9422e-02,  2.8996e-02,  2.2351e-02,
        -3.7165e-02,  5.0012e-02,  5.0732e-02, -9.2059e-05,  4.4836e-02,
        -7.0945e-02,  4.0427e-02, -1.6817e-02, -4.3649e-03, -5.1460e-02,
         2.7080e-02, -5.8638e-02, -3.4910e-02,  7.4149e-02,  5.3140e-02,
         5.4246e-02,  4.4159e-02,  2.0184e-02, -4.1311e-02,  3.3059e-02,
        -5.4783e-02,  4.8177e-02, -3.6300e-02,  4.4888e-02, -4.9710e-02,
         6.2516e-02, -3.5722e-02,  8.0879e-02,  1.1122e-03,  2.8200e-02,
        -6.4518e-02,  4.0572e-02,  2.5525e-02])
tensor([[-0.0273,  0.0659, -0.0728,  ..., -0.0360,  0.0625,  0.0541],
        [-0.0815,  0.0312,  0.0860,  ..., -0.0179, -0.0233,  0.0054],
        [ 0.0127, -0.0697,  0.0207,  ..., -0.0871, -0.0267, -0.0882],
        ...,
        [ 0.0295,  0.0821,  0.0371,  ..., -0.0101, -0.0328,  0.0675],
        [-0.0692,  0.0373, -0.0824,  ..., -0.0282, -0.0412, -0.0707],
        [-0.0543,  0.0013,  0.0847,  ...,  0.0381,  0.0527,  0.0146]])
tensor([-0.0257,  0.0164,  0.0076, -0.0362,  0.0372, -0.0399,  0.0462, -0.0758,
         0.0432,  0.0879, -0.0713,  0.0794,  0.0636, -0.0095, -0.0877, -0.0846,
         0.0138,  0.0459,  0.0480, -0.0050,  0.0422,  0.0596,  0.0739,  0.0323,
         0.0555,  0.0809,  0.0377, -0.0312,  0.0604, -0.0864,  0.0546,  0.0748,
         0.0865, -0.0161,  0.0184,  0.0035,  0.0793,  0.0195,  0.0520,  0.0557,
         0.0170, -0.0628,  0.0687, -0.0690, -0.0204, -0.0334, -0.0092, -0.0265,
         0.0618])
memory deque([Transition(state=tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 4., 0., 0., 0., 4., 4., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 5., 0., 0., 5., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 5., 0., 5., 0., 0., 5., 2., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 4., 0., 0., 4., 4., 0., 5., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 3., 0., 0., 0., 2., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), action=tensor([[11]]), next_state=tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 4., 0., 0., 0., 4., 4., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 5., 0., 0., 5., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 5., 0., 5., 0., 0., 5., 2., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 4., 0., 0., 4., 4., 0., 5., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 3., 0., 0., 0., 2., 0., 0.,
         0., 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), reward=tensor([0.5801], dtype=torch.float64)), Transition(state=tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 4., 0., 0., 0., 4., 4., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 5., 0., 0., 5., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 5., 0., 5., 0., 0., 5., 2., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 4., 0., 0., 4., 4., 0., 5., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 3., 0., 0., 0., 2., 0., 0.,
         0., 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), action=tensor([[9]]), next_state=tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 4., 0., 0., 0., 4., 4., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 5., 0., 0., 5., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 5., 0., 5., 0., 0., 5., 2., 0., 2., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 4., 0., 0., 4., 4., 0., 5., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 3., 0., 0., 0., 2., 0., 0.,
         0., 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), reward=tensor([0.5496], dtype=torch.float64)), Transition(state=tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 4., 0., 0., 0., 4., 4., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 5., 0., 0., 5., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 5., 0., 5., 0., 0., 5., 2., 0., 2., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 4., 0., 0., 4., 4., 0., 5., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 3., 0., 0., 0., 2., 0., 0.,
         0., 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), action=tensor([[0]]), next_state=tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 4., 0., 0., 0., 4., 4., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 5., 0., 0., 5., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 5., 0., 5., 0., 0., 5., 2., 0., 2., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 4., 0., 0., 4., 4., 0., 5., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 3., 0., 0., 0., 2., 0., 0.,
         0., 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), reward=tensor([0.5371], dtype=torch.float64)), Transition(state=tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 4., 0., 0., 0., 4., 4., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 5., 0., 0., 5., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 5., 0., 5., 0., 0., 5., 2., 0., 2., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 4., 0., 0., 4., 4., 0., 5., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 3., 0., 0., 0., 2., 0., 0.,
         0., 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), action=tensor([[9]]), next_state=tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 4., 0., 0., 0., 4., 4., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 5., 0., 0., 5., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 5., 0., 5., 0., 0., 5., 2., 0., 2., 0.,
         2., 0., 0., 0., 0., 0., 0., 0., 4., 0., 0., 4., 4., 0., 5., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 3., 0., 0., 0., 2., 0., 0.,
         0., 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), reward=tensor([0.5529], dtype=torch.float64)), Transition(state=tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 4., 0., 0., 0., 4., 4., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 5., 0., 0., 5., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 5., 0., 5., 0., 0., 5., 2., 0., 2., 0.,
         2., 0., 0., 0., 0., 0., 0., 0., 4., 0., 0., 4., 4., 0., 5., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 3., 0., 0., 0., 2., 0., 0.,
         0., 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), action=tensor([[9]]), next_state=tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 4., 0., 0., 0., 4., 4., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 5., 0., 0., 5., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 5., 0., 5., 0., 0., 5., 2., 0., 2., 0.,
         2., 2., 0., 0., 0., 0., 0., 0., 4., 0., 0., 4., 4., 0., 5., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 3., 0., 0., 0., 2., 0., 0.,
         0., 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), reward=tensor([0.5702], dtype=torch.float64)), Transition(state=tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 4., 0., 0., 0., 4., 4., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 5., 0., 0., 5., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 5., 0., 5., 0., 0., 5., 2., 0., 2., 0.,
         2., 2., 0., 0., 0., 0., 0., 0., 4., 0., 0., 4., 4., 0., 5., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 3., 0., 0., 0., 2., 0., 0.,
         0., 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), action=tensor([[9]]), next_state=tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 4., 0., 0., 0., 4., 4., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 5., 0., 0., 5., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 5., 0., 5., 0., 0., 5., 2., 0., 2., 0.,
         2., 2., 2., 0., 0., 0., 0., 0., 4., 0., 0., 4., 4., 0., 5., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 3., 0., 0., 0., 2., 0., 0.,
         0., 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), reward=tensor([0.5834], dtype=torch.float64)), Transition(state=tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 4., 0., 0., 0., 4., 4., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 5., 0., 0., 5., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 5., 0., 5., 0., 0., 5., 2., 0., 2., 0.,
         2., 2., 2., 0., 0., 0., 0., 0., 4., 0., 0., 4., 4., 0., 5., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 3., 0., 0., 0., 2., 0., 0.,
         0., 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), action=tensor([[30]]), next_state=tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 4., 0., 0., 0., 4., 4., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 5., 0., 0., 5., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 4., 0., 0., 0., 0., 0., 0., 5., 0., 5., 0., 0., 5., 2., 0., 2., 0.,
         2., 2., 2., 5., 0., 0., 0., 0., 4., 0., 0., 4., 4., 0., 5., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 3., 0., 0., 0., 2., 0., 0.,
         0., 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), reward=tensor([0.5801], dtype=torch.float64)), Transition(state=tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 4., 0., 0., 0., 4., 4., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 5., 0., 0., 5., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 4., 0., 0., 0., 0., 0., 0., 5., 0., 5., 0., 0., 5., 2., 0., 2., 0.,
         2., 2., 2., 5., 0., 0., 0., 0., 4., 0., 0., 4., 4., 0., 5., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 3., 0., 0., 0., 2., 0., 0.,
         0., 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), action=tensor([[40]]), next_state=tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 4., 0., 0., 0., 4., 4., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 5., 0., 0., 5., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 4., 5., 0., 0., 0., 0., 0., 5., 0., 5., 0., 0., 5., 2., 0., 2., 0.,
         2., 2., 2., 5., 0., 0., 0., 0., 4., 0., 0., 4., 4., 0., 5., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 4., 0., 0., 0., 0., 3., 0., 0., 0., 2., 0., 0.,
         0., 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), reward=tensor([0.5878], dtype=torch.float64)), Transition(state=tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 4., 0., 0., 0., 4., 4., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 5., 0., 0., 5., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 4., 5., 0., 0., 0., 0., 0., 5., 0., 5., 0., 0., 5., 2., 0., 2., 0.,
         2., 2., 2., 5., 0., 0., 0., 0., 4., 0., 0., 4., 4., 0., 5., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 4., 0., 0., 0., 0., 3., 0., 0., 0., 2., 0., 0.,
         0., 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), action=tensor([[31]]), next_state=tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 4., 0., 0., 0., 4., 4., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 5., 0., 0., 5., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 4., 5., 4., 0., 0., 0., 0., 5., 0., 5., 0., 0., 5., 2., 0., 2., 0.,
         2., 2., 2., 5., 0., 0., 0., 0., 4., 0., 0., 4., 4., 0., 5., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 4., 5., 0., 0., 0., 3., 0., 0., 0., 2., 0., 0.,
         0., 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), reward=tensor([0.5307], dtype=torch.float64)), Transition(state=tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 4., 0., 0., 0., 4., 4., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 0., 0., 0., 5., 0., 0., 5., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
         0., 4., 5., 4., 0., 0., 0., 0., 5., 0., 5., 0., 0., 5., 2., 0., 2., 0.,
         2., 2., 2., 5., 0., 0., 0., 0., 4., 0., 0., 4., 4., 0., 5., 0., 0., 0.,
         0., 0., 0., 0., 0., 0., 4., 5., 0., 0., 0., 3., 0., 0., 0., 2., 0., 0.,
         0., 2., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]]), action=tensor([[35]]), next_state=None, reward=tensor([0.5768], dtype=torch.float64))], maxlen=10)
done

Episode:  0
/Users/vanditshah/Documents/IIT M Material/Sem 3/MTP/Code/Quantum-RL-main/main.py:788: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than torch.tensor(sourceTensor).
  state = torch.tensor(state, dtype=torch.float32, device=device).unsqueeze(0)
/Users/vanditshah/Documents/IIT M Material/Sem 3/MTP/Code/Quantum-RL-main/main.py:407: DeprecationWarning: The class ``qiskit.utils.quantum_instance.QuantumInstance`` is deprecated as of qiskit-terra 0.24.0. It will be removed no earlier than 3 months after the release date. For code migration guidelines, visit https://qisk.it/qi_migration.
  quantum_instance=QuantumInstance(Aer.get_backend('qasm_simulator'),
/Users/vanditshah/Documents/IIT M Material/Sem 3/MTP/Code/Quantum-RL-main/main.py:403: DeprecationWarning: The quantum_instance argument is deprecated as of version 0.5.0 and will be removed no sooner than 3 months after the release. Instead use the sampler argument.
  vqc = VQC(feature_map=self.feature_map,
/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/numpy/linalg/linalg.py:2146: RuntimeWarning: divide by zero encountered in det
  r = _umath_linalg.det(a, signature=signature)
/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/numpy/linalg/linalg.py:2146: RuntimeWarning: invalid value encountered in det
  r = _umath_linalg.det(a, signature=signature)
PARAM VALS OLD:  []
Traceback (most recent call last):
  File "/Users/vanditshah/Documents/IIT M Material/Sem 3/MTP/Code/Quantum-RL-main/main.py", line 795, in <module>
    observation, reward, terminated, info = env.step(action.item())
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/gym/wrappers/order_enforcing.py", line 37, in step
    return self.env.step(action)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/gym/wrappers/env_checker.py", line 37, in step
    return env_step_passive_checker(self.env, action)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/gym/utils/passive_env_checker.py", line 214, in env_step_passive_checker
    result = env.step(action)
  File "/Users/vanditshah/Documents/IIT M Material/Sem 3/MTP/Code/Quantum-RL-main/main.py", line 287, in step
    f1_score = self.test_ansatz_and_get_f1()
  File "/Users/vanditshah/Documents/IIT M Material/Sem 3/MTP/Code/Quantum-RL-main/main.py", line 423, in test_ansatz_and_get_f1
    vqc.fit(train_X, train_y)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit_machine_learning/algorithms/trainable_model.py", line 199, in fit
    self._fit_result = self._fit_internal(X, y)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit_machine_learning/algorithms/classifiers/vqc.py", line 193, in _fit_internal
    return self._minimize(function)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit_machine_learning/algorithms/trainable_model.py", line 295, in _minimize
    optimizer_result = self._optimizer.minimize(
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit/algorithms/optimizers/scipy_optimizer.py", line 149, in minimize
    raw_result = minimize(
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/scipy/optimize/_minimize.py", line 716, in minimize
    res = _minimize_cobyla(fun, x0, args, constraints, callback=callback,
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/scipy/optimize/_cobyla_py.py", line 35, in wrapper
    return func(*args, **kwargs)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/scipy/optimize/_cobyla_py.py", line 278, in _minimize_cobyla
    sf = _prepare_scalar_function(fun, x0, args=args, jac=_jac)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/scipy/optimize/_optimize.py", line 383, in _prepare_scalar_function
    sf = ScalarFunction(fun, x0, args, grad, hess,
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/scipy/optimize/_differentiable_functions.py", line 158, in __init__
    self._update_fun()
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/scipy/optimize/_differentiable_functions.py", line 251, in _update_fun
    self._update_fun_impl()
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/scipy/optimize/_differentiable_functions.py", line 155, in update_fun
    self.f = fun_wrapped(self.x)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/scipy/optimize/_differentiable_functions.py", line 137, in fun_wrapped
    fx = fun(np.copy(x), *args)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit_machine_learning/algorithms/trainable_model.py", line 271, in objective
    objective_value = function.objective(objective_weights)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit_machine_learning/algorithms/objective_functions.py", line 191, in objective
    probs = self._neural_network_forward(weights)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit_machine_learning/algorithms/objective_functions.py", line 102, in _neural_network_forward
    self._last_forward = self._neural_network.forward(self._X, weights)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit_machine_learning/neural_networks/neural_network.py", line 226, in forward
    output_data = self._forward(input_, weights_)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit_machine_learning/neural_networks/sampling_neural_network.py", line 89, in _forward
    return self._probabilities(input_data, weights)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit_machine_learning/neural_networks/circuit_qnn.py", line 417, in _probabilities
    result = self._quantum_instance.execute(circuits, had_transpiled=self._circuit_transpiled)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit/utils/quantum_instance.py", line 500, in execute
    circuits = self.transpile(circuits)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit/utils/quantum_instance.py", line 426, in transpile
    transpiled_circuits = compiler.transpile(
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit/compiler/transpiler.py", line 381, in transpile
    _serial_transpile_circuit(
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit/compiler/transpiler.py", line 463, in _serial_transpile_circuit
    result = pass_manager.run(circuit, callback=callback, output_name=output_name)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit/transpiler/passmanager.py", line 537, in run
    return super().run(circuits, output_name, callback)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit/transpiler/passmanager.py", line 231, in run
    return self._run_single_circuit(circuits, output_name, callback)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit/transpiler/passmanager.py", line 292, in _run_single_circuit
    result = running_passmanager.run(circuit, output_name=output_name, callback=callback)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit/transpiler/runningpassmanager.py", line 125, in run
    dag = self._do_pass(pass_, dag, passset.options)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit/transpiler/runningpassmanager.py", line 169, in _do_pass
    dag = self._do_pass(required_pass, dag, options)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit/transpiler/runningpassmanager.py", line 173, in _do_pass
    dag = self._run_this_pass(pass_, dag)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit/transpiler/runningpassmanager.py", line 227, in _run_this_pass
    pass_.run(FencedDAGCircuit(dag))
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit/transpiler/passes/optimization/commutation_analysis.py", line 75, in run
    does_commute = self.comm_checker.commute(
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit/circuit/commutation_checker.py", line 136, in commute
    operator_2 = Operator(op2, input_dims=(2,) * len(qarg2), output_dims=(2,) * len(qarg2))
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit/quantum_info/operators/operator.py", line 85, in __init__
    self._data = self._init_instruction(data).data
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit/quantum_info/operators/operator.py", line 614, in _init_instruction
    op._append_instruction(instruction)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit/quantum_info/operators/operator.py", line 691, in _append_instruction
    self._append_instruction(instruction.operation, qargs=new_qargs)
  File "/Users/vanditshah/miniconda3/envs/grm-env/lib/python3.10/site-packages/qiskit/quantum_info/operators/operator.py", line 658, in _append_instruction
    raise QiskitError(f"Cannot apply Operation: {obj.name}")
qiskit.exceptions.QiskitError: 'Cannot apply Operation: reset'

Any suggestions?

I guess numpy is the issue here but do not have any concrete evidence against it.

jakelishman commented 10 months ago

If you want help from us, I'm sorry, but you're going to need to put the effort in to make a minimal reproducer that we're allowed to see.

vandit2209 commented 10 months ago

sure, kindly allow me sometime to get the relevant permission

jakelishman commented 10 months ago

This shouldn't be a question of permissions; a minimal reproducer should not use any of your research code, and we don't want to see your research code. What's helpful to us is the absolute smallest possible code block that reproduces the problem you're seeing. Ideally, that's less than 20 lines in total, including imports.

See this StackOverflow post on how to produce a useful bug report.

1ucian0 commented 10 months ago

Feel free to open a new bug report once you have a way to explain how to trigger the bug you would like to report.

Closing as can't repro

vandit2209 commented 10 months ago

Hello, The error is produced while using vqc.fit() with COBYLA optimiser.

jakelishman commented 10 months ago

That is not a complete and minimal reproducing example. Please read the materials attached to the issue template and also linked in the comment chain above about how to interact when asking for help.