dkweiss31 / floquet

Floquet simulations of quantum systems to identify nonlinear resonances
https://dkweiss.net/floquet/
BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

Error in EJ_sweep demo #1

Open zachparrott opened 4 days ago

zachparrott commented 4 days ago

Hi Daniel, thanks for sharing this great package!

I have started playing around with it and hit the following error in the EJ_sweep.ipynb example:

# parallelize the calls to sweep_tmon_EJ
EJ_values = np.linspace(15.0, 25.0, 120)
result = list(ft.parallel_map(6, sweep_tmon_EJ, EJ_values))
displaced_state_overlaps, avg_excitation = list(zip(*result, strict=True))

---------------------------------------------------------------------------
RemoteTraceback                           Traceback (most recent call last)
RemoteTraceback: 
"""
Traceback (most recent call last):
  File "c:\Users\zlp\Miniconda3\envs\floq\lib\site-packages\multiprocess\pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "c:\Users\zlp\Miniconda3\envs\floq\lib\site-packages\multiprocess\pool.py", line 48, in mapstar
    return list(map(*args))
  File "c:\Users\zlp\Miniconda3\envs\floq\lib\site-packages\pathos\helpers\mp_helper.py", line 15, in <lambda>
    func = lambda args: f(*args)
  File "C:\Users\zlp\AppData\Local\Temp\1\ipykernel_28472\73690567.py", line 23, in sweep_tmon_EJ
NameError: name 'scq' is not defined
"""

Looks like scQubits is getting referenced somewhere in the parallelization where it is not defined?

dkweiss31 commented 4 days ago

Hi Zach! I'm delighted that you're enjoying the package :)

Indeed someone else has also (offline) reported this issue to me, its very strange and I'm not sure where its coming from. I have not been able to independently reproduce it. Somehow pathos does not recognize that scqubits has been imported as scq. A quick fix is to replace

result = list(ft.parallel_map(6, sweep_tmon_EJ, EJ_values))

with

result = list(ft.parallel_map(1, sweep_tmon_EJ, EJ_values))

which replaces the parallel map using pathos to a simple call to python's map (which only uses a single cpu).

It's worth verifying that installing everything in a clean environment doesn't fix the problem. Run in terminal

conda create --name floquet_test python=3.10
conda activate floquet_test

Edit: you then have two ways of installing the package:

  1. If you've git cloned the package so that you can edit the code locally, cd into the folder that has the pyproject.toml file and run in terminal
    pip install -e ".[dev]"
  2. Alternatively you can install via pip
    pip install git+https://github.com/dkweiss31/floquet

    Either way should install all appropriate dependencies. In both cases you can then try copying the code in the demo notebook to a python file called EJ_sweep.py, and run

    python EJ_sweep.py

    Either solution works on my end, let me know if it doesn't work for you!