Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Programs using Qiskit fail to run with Scalene >1.5.31.1 #783

Closed
fpietra opened this issue Feb 22, 2024 · 3 comments
Closed

Programs using Qiskit fail to run with Scalene >1.5.31.1 #783

fpietra opened this issue Feb 22, 2024 · 3 comments

Comments

@fpietra
Copy link

fpietra commented Feb 22, 2024

Describe the bug
Profiling with Scalene 1.5.34 causes programs importing the Qiskit library to not run correctly. The program exits as soon as Qiskit is imported with the error:

Error in program being profiled:
 'PosixPath' object is not subscriptable

This is a regression from previous Scalene versions: 1.5.31.1 works correctly.

To Reproduce
Consider this simple program:

$ cat scalene_check.py 
from qiskit import QuantumCircuit

print("done")

This runs correctly:

$ python scalene_check.py 
done

Profiling with Scalene, I get the TypeError: 'PosixPath' object is not subscriptable. Here is the full program and profiler output:

$ scalene scalene_check.py --outfile profile.txt              
Error in program being profiled:
 'PosixPath' object is not subscriptable
Traceback (most recent call last):
  File "/opt/conda/envs/aurora-py310/lib/python3.10/site-packages/scalene/scalene_profiler.py", line 1709, in profile_code
    exec(code, the_globals, the_locals)
  File "/home/vscode/scalene_check.py", line 1, in <module>
    from qiskit import QuantumCircuit
  File "/opt/conda/envs/aurora-py310/lib/python3.10/site-packages/qiskit/__init__.py", line 87, in <module>
    from qiskit.execute_function import execute
  File "/opt/conda/envs/aurora-py310/lib/python3.10/site-packages/qiskit/execute_function.py", line 25, in <module>
    from qiskit.compiler import transpile, schedule
  File "/opt/conda/envs/aurora-py310/lib/python3.10/site-packages/qiskit/compiler/__init__.py", line 31, in <module>
    from .transpiler import transpile
  File "/opt/conda/envs/aurora-py310/lib/python3.10/site-packages/qiskit/compiler/transpiler.py", line 33, in <module>
    from qiskit.transpiler.passes.synthesis.high_level_synthesis import HLSConfig
  File "/opt/conda/envs/aurora-py310/lib/python3.10/site-packages/qiskit/transpiler/passes/__init__.py", line 214, in <module>
    from .optimization import Optimize1qGates
  File "/opt/conda/envs/aurora-py310/lib/python3.10/site-packages/qiskit/transpiler/passes/optimization/__init__.py", line 19, in <module>
    from .consolidate_blocks import ConsolidateBlocks
  File "/opt/conda/envs/aurora-py310/lib/python3.10/site-packages/qiskit/transpiler/passes/optimization/consolidate_blocks.py", line 29, in <module>
    from qiskit.transpiler.passes.synthesis import unitary_synthesis
  File "/opt/conda/envs/aurora-py310/lib/python3.10/site-packages/qiskit/transpiler/passes/synthesis/__init__.py", line 15, in <module>
    from .unitary_synthesis import UnitarySynthesis
  File "/opt/conda/envs/aurora-py310/lib/python3.10/site-packages/qiskit/transpiler/passes/synthesis/unitary_synthesis.py", line 43, in <module>
    from qiskit.transpiler.passes.synthesis import plugin
  File "/opt/conda/envs/aurora-py310/lib/python3.10/site-packages/qiskit/transpiler/passes/synthesis/plugin.py", line 279, in <module>
    import stevedore
  File "/opt/conda/envs/aurora-py310/lib/python3.10/site-packages/stevedore/__init__.py", line 11, in <module>
    from .extension import ExtensionManager
  File "/opt/conda/envs/aurora-py310/lib/python3.10/site-packages/stevedore/extension.py", line 19, in <module>
    from . import _cache
  File "/opt/conda/envs/aurora-py310/lib/python3.10/site-packages/stevedore/_cache.py", line 203, in <module>
    _c = Cache()
  File "/opt/conda/envs/aurora-py310/lib/python3.10/site-packages/stevedore/_cache.py", line 147, in __init__
    sys.executable[0:4] == '/tmp']):
TypeError: 'PosixPath' object is not subscriptable
$ cat profile.txt 
                                     Memory usage: ▄▄▅██ (max: 20.316 MB, growth rate: 101%)                                     
                        /home/vscode/scalene_check.py: % of time = 100.00% (485.960ms) out of 485.960ms.                         
       ╷       ╷       ╷       ╷        ╷       ╷               ╷       ╷                                                        
       │Time   │–––––– │–––––– │Memory  │–––––– │–––––––––––    │Copy   │                                                        
  Line │Python │native │system │Python  │peak   │timeline/%     │(MB/s) │/home/vscode/scalene_check.py                           
╺━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━━━┿━━━━━━━┿━━━━━━━━━━━━━━━┿━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸
     1 │   38% │   59% │   4%  │  99%   │   20M │▄█ 100%        │  1328 │from qiskit import QuantumCircuit                       
     2 │       │       │       │        │       │               │       │                                                        
     3 │       │       │       │        │       │               │       │print("done")                                           
     4 │       │       │       │        │       │               │       │                                                        
       ╵       ╵       ╵       ╵        ╵       ╵               ╵       ╵                                                        
Top AVERAGE memory consumption, by line:
(1)     1:    20 MB                                                                                                               
Top PEAK memory consumption, by line:
(1)     1:    20 MB           

Expected behavior
The program should run correctly. This is the output from Scalene 1.5.31.1:

$ scalene --version
Scalene version 1.5.31.1 (2023.09.15)
$ scalene scalene_check.py --outfile profile_1.5.31.1.txt 
done
$ cat profile_1.5.31.1.txt                               
                                    Memory usage: ▃▃▃▆▆██ (max: 30.427 MB, growth rate: 101%)                                    
                        /home/vscode/scalene_check.py: % of time = 100.00% (503.837ms) out of 503.837ms.                         
       ╷       ╷       ╷       ╷        ╷       ╷               ╷       ╷                                                        
       │Time   │–––––– │–––––– │Memory  │–––––– │–––––––––––    │Copy   │                                                        
  Line │Python │native │system │Python  │peak   │timeline/%     │(MB/s) │/home/vscode/scalene_check.py                           
╺━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━━┿━━━━━━━━┿━━━━━━━┿━━━━━━━━━━━━━━━┿━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸
     1 │   39% │   58% │   3%  │  99%   │   30M │▃▆█ 100%       │  1156 │from qiskit import QuantumCircuit                       
     2 │       │       │       │        │       │               │       │                                                        
     3 │       │       │       │        │       │               │       │print("done")                                           
     4 │       │       │       │        │       │               │       │                                                        
       ╵       ╵       ╵       ╵        ╵       ╵               ╵       ╵                                                        
Top AVERAGE memory consumption, by line:
(1)     1:    30 MB                                                                                                               
Top PEAK memory consumption, by line:
(1)     1:    30 MB            

Desktop:

  • OS: Linux 5.15.133.1-microsoft-standard-WSL2
  • Python 3.10.13
  • Scalene version 1.5.34 (2024.01.27) (from conda-forge)
  • Qiskit version 0.45.2

Tested with the repository version as well.

@emeryberger
Copy link
Member

Thanks for the report. I just issued a new release and your test works for me; it will take some time to get to conda-forge. That said, I saw that you tested with the repo version, and it did not work for you, which is surprising. Please give the new version a try and let's see what happens. Thanks.

@fpietra
Copy link
Author

fpietra commented Feb 23, 2024

It now works correctly for me too with the current repo version (1.5.35 2024.02.23). Thanks.

@emeryberger
Copy link
Member

Great. Closing; thanks again for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants