QiruiZhang / FTDD

Quantum Circuit Simulation with Fast Tensor Decision Diagram
MIT License
3 stars 0 forks source link

Error with Cotengra path #1

Closed romOlivo closed 1 week ago

romOlivo commented 1 month ago

I am attempting to run the tool to test the PyTDD version with the sample demos provided by the tool. However, I am unable to get cotengra to calculate the path. When I attempt to run it, I receive the following error:

(venv) usuario@OptiPlex-3080:~/Documentos/FTDD/TestFTDD$ python3 DemoFTDD.py 3_17_13

Quantum circuit:  3_17_13.qasm

  0%|                                                                                                                                                                                                     | 0/512 [00:00<?, ?it/s]/home/usuario/Documentos/FTDD/venv/lib/python3.10/site-packages/cotengra/hyperoptimizers/hyper.py:307: UserWarning: Trial error: expected a string of length 1. Set `HyperOptimizer` kwarg `on_trial_error='raise'` to raise this error, or `on_trial_error='ignore'` to silence.
  warnings.warn(
/home/usuario/Documentos/FTDD/venv/lib/python3.10/site-packages/cotengra/hyperoptimizers/hyper.py:307: UserWarning: Trial error: expected a string of length 1. Set `HyperOptimizer` kwarg `on_trial_error='raise'` to raise this error, or `on_trial_error='ignore'` to silence.
  warnings.warn(
/home/usuario/Documentos/FTDD/venv/lib/python3.10/site-packages/cotengra/hyperoptimizers/hyper.py:307: UserWarning: Trial error: expected a string of length 1. Set `HyperOptimizer` kwarg `on_trial_error='raise'` to raise this error, or `on_trial_error='ignore'` to silence.
  warnings.warn(
/home/usuario/Documentos/FTDD/venv/lib/python3.10/site-packages/cotengra/hyperoptimizers/hyper.py:307: UserWarning: Trial error: expected a string of length 1. Set `HyperOptimizer` kwarg `on_trial_error='raise'` to raise this error, or `on_trial_error='ignore'` to silence.
  warnings.warn(
/home/usuario/Documentos/FTDD/venv/lib/python3.10/site-packages/cotengra/hyperoptimizers/hyper.py:307: UserWarning: Trial error: expected a string of length 1. Set `HyperOptimizer` kwarg `on_trial_error='raise'` to raise this error, or `on_trial_error='ignore'` to silence.
  warnings.warn(
/home/usuario/Documentos/FTDD/venv/lib/python3.10/site-packages/cotengra/hyperoptimizers/hyper.py:307: UserWarning: Trial error: expected a string of length 1. Set `HyperOptimizer` kwarg `on_trial_error='raise'` to raise this error, or `on_trial_error='ignore'` to silence.
  warnings.warn(
/home/usuario/Documentos/FTDD/venv/lib/python3.10/site-packages/cotengra/hyperoptimizers/hyper.py:307: UserWarning: Trial error: expected a string of length 1. Set `HyperOptimizer` kwarg `on_trial_error='raise'` to raise this error, or `on_trial_error='ignore'` to silence.
  warnings.warn(
/home/usuario/Documentos/FTDD/venv/lib/python3.10/site-packages/cotengra/hyperoptimizers/hyper.py:307: UserWarning: Trial error: expected a string of length 1. Set `HyperOptimizer` kwarg `on_trial_error='raise'` to raise this error, or `on_trial_error='ignore'` to silence.
  warnings.warn(
/home/usuario/Documentos/FTDD/venv/lib/python3.10/site-packages/cotengra/hyperoptimizers/hyper.py:307: UserWarning: Trial error: expected a string of length 1. Set `HyperOptimizer` kwarg `on_trial_error='raise'` to raise this error, or `on_trial_error='ignore'` to silence.
  warnings.warn(
/home/usuario/Documentos/FTDD/venv/lib/python3.10/site-packages/cotengra/hyperoptimizers/hyper.py:307: UserWarning: Trial error: expected a string of length 1. Set `HyperOptimizer` kwarg `on_trial_error='raise'` to raise this error, or `on_trial_error='ignore'` to silence.
  warnings.warn(
/home/usuario/Documentos/FTDD/venv/lib/python3.10/site-packages/cotengra/hyperoptimizers/hyper.py:307: UserWarning: Trial error: expected a string of length 1. Set `HyperOptimizer` kwarg `on_trial_error='raise'` to raise this error, or `on_trial_error='ignore'` to silence.
  warnings.warn(
/home/usuario/Documentos/FTDD/venv/lib/python3.10/site-packages/cotengra/hyperoptimizers/hyper.py:307: UserWarning: Trial error: expected a string of length 1. Set `HyperOptimizer` kwarg `on_trial_error='raise'` to raise this error, or `on_trial_error='ignore'` to silence.
  warnings.warn(
log10[FLOPs]=inf log2[SIZE]=inf: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 512/512 [00:00<00:00, 558.67it/s]
Traceback (most recent call last):
  File "/home/usuario/Documentos/FTDD/TestFTDD/DemoFTDD.py", line 96, in <module>
    tree_t0c1 = opt.search(tensor_list_t0, open_indices_t0, size_dict_t0)
  File "/home/usuario/Documentos/FTDD/venv/lib/python3.10/site-packages/cotengra/hyperoptimizers/hyper.py", line 1035, in search
    self._cache[h] = self._compute_path(inputs, output, size_dict)
  File "/home/usuario/Documentos/FTDD/venv/lib/python3.10/site-packages/cotengra/hyperoptimizers/hyper.py", line 1000, in _compute_path
    "path": opt.path,
  File "/home/usuario/Documentos/FTDD/venv/lib/python3.10/site-packages/cotengra/hyperoptimizers/hyper.py", line 504, in path
    return self.tree.get_path()
  File "/home/usuario/Documentos/FTDD/venv/lib/python3.10/site-packages/cotengra/hyperoptimizers/hyper.py", line 500, in tree
    return self.best["tree"]
KeyError: 'tree'

I am using Python version 3.10.12, with the following package installation:

(venv) usuario@OptiPlex-3080:~/Documentos/FTDD/TestFTDD$ pip freeze
alembic==1.13.3
arraylias==0.1.1
asteval==1.0.5
asttokens==2.4.1
autoray==0.6.12
beautifulsoup4==4.12.3
blinker==1.8.2
certifi==2024.8.30
cffi==1.17.1
charset-normalizer==3.3.2
click==8.1.7
cloudpickle==3.0.0
colorlog==6.8.2
comm==0.2.2
contourpy==1.3.0
cotengra==0.6.2
cotengrust==0.1.4
cryptography==43.0.1
cycler==0.12.1
cytoolz==0.12.3
dask==2024.9.1
decorator==5.1.1
dill==0.3.9
docplex==2.28.240
exceptiongroup==1.2.2
executing==2.1.0
fastdtw==0.3.4
flask==3.0.3
fonttools==4.54.1
frozendict==2.4.4
fsspec==2024.9.0
graphviz==0.20.3
greenlet==3.1.1
h5py==3.12.1
html5lib==1.1
ibm-cloud-sdk-core==3.21.0
ibm-platform-services==0.57.1
idna==3.10
importlib-metadata==8.5.0
inflection==0.5.1
iniconfig==2.0.0
ipython==8.28.0
ipywidgets==8.1.5
itsdangerous==2.2.0
jedi==0.19.1
jinja2==3.1.4
joblib==1.4.2
jupyterlab-widgets==3.0.13
kahypar==1.1.8
kiwisolver==1.4.7
lark-parser==0.12.0
lmfit==1.3.2
locket==1.0.0
loky==3.3.0
lxml==5.3.0
Mako==1.3.5
MarkupSafe==2.1.5
matplotlib==3.6.2
matplotlib-inline==0.1.7
more-itertools==10.5.0
mpmath==1.3.0
mqt.bench==0.2.2
mqt.ddsim==1.17.2
multiset==3.2.0
multitasking==0.0.11
Nasdaq-Data-Link==1.0.4
networkx==2.8.8
numpy==1.26.4
opt-einsum==3.4.0
optuna==4.0.0
packaging==24.1
pandas==2.2.3
parso==0.8.4
partd==1.4.2
pbr==6.1.0
peewee==3.17.6
pexpect==4.9.0
pillow==10.4.0
platformdirs==4.3.6
pluggy==1.5.0
ply==3.11
prompt-toolkit==3.0.48
psutil==6.0.0
ptyprocess==0.7.0
pure-eval==0.2.3
pycparser==2.22
pydot==3.0.2
pygments==2.18.0
PyJWT==2.9.0
pylatexenc==2.10
pyparsing==3.1.4
pyscf==2.7.0
pyspnego==0.11.1
pytest==8.3.3
python-dateutil==2.9.0.post0
pytket==1.10.0
pytket-qiskit==0.33.0
pytz==2024.2
PyYAML==6.0.2
qiskit==0.39.5
qiskit-aer==0.11.2
qiskit-dynamics==0.3.2
qiskit-experiments==0.5.2
qiskit-finance==0.3.4
qiskit-ibm-experiment==0.3.1
qiskit-ibm-runtime==0.8.0
qiskit-ibmq-provider==0.19.2
qiskit-machine-learning==0.6.1
qiskit-nature==0.5.2
qiskit-optimization==0.5.0
qiskit-terra==0.22.4
qwasm==1.0.1
requests==2.32.3
requests-ntlm==1.3.0
retworkx==0.15.1
rustworkx==0.15.1
scikit-learn==1.5.2
scipy==1.14.1
seaborn==0.13.2
six==1.16.0
soupsieve==2.6
SQLAlchemy==2.0.35
stack-data==0.6.3
stevedore==5.3.0
symengine==0.13.0
sympy==1.13.3
tensornetwork==0.4.6
threadpoolctl==3.5.0
tomli==2.0.2
toolz==0.12.1
tqdm==4.66.5
traitlets==5.14.3
tweedledum==1.1.1
types-pkg-resources==0.1.3
typing-extensions==4.12.2
tzdata==2024.2
uncertainties==3.2.2
urllib3==2.2.3
wcwidth==0.2.13
webencodings==0.5.1
websocket-client==1.3.3
websockets==13.1
werkzeug==3.0.4
widgetsnbextension==4.0.13
yfinance==0.2.44
zipp==3.20.2

I am unsure if I am making an error in my process or if there is an incompatibility between the packages and the tool. I would be grateful if you could assist me.

I appreciate your assistance in advance.

QiruiZhang commented 2 weeks ago

Apologize for my late reply.

This issue seems to be buried deep in the Cotengra dependencies. I have indeed found that I had to be careful with the dependencies and Python version for FTDD, so I would suggest sticking strictly to the setup described in ReadME, especially:

  1. Using Anaconda and create a clean/new virtual env for running FTDD.
  2. Use Python version 3.8.15. This can make a difference.
  3. Only install packages mentioned in the ReadME.

As for OS, I have tested that Ubuntu 20.04 LTS or RHEL 8 works. I would assume different versions of Ubuntu or RHEL should also work. Please use these OSes if possible.

Let me know if this comment helps. Thank you.

romOlivo commented 1 week ago

Thank you for your assistance.

As you suggested, I downgraded to the Python version you indicated and was able to successfully run Cotenegra. I was previously using Python version 3.10, which functioned properly with the previous version of this tool. However, after the latest upgrade, it suddenly ceased functioning for unknown reasons.

Your guidance was invaluable.