qiboteam / qibojit-benchmarks

Benchmark code for qibojit performance accessment
Apache License 2.0
2 stars 3 forks source link

Running compare.py script hit this error: 'CircuitResult' object has no attribute 'numpy' #39

Closed liweintu closed 1 year ago

liweintu commented 1 year ago

When running script compare.py on GPU, it hit an error below. It seems that the numpy() method has been removed from qibo.states.CircuitResult. My suspicion is that numpy() might have been moved to some other place due to refactoring. Any suggestions on where the helper function is for getting this numpy array? Thanks.

[BENCHMARKS|INFO|2023-01-18 17:38:16]: Creating new logs in qibojit_breakdown.dat. [BENCHMARKS|INFO|2023-01-18 17:38:16]: datetime: 2023-01-18 17:38:16 [BENCHMARKS|INFO|2023-01-18 17:38:16]: nqubits: 20 [BENCHMARKS|INFO|2023-01-18 17:38:16]: nreps: 10 [Qibo 0.1.9|INFO|2023-01-18 17:38:18]: Using qibojit (cupy) backend on /GPU:0 [BENCHMARKS|INFO|2023-01-18 17:38:18]: import_time: 2.2231616973876953 [BENCHMARKS|INFO|2023-01-18 17:38:18]: library_options: backend=qibojit,platform=cupy [BENCHMARKS|INFO|2023-01-18 17:38:18]: library: qibo [BENCHMARKS|INFO|2023-01-18 17:38:18]: precision: double [BENCHMARKS|INFO|2023-01-18 17:38:18]: device: /GPU:0 [BENCHMARKS|INFO|2023-01-18 17:38:18]: version: 0.1.9 [BENCHMARKS|INFO|2023-01-18 17:38:18]: circuit: supremacy [BENCHMARKS|INFO|2023-01-18 17:38:18]: circuit_options: nqubits=20, depth=2, seed=123 [BENCHMARKS|INFO|2023-01-18 17:38:18]: creation_time: 0.0034787654876708984 Traceback (most recent call last): File "/home/liwei/repos/qibojit-benchmarks/compare.py", line 50, in library_benchmark(**args) File "/home/liwei/repos/qibojit-benchmarks/benchmarks/scripts.py", line 119, in library_benchmark result = backend(circuit) File "/home/liwei/repos/qibojit-benchmarks/benchmarks/libraries/qibo.py", line 30, in call return circuit().numpy() AttributeError: 'CircuitResult' object has no attribute 'numpy'

My settings: OS: Ubuntu 20.04.4 LTS python: 3.9.13 qibo: 0.1.9 qibojit: 0.0.6 cupy: 11.3.0 GPU: Nvidia A100

liweintu commented 1 year ago

Using state(numpy=True) instead of numpy() seems to be able to work around, as below.

[BENCHMARKS|INFO|2023-01-18 18:42:46]: Creating new logs in qibojit_breakdown.dat. [BENCHMARKS|INFO|2023-01-18 18:42:46]: datetime: 2023-01-18 18:42:46 [BENCHMARKS|INFO|2023-01-18 18:42:46]: nqubits: 20 [BENCHMARKS|INFO|2023-01-18 18:42:46]: nreps: 10 [Qibo 0.1.9|INFO|2023-01-18 18:42:48]: Using qibojit (cupy) backend on /GPU:0 [BENCHMARKS|INFO|2023-01-18 18:42:48]: import_time: 2.2372593879699707 [BENCHMARKS|INFO|2023-01-18 18:42:48]: library_options: backend=qibojit,platform=cupy [BENCHMARKS|INFO|2023-01-18 18:42:48]: library: qibo [BENCHMARKS|INFO|2023-01-18 18:42:48]: precision: double [BENCHMARKS|INFO|2023-01-18 18:42:48]: device: /GPU:0 [BENCHMARKS|INFO|2023-01-18 18:42:48]: version: 0.1.9 [BENCHMARKS|INFO|2023-01-18 18:42:48]: circuit: supremacy [BENCHMARKS|INFO|2023-01-18 18:42:48]: circuit_options: nqubits=20, depth=2, seed=123 [BENCHMARKS|INFO|2023-01-18 18:42:48]: creation_time: 0.003512144088745117 [BENCHMARKS|INFO|2023-01-18 18:42:49]: dry_run_time: 0.44921422004699707 [BENCHMARKS|INFO|2023-01-18 18:42:49]: dtype: complex128 [BENCHMARKS|INFO|2023-01-18 18:42:49]: simulation_times: [0.009662151336669922, 0.008568525314331055, 0.008428096771240234, 0.00842738151550293, 0.008405447006225586, 0.008429527282714844, 0.00845026969909668, 0.00844430923461914, 0.008404731750488281, 0.008426666259765625] [BENCHMARKS|INFO|2023-01-18 18:42:49]: simulation_times_mean: 0.00856471061706543 [BENCHMARKS|INFO|2023-01-18 18:42:49]: simulation_times_std: 0.0003884149328469331

scarrazza commented 1 year ago

Indeed, the second approach is now compatible with the latest qibo version.

liweintu commented 1 year ago

Thanks for confirming. I'll create a PR to fix this.

liweintu commented 1 year ago

Sorry for the naive question. I got the fix commit prepared in a local branch, but when I did 'git push', I hit the following error: $ git push --set-upstream origin fixqibocompatibility ERROR: Permission to qiboteam/qibojit-benchmarks.git denied to liweintu. fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

I've uploaded my ssh key to Github, and also generated PAT (Personal Access Token) for Qibo repos in Github. Did I miss something here?

liweintu commented 1 year ago

Ok, after forking, the PR (#40) to fix this issue has been submitted. @scarrazza Please take a look. Thanks.

liweintu commented 1 year ago

Issue resolved, closing.