Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Update qGAN tutorial #1036

Merged
merged 8 commits into from Oct 7, 2020
Merged

Update qGAN tutorial #1036

merged 8 commits into from Oct 7, 2020

Conversation

Zoufalc
Copy link
Contributor

@Zoufalc Zoufalc commented Sep 16, 2020

Summary

The aim of this PR is to make sure that the qGAN tutorial on how to load random distributions is up to date with recent version of the Qiskit master branches.

Details and comments

Replace aqua_globals.random with np.random

@nonhermitian
Copy link
Contributor

Since the tutorial now works, it needs to be moved out of the legacy dir and into the working tutorials. This will require making a new section for machine learning.

Also the authors, affiliation and embedded title image need to go to match the style of the other notebooks.

@Zoufalc
Copy link
Contributor Author

Zoufalc commented Sep 25, 2020

The qGAN training requires about an hour and can thus not suffice the 3 min cell limit
A cell timed out while it was being executed, after 180 seconds.
Can we avoid this requirement here?

@nonhermitian
Copy link
Contributor

nonhermitian commented Sep 26, 2020

So unfortunately not, we are bound by tight time limits due to the corresponding time limits in the CI build process. That being said, I think that this tutorial can be slimmed down by decreasing the number of epochs and also through code changes. Indeed, running profile on this training gives data copy at the time. This is an indication that things are not as optimal as they otherwise could be (see below). It is not clear if this is because of excessive circuit generation in Aqua, or if this is something in the transpiler (where most of the time is spent). The runtime is also not linear in the number of epochs. I am not sure if this is to be expected or not. 3000 epochs requires 3.5x longer runtime than a single one times 3000. Also, a single epoch is again dominated by data copies. I leave it to you @kdk, @mtreinish, and @levbishop to figure out where the core bottleneck is here.

Slimmed down profile for single epoch:

  ncalls  tottime  percall  cumtime  percall filename:lineno(function)
52480/421    0.061    0.000    0.174    0.000 copy.py:132(deepcopy)
       40    0.037    0.001    0.037    0.001 numpy_discriminator.py:145(leaky_relu_backward)
      122    0.022    0.000    0.022    0.000 {method 'acquire' of '_thread.lock' objects}
9234/3837    0.021    0.000    0.184    0.000 copy.py:269(_reconstruct)
      488    0.020    0.000    0.073    0.000 dagcircuit.py:819(substitute_node_with_dag)
    10824    0.020    0.000    0.054    0.000 copy.py:66(copy)
     1403    0.017    0.000    0.038    0.000 dagcircuit.py:302(apply_operation_back)
    94778    0.017    0.000    0.021    0.000 {built-in method builtins.isinstance}
      183    0.017    0.000    0.138    0.001 optimize_1q_gates.py:48(run)
   129760    0.016    0.000    0.016    0.000 {method 'get' of 'dict' objects}
      915    0.014    0.000    0.015    0.000 {built-in method builtins.__build_class__}
      976    0.012    0.000    0.020    0.000 quaternion.py:40(__mul__)
     5307    0.011    0.000    0.020    0.000 dagnode.py:34(__init__)
    22932    0.010    0.000    0.014    0.000 copy.py:253(_keep_alive)
 3059/238    0.010    0.000    0.169    0.001 copy.py:237(_deepcopy_dict)
    26342    0.010    0.000    0.010    0.000 {built-in method builtins.getattr}
     1159    0.009    0.000    0.010    0.000 {lexicographical_topological_sort}
     1342    0.009    0.000    0.013    0.000 inspect.py:2879(_bind)
     9234    0.009    0.000    0.009    0.000 {method '__reduce_ex__' of 'object' objects}
   106150    0.009    0.000    0.009    0.000 {built-in method builtins.id}
     5708    0.009    0.000    0.009    0.000 {built-in method numpy.array}
     1342    0.009    0.000    0.022    0.000 inspect.py:2117(_signature_from_function)
9610/3554    0.009    0.000    0.125    0.000 copy.py:211(_deepcopy_list)
     1220    0.008    0.000    0.016    0.000 dagcircuit.py:211(_add_wire)
       61    0.008    0.000    0.154    0.003 basis_translator.py:280(_compose_transforms)
    19174    0.008    0.000    0.008    0.000 {built-in method builtins.hasattr}
    16470    0.008    0.000    0.013    0.000 _collections_abc.py:879(__iter__)
       61    0.008    0.000    0.037    0.001 basis_translator.py:174(_basis_search)
4188/2088    0.007    0.000    0.121    0.000 copy.py:220(_deepcopy_tuple)

Profile for all 3000:

        4072311028 function calls (3842205028 primitive calls) in 7945.119 seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
 32472000 2145.413    0.000 2251.600    0.000 copy.py:66(copy)
  7686000 1508.082    0.000 1517.698    0.000 {built-in method builtins.any}
 10614000 1017.896    0.000 1019.949    0.000 parameterexpression.py:43(parameters)
  8601000  207.249    0.000  261.093    0.000 dagcircuit.py:285(_add_op_node)
157440000/1263000  188.931    0.000  542.001    0.000 copy.py:132(deepcopy)
   120000  121.570    0.001  121.816    0.001 numpy_discriminator.py:145(leaky_relu_backward)
  2196000  100.161    0.000  133.408    0.000 quaternion.py:57(normalize)
   366000   73.785    0.000   73.785    0.000 {method 'acquire' of '_thread.lock' objects}
27702000/11511000   65.113    0.000  574.761    0.000 copy.py:269(_reconstruct)
  1464000   63.918    0.000  419.964    0.000 dagcircuit.py:819(substitute_node_with_dag)
  4209000   58.241    0.000  123.849    0.000 dagcircuit.py:302(apply_operation_back)
389280000   53.263    0.000   53.898    0.000 {method 'get' of 'dict' objects}
284877002   52.305    0.000   62.787    0.000 {built-in method builtins.isinstance}
   549000   51.100    0.000  519.776    0.001 optimize_1q_gates.py:48(run)
  4026000   45.493    0.000  125.203    0.000 inspect.py:2198(_signature_from_callable)
  2745000   43.883    0.000   45.678    0.000 {built-in method builtins.__build_class__}
  2928000   35.898    0.000   61.280    0.000 quaternion.py:40(__mul__)
 15921000   33.906    0.000   62.562    0.000 dagnode.py:34(__init__)
 68796000   31.383    0.000   44.578    0.000 copy.py:253(_keep_alive)
9177000/714000   31.266    0.000  526.160    0.001 copy.py:237(_deepcopy_dict)
 79026000   30.327    0.000   30.832    0.000 {built-in method builtins.getattr}
  3477000   28.949    0.000   32.119    0.000 {lexicographical_topological_sort}
318450000   28.477    0.000   28.477    0.000 {built-in method builtins.id}
  4026000   27.828    0.000   40.879    0.000 inspect.py:2879(_bind)
 27702000   27.490    0.000   27.490    0.000 {method '__reduce_ex__' of 'object' objects}
28830000/10662000   26.477    0.000  391.696    0.000 copy.py:211(_deepcopy_list)
  4026000   26.259    0.000   66.897    0.000 inspect.py:2117(_signature_from_function)
 17124000   26.201    0.000   26.201    0.000 {built-in method numpy.array}
  3660000   24.151    0.000   47.606    0.000 dagcircuit.py:211(_add_wire)
 49410000   23.768    0.000   40.858    0.000 _collections_abc.py:879(__iter__)
 57522000   23.532    0.000   23.532    0.000 {built-in method builtins.hasattr}
   183000   23.043    0.000  665.520    0.004 basis_translator.py:280(_compose_transforms)
   183000   23.025    0.000  111.685    0.001 basis_translator.py:174(_basis_search)
12564000/6264000   22.776    0.000  379.270    0.000 copy.py:220(_deepcopy_tuple)
15504000/11478000   21.992    0.000 2483.358    0.000 instruction.py:318(__deepcopy__)
  4392000   21.890    0.000   37.223    0.000 quaternion.py:111(from_axis_rotation)
11106000/7056000   20.493    0.000   86.826    0.000 {built-in method numpy.core._multiarray_umath.implement_array_function}
   183000   19.283    0.000 4096.287    0.022 basis_translator.py:70(run)
  1098000   17.803    0.000  193.539    0.000 basic.py:790(subs)
  2196000   17.455    0.000  495.011    0.000 circuit_to_dag.py:20(circuit_to_dag)
 93696000   17.202    0.000   17.202    0.000 quaternion.py:31(__call__)
150927000   17.164    0.000   17.164    0.000 {method 'append' of 'list' objects}
 49410000   17.090    0.000   17.090    0.000 quantumcircuitdata.py:31(__getitem__)
  2745000   17.080    0.000 4979.125    0.002 runningpassmanager.py:152(_run_this_pass)
  1098000   16.941    0.000   48.256    0.000 dagcircuit.py:1339(collect_runs)
  4026000   16.599    0.000  199.576    0.000 basepasses.py:35(_freeze_init_parameters)
  2928000   15.675    0.000   61.781    0.000 basis_translator.py:252(<listcomp>)
  2745000   15.336    0.000   79.388    0.000 dagcircuit.py:189(add_qreg)
  2928000   14.717    0.000   20.113    0.000 dagcircuit.py:398(_check_edgemap_registers)
 39528000   14.531    0.000   40.196    0.000 basis_translator.py:252(<genexpr>)
  3477000   14.416    0.000   49.805    0.000 register.py:38(__init__)
   183000   13.943    0.000 7761.998    0.042 quantum_generator.py:216(get_output)
  1647000   13.930    0.000 1546.458    0.001 quantumcircuit.py:140(__init__)
 24588000   13.479    0.000   21.669    0.000 copyreg.py:87(__newobj__)
  4026000   13.311    0.000  221.996    0.000 basepasses.py:30(__call__)
  4401000   13.246    0.000   13.246    0.000 {method 'reduce' of 'numpy.ufunc' objects}
  9699000   13.170    0.000   16.976    0.000 register.py:107(__getitem__)
   732000   12.879    0.000   31.837    0.000 quaternion.py:76(to_matrix)
  8418000   12.741    0.000   22.342    0.000 inspect.py:2467(__init__)
1830000/1098000   12.270    0.000   74.385    0.000 numbers.py:1031(__new__)
 99552000   12.217    0.000   12.217    0.000 bit.py:75(__hash__)
71538001/67146001   12.214    0.000   14.564    0.000 {built-in method builtins.len}
  2745000   12.196    0.000   57.896    0.000 dagcircuit.py:52(__init__)
  2196000   12.141    0.000 1460.267    0.001 quantumcircuit.py:1756(assign_parameters)
  1464000   11.895    0.000  175.672    0.000 quantumcircuit.py:1533(copy)
 10248000   11.562    0.000   14.738    0.000 register.py:99(__repr__)
 10248000   11.229    0.000   25.967    0.000 bit.py:71(__repr__)
12564000/6264000   11.157    0.000  367.901    0.000 copy.py:221(<listcomp>)
  9240000   11.014    0.000   11.014    0.000 {built-in method numpy.zeros}
 44469000   10.829    0.000   10.829    0.000 dagnode.py:72(op)
   732000   10.532    0.000   53.428    0.000 sympify.py:66(_convert_numpy_types)
 17505000   10.481    0.000   27.557    0.000 <frozen importlib._bootstrap>:1009(_handle_fromlist)
  5856000   10.085    0.000   18.702    0.000 dagcircuit.py:1049(op_nodes)
 19935000   10.045    0.000   10.045    0.000 {method 'update' of 'dict' objects}
  1218000    9.905    0.000   29.113    0.000 basic.py:1878(_aresame)
  4941000    9.769    0.000   13.748    0.000 basis_translator.py:166(_basis_heuristic)
 28797000    9.443    0.000    9.489    0.000 {built-in method __new__ of type object at 0x10d0343a8}
 21960000    9.148    0.000    9.148    0.000 {method 'add_edge' of 'retworkx.PyDiGraph' objects}
  1098000    9.093    0.000  217.815    0.000 parameterexpression.py:52(bind)
   366000    9.060    0.000  173.423    0.000 circuit_to_instruction.py:23(circuit_to_instruction)
  5856000    9.000    0.000   13.689    0.000 instruction.py:138(params)
   915000    8.830    0.000 3687.586    0.004 dag_to_circuit.py:19(dag_to_circuit)
  4026000    8.782    0.000   13.945    0.000 inspect.py:2750(__init__)
549000/183000    8.670    0.000  296.084    0.002 unroll_custom_definitions.py:40(run)
   549000    8.533    0.000   23.372    0.000 optimize_1q_gates.py:267(_split_runs_on_parameters)
  3477000    8.453    0.000   57.073    0.000 quantumcircuit.py:805(_append)
  3477000    8.451    0.000   17.789    0.000 quantumcircuit.py:837(_update_parameter_table)
   732000    8.310    0.000   20.045    0.000 numeric.py:2274(within_tol)
  7320000    8.238    0.000    8.239    0.000 {method 'predecessors' of 'retworkx.PyDiGraph' objects}
  3477000    8.238    0.000    9.926    0.000 parametertable.py:27(__init__)
  1464000    8.226    0.000  231.017    0.000 quaternion.py:138(from_euler)
  5307000    7.744    0.000   22.136    0.000 instruction.py:54(__init__)
   915000    7.672    0.000    7.672    0.000 {built-in method posix.urandom}
  2196000    7.563    0.000   19.303    0.000 function_base.py:422(asarray_chkfinite)
 15921000    7.402    0.000    7.402    0.000 {method 'add_node' of 'retworkx.PyDiGraph' objects}
  1464000    7.302    0.000    9.877    0.000 dagcircuit.py:450(_check_wiremap_validity)
  4941000    7.213    0.000   29.415    0.000 gate.py:28(__init__)
  5490000    7.012    0.000   85.506    0.000 sympify.py:90(sympify)
 49776000    7.007    0.000    7.007    0.000 register.py:75(name)
 14457000    6.820    0.000   18.669    0.000 {built-in method builtins.all}
 71718000    6.802    0.000    6.802    0.000 copy.py:190(_deepcopy_atomic)
  2196000    6.784    0.000   33.791    0.000 compatibility.py:570(ordered)
 33969000    6.692    0.000   10.864    0.000 {built-in method builtins.next}
  5856000    6.655    0.000    6.655    0.000 {method 'nodes' of 'retworkx.PyDiGraph' objects}
   510000    6.515    0.000    9.294    0.000 numpy_discriminator.py:90(leaky_relu)
  3477000    6.388    0.000   23.766    0.000 register.py:69(<listcomp>)
 40275000    6.381    0.000    6.381    0.000 {built-in method builtins.issubclass}
  1647000    6.336    0.000 1518.336    0.001 quantumcircuit.py:861(add_register)
  9150002    6.314    0.000    6.822    0.000 {built-in method _abc._abc_instancecheck}
 16653000    6.314    0.000    9.623    0.000 dagnode.py:115(__hash__)
30744000/30195000    6.276    0.000    7.229    0.000 {built-in method builtins.hash}
  2196000    6.177    0.000   28.066    0.000 misc.py:19(norm)
 10797000    6.100    0.000   10.874    0.000 quantumcircuit.py:179(data)
  2745000    6.094    0.000    8.682    0.000 runningpassmanager.py:191(_log_pass)
   732000    6.019    0.000  343.506    0.000 optimize_1q_gates.py:240(yzy_to_zyz)
  1098000    5.906    0.000 1024.202    0.001 quantumcircuit.py:1890(_substitute_parameter)
 21468000    5.878    0.000   30.075    0.000 copy.py:274(<genexpr>)
 10065000    5.728    0.000    5.728    0.000 register.py:133(__iter__)
  4392000    5.653    0.000   17.356    0.000 quantumregister.py:28(__init__)
 40260000    5.469    0.000    5.469    0.000 bit.py:49(register)
  4026000    5.450    0.000    8.950    0.000 inspect.py:484(unwrap)
  1464000    5.370    0.000    7.405    0.000 dagcircuit.py:748(_full_pred_succ_maps)
   915000    5.369    0.000  225.225    0.000 quantumcircuit.py:1876(_bind_parameter)
  8052000    5.355    0.000   13.554    0.000 quaternion.py:28(__init__)
  4392000    5.319    0.000   11.113    0.000 bit.py:26(__init__)
  2205000    5.301    0.000   16.607    0.000 fromnumeric.py:70(_wrapreduction)
  8418000    5.239    0.000    7.320    0.000 enum.py:289(__call__)
  2196000    5.205    0.000   10.006    0.000 dagcircuit.py:164(global_phase)
 15738000    5.165    0.000    5.165    0.000 dagcircuit.py:817(<genexpr>)
  3294000    5.092    0.000    8.419    0.000 libmpf.py:291(from_man_exp)
  9333000    5.071    0.000 2466.314    0.000 instruction.py:300(copy)
   732000    5.048    0.000   47.625    0.000 numeric.py:2197(isclose)
  2196000    4.980    0.000   14.924    0.000 dagcircuit.py:730(_make_pred_succ_maps)
  2745000    4.841    0.000 4993.727    0.002 runningpassmanager.py:125(_do_pass)
  2928000    4.823    0.000    4.823    0.000 optimize_1q_gates.py:262(<genexpr>)
   183000    4.821    0.000  202.842    0.001 level1.py:56(level_1_pass_manager)
 34077000    4.815    0.000    4.815    0.000 {method 'items' of 'dict' objects}
   255000    4.806    0.000   30.256    0.000 numpy_discriminator.py:75(forward)
  1098000    4.787    0.000   23.634    0.000 compatibility.py:548(_nodes)
 10797000    4.774    0.000    4.774    0.000 quantumcircuitdata.py:28(__init__)
   183000    4.743    0.000    4.743    0.000 {built-in method posix.stat}
  2928000    4.737    0.000    7.536    0.000 dagcircuit.py:943(substitute_node)
 29832000    4.697    0.000    4.697    0.000 parameter.py:82(__hash__)
  1830000    4.577    0.000    9.008    0.000 numbers.py:149(mpf_norm)
5856000/2928000    4.550    0.000    5.789    0.000 equivalence.py:229(_get_equivalences)
  3477000    4.526    0.000    6.245    0.000 quantumcircuit.py:896(_check_dups)
   183000    4.512    0.000   17.602    0.000 assemble_circuits.py:22(_assemble_circuit)
  3477000    4.467    0.000   37.449    0.000 dagcircuit.py:796(topological_nodes)
  8418000    4.451    0.000    5.280    0.000 dagcircuit.py:256(_check_bits)
 14457000    4.435    0.000    5.780    0.000 {method 'add' of 'set' objects}
  1830000    4.406    0.000    7.078    0.000 circuit_to_instruction.py:82(find_bit_position)
  1464000    4.354    0.000    5.828    0.000 dagcircuit.py:704(_check_wires_list)
 12699000    4.305    0.000   18.126    0.000 _asarray.py:14(asarray)
  2928000    4.272    0.000    4.272    0.000 {method 'match' of 're.Pattern' objects}
 29412000    4.265    0.000    4.265    0.000 {method 'copy' of 'list' objects}
   732000    4.263    0.000   37.988    0.000 quaternion.py:90(to_zyz)
  6588000    4.230    0.000    5.083    0.000 expr.py:106(__hash__)
  4026000    4.169    0.000    4.169    0.000 basepasses.py:54(__init__)
   915000    4.053    0.000    5.289    0.000 uuid.py:121(__init__)
  2745000    4.006    0.000    9.079    0.000 runningpassmanager.py:196(_update_valid_passes)
   732000    3.996    0.000   10.765    0.000 dagcircuit.py:1176(remove_op_node)
 12444000    3.943    0.000    5.163    0.000 inspect.py:2799(<genexpr>)
 31476000    3.940    0.000    3.940    0.000 bit.py:60(index)
   549000    3.901    0.000    3.901    0.000 {dag_longest_path_length}
 20130000    3.847    0.000    3.847    0.000 instruction.py:133(params)
   978000    3.847    0.000    7.890    0.000 numbers.py:1389(__eq__)
  1647000    3.835    0.000   21.855    0.000 cache.py:91(wrapper)
  3477000    3.763    0.000   17.296    0.000 quantumcircuit.py:902(_check_qargs)
  7869000    3.744    0.000    6.947    0.000 quantumcircuit.py:906(<genexpr>)
   732000    3.736    0.000    4.991    0.000 libmpf.py:1290(str_to_man_exp)
  9150002    3.660    0.000   10.482    0.000 abc.py:137(__instancecheck__)
2562000/1281000    3.647    0.000    5.261    0.000 equivalence.py:91(has_entry)
  1464000    3.642    0.000    8.443    0.000 _ufunc_config.py:32(seterr)
  1464000    3.622    0.000    8.784    0.000 dagcircuit.py:145(wires)
   183000    3.589    0.000 6689.161    0.037 runningpassmanager.py:95(run)
 10980000    3.518    0.000    6.105    0.000 instruction.py:168(<genexpr>)
 18456000    3.500    0.000    3.500    0.000 {built-in method builtins.setattr}
  2013000    3.498    0.000    5.540    0.000 parametertable.py:71(__delitem__)
  1464000    3.481    0.000    4.853    0.000 quantumcircuit.py:1562(<listcomp>)
 14823000    3.455    0.000    3.455    0.000 {built-in method builtins.iter}
  2196000    3.417    0.000    4.721    0.000 quantumcircuit.py:1863(_unroll_param_dict)
 24705000    3.405    0.000    3.405    0.000 basis_translator.py:171(<genexpr>)
   183000    3.331    0.000  664.573    0.004 quantum_generator.py:192(construct_circuit)
  2196000    3.328    0.000    3.328    0.000 {method 'in_edges' of 'retworkx.PyDiGraph' objects}
  2928000    3.307    0.000    4.876    0.000 re.py:273(_compile)
 18483000    3.254    0.000    3.254    0.000 register.py:87(size)
  4026000    3.224    0.000   44.104    0.000 inspect.py:3010(bind)
  2928000    3.188    0.000   20.746    0.000 optimize_1q_gates.py:84(<listcomp>)
 15372000    3.185    0.000    3.185    0.000 {built-in method builtins.abs}
 23241000    3.170    0.000    3.170    0.000 dagcircuit.py:804(_key)
  2196000    3.150    0.000    9.276    0.000 {method 'all' of 'numpy.generic' objects}
  6039000    3.126    0.000    5.813    0.000 {method 'extend' of 'list' objects}
  2196000    3.088    0.000    4.469    0.000 basis_translator.py:323(<listcomp>)
  1464000    3.076    0.000   30.539    0.000 dagcircuit.py:858(<dictcomp>)
  3477000    3.061    0.000    6.361    0.000 quantumcircuit.py:909(_check_cargs)
  4998000    3.056    0.000    4.278    0.000 <frozen importlib._bootstrap>:416(parent)
 25071000    3.029    0.000    3.029    0.000 inspect.py:2517(name)
  1218000    3.027    0.000    6.810    0.000 expr.py:124(__eq__)
  3477000    3.023    0.000    3.023    0.000 {method 'successors' of 'retworkx.PyDiGraph' objects}
  2196000    3.005    0.000   17.557    0.000 parameterexpression.py:248(__float__)
  1464000    2.995    0.000    3.192    0.000 _ufunc_config.py:132(geterr)
  3477000    2.978    0.000   40.427    0.000 dagcircuit.py:810(topological_op_nodes)
 20679000    2.958    0.000    2.958    0.000 {method 'keys' of 'dict' objects}
   183000    2.912    0.000    8.384    0.000 transpile.py:380(_parse_transpile_args)
  1464000    2.899    0.000  122.041    0.000 quantumcircuit.py:1553(<dictcomp>)
  5124000    2.898    0.000    3.677    0.000 parametertable.py:36(__getitem__)
  1464000    2.818    0.000   14.417    0.000 circuit_to_instruction.py:109(<lambda>)
   915000    2.810    0.000    4.563    0.000 instruction.py:204(assemble)
   549000    2.810    0.000    7.791    0.000 parameter.py:46(__init__)
    60000    2.763    0.000  132.517    0.002 numpy_discriminator.py:128(backward)
  8247000    2.693    0.000    2.693    0.000 __init__.py:1614(isEnabledFor)
  7068012    2.669    0.000    4.121    0.000 basic.py:2012(_preorder_traversal)
   732000    2.667    0.000   19.599    0.000 libmpf.py:1313(from_str)
  1098000    2.613    0.000   85.297    0.000 basic.py:932(<listcomp>)
  5124000    2.603    0.000    2.603    0.000 {method 'remove_edge' of 'retworkx.PyDiGraph' objects}
  4026000    2.589    0.000  130.158    0.000 inspect.py:3081(signature)
   183000    2.584    0.000 7058.099    0.039 quantum_instance.py:251(execute)
  1098000    2.561    0.000    3.928    0.000 parametertable.py:39(__setitem__)
  8052000    2.556    0.000    3.389    0.000 inspect.py:158(isfunction)
  1098000    2.525    0.000    3.250    0.000 util.py:152(is_main_process)
  2928000    2.523    0.000   11.508    0.000 instruction.py:166(is_parameterized)
  2196000    2.474    0.000    2.914    0.000 dagcircuit.py:742(<dictcomp>)
  4026000    2.366    0.000  127.569    0.000 inspect.py:2829(from_callable)
  1098000    2.352    0.000    9.263    0.000 numbers.py:1191(_new)
 13359000    2.349    0.000    2.349    0.000 dagnode.py:83(qargs)
   549000    2.334    0.000   21.900    0.000 parametervector.py:23(__init__)
   165000    2.329    0.000 7537.922    0.046 quantum_generator.py:318(objective_function)
  3534000    2.325    0.000    2.325    0.000 basic.py:2008(__init__)
  4392000    2.323    0.000    5.031    0.000 bit.py:46(_update_hash)
  2196000    2.315    0.000   12.658    0.000 numbers.py:672(__float__)
   549000    2.310    0.000    4.026    0.000 fixed_point.py:39(run)
  2196000    2.288    0.000   18.827    0.000 fromnumeric.py:2337(all)
  1992000    2.285    0.000    2.285    0.000 {method 'reshape' of 'numpy.ndarray' objects}
   915000    2.284    0.000   15.245    0.000 uuid.py:759(uuid4)
  3294000    2.268    0.000    5.608    0.000 sympify.py:413(_sympify)
  2196000    2.257    0.000   19.487    0.000 u3.py:63(__init__)
  2928000    2.245    0.000   14.609    0.000 optimize_1q_gates.py:274(<lambda>)
  1098000    2.244    0.000   14.072    0.000 basic.py:1558(count)
   183000    2.231    0.000 6923.076    0.038 transpile.py:44(transpile)
  1464000    2.199    0.000    4.458    0.000 quantumcircuit.py:1556(<dictcomp>)
  3843000    2.190    0.000    3.656    0.000 __init__.py:1368(info)
  1464000    2.187    0.000    4.377    0.000 dagcircuit.py:148(<listcomp>)
     3000    2.182    0.001    2.214    0.001 {method 'shuffle' of 'numpy.random._generator.Generator' objects}
   366000    2.175    0.000   11.673    0.000 quantumcircuit.py:770(append)
  4758000    2.167    0.000    9.241    0.000 {built-in method builtins.sum}
   549000    2.162    0.000   20.500    0.000 cx_cancellation.py:23(run)
  7869000    2.157    0.000    2.625    0.000 quantumcircuit.py:904(<genexpr>)
    30000    2.140    0.000 7302.158    0.243 optimizer.py:71(gradient_num_diff)
   255000    2.137    0.000    2.137    0.000 numpy_discriminator.py:86(sigmoid)
  1464000    2.124    0.000    2.611    0.000 quantumcircuit.py:1550(<dictcomp>)
  2196000    2.114    0.000   11.272    0.000 _collections_abc.py:440(__lt__)
 18666000    2.111    0.000    2.111    0.000 inspect.py:2529(kind)
  3660000    2.106    0.000    2.106    0.000 libmpf.py:153(_normalize)
   732000    2.104    0.000    4.476    0.000 libmpf.py:950(mpf_div)
  8418000    2.081    0.000    2.081    0.000 enum.py:531(__new__)
  2379000    2.046    0.000    4.517    0.000 runningpassmanager.py:304(__iter__)
  4392000    2.017    0.000    2.470    0.000 quantumcircuit.py:235(has_register)
  5124000    2.000    0.000    4.550    0.000 dagcircuit.py:907(<lambda>)
  1647000    1.989    0.000    1.989    0.000 quantumcircuit.py:220(_increment_instances)
 10065000    1.913    0.000    1.913    0.000 dagcircuit.py:274(_bits_in_condition)
   183000    1.901    0.000    6.750    0.000 assemble.py:176(_parse_common_args)
  4872000    1.880    0.000    7.446    0.000 basic.py:2056(__next__)
  4392000    1.879    0.000    1.885    0.000 {method 'union' of 'set' objects}
   732000    1.874    0.000    1.874    0.000 {method 'dot' of 'numpy.ndarray' objects}
   183000    1.872    0.000   13.394    0.000 run_circuits.py:325(run_on_backend)
   732000    1.865    0.000    2.077    0.000 getlimits.py:366(__new__)
  1830000    1.857    0.000    2.649    0.000 parametervector.py:49(__iter__)
  2196000    1.854    0.000   29.919    0.000 quaternion.py:52(norm)
  1962000    1.841    0.000    7.589    0.000 fromnumeric.py:52(_wrapfunc)
   183000    1.829    0.000   96.578    0.001 run_circuits.py:182(run_qobj)
   183000    1.823    0.000  275.733    0.002 univariate_variational_distribution.py:68(build)
  2196000    1.823    0.000    2.586    0.000 blas.py:372(getter)
  2196000    1.814    0.000    2.632    0.000 _collections_abc.py:672(keys)
  2928000    1.813    0.000    8.378    0.000 libmpf.py:330(from_int)
  1098000    1.800    0.000    2.242    0.000 basic.py:108(__new__)
   183000    1.799    0.000   20.981    0.000 assemble_circuits.py:114(assemble_circuits)
  2745000    1.794    0.000    1.794    0.000 dagcircuit.py:82(DummyCallableList)
  4392000    1.778    0.000   14.984    0.000 _methods.py:56(_all)
  2196000    1.772    0.000   23.901    0.000 <__array_function__ internals>:2(all)
  2562000    1.762    0.000    1.762    0.000 {built-in method _bisect.bisect_right}
  2196000    1.758    0.000    1.758    0.000 {method 'remove_node' of 'retworkx.PyDiGraph' objects}
  1098000    1.732    0.000    2.528    0.000 parameterexpression.py:74(<dictcomp>)
   165000    1.731    0.000    4.852    0.000 quantum_generator.py:288(loss)
  2196000    1.730    0.000    1.730    0.000 {method 'out_edges' of 'retworkx.PyDiGraph' objects}
   183000    1.728    0.000    4.658    0.000 thread.py:145(submit)
  1098000    1.705    0.000    3.760    0.000 sympify.py:56(_is_numpy_instance)
   732000    1.702    0.000    2.584    0.000 numeric.py:1897(binary_repr)
   732000    1.645    0.000  345.151    0.000 optimize_1q_gates.py:222(compose_u3)
   366000    1.638    0.000  175.673    0.000 quantumcircuit.py:916(to_instruction)
  1647000    1.632    0.000    1.965    0.000 quantumcircuit.py:1727(global_phase)
  2196000    1.617    0.000    1.973    0.000 dagcircuit.py:744(<dictcomp>)
  2196000    1.608    0.000    7.074    0.000 basic.py:1561(<genexpr>)
  1098000    1.607    0.000    3.226    0.000 parameterexpression.py:142(_raise_if_passed_unknown_parameters)
   183000    1.600    0.000 6696.064    0.037 passmanager.py:257(_run_single_circuit)
    30000    1.593    0.000 7688.678    0.256 adam_amsgrad.py:172(minimize)
  4941000    1.592    0.000    1.592    0.000 {built-in method _heapq.heappush}
  1932000    1.574    0.000   11.905    0.000 <__array_function__ internals>:2(reshape)
   183000    1.556    0.000 6901.086    0.038 transpile.py:261(_transpile_circuit)
   732000    1.538    0.000   58.758    0.000 numeric.py:2121(allclose)
  1932000    1.521    0.000    8.826    0.000 fromnumeric.py:199(reshape)
  7320000    1.512    0.000    1.512    0.000 {built-in method time.time}
  4026000    1.499    0.000    2.150    0.000 inspect.py:504(_is_wrapper)
   183000    1.493    0.000   32.562    0.000 assemble.py:43(assemble)
  2196000    1.475    0.000   10.333    0.000 {method 'all' of 'numpy.ndarray' objects}
   915000    1.470    0.000    2.288    0.000 assemble_circuits.py:72(<listcomp>)
  1830000    1.454    0.000   11.599    0.000 circuit_to_instruction.py:111(<lambda>)
  2928000    1.448    0.000    6.324    0.000 re.py:234(compile)
  5490000    1.428    0.000    1.428    0.000 basepasses.py:60(__hash__)
   915000    1.416    0.000    1.416    0.000 {built-in method builtins.repr}
  4758000    1.414    0.000    1.689    0.000 parametertable.py:34(<genexpr>)
  8418000    1.412    0.000    1.412    0.000 {method 'isidentifier' of 'str' objects}
   366000    1.411    0.000 6920.183    0.019 parallel.py:73(parallel_map)
  1704000    1.360    0.000    1.360    0.000 {built-in method builtins.sorted}
  1647000    1.357    0.000    1.610    0.000 quantumcircuit.py:141(<listcomp>)
   990000    1.355    0.000    1.355    0.000 {method '__deepcopy__' of 'numpy.generic' objects}
  2562000    1.345    0.000    1.345    0.000 sympify.py:62(<genexpr>)
   183000    1.335    0.000    1.364    0.000 run_circuits.py:81(_split_qobj_to_qobjs)
  2562000    1.326    0.000    3.088    0.000 libintmath.py:83(python_bitcount)
  4209000    1.326    0.000    1.326    0.000 {method 'get_node_data' of 'retworkx.PyDiGraph' objects}
  3843000    1.322    0.000    2.547    0.000 basepasses.py:90(is_analysis_pass)
  4026000    1.310    0.000    1.310    0.000 inspect.py:2609(__init__)
   183000    1.298    0.000   77.320    0.000 _base.py:408(result)
  2757000    1.291    0.000    1.979    0.000 __init__.py:1356(debug)
  2928000    1.288    0.000    1.288    0.000 dagnode.py:79(op)
  7686000    1.286    0.000    1.286    0.000 {method 'values' of 'collections.OrderedDict' objects}
  4758000    1.279    0.000    1.279    0.000 quantumcircuit.py:1722(global_phase)
   732000    1.275    0.000    1.275    0.000 libmpf.py:208(_normalize1)
   183000    1.271    0.000 6924.516    0.038 quantum_instance.py:224(transpile)
  1098000    1.240    0.000    5.064    0.000 numbers.py:1484(__hash__)
   549000    1.237    0.000    1.777    0.000 symbol.py:177(_sanitize)
  4998000    1.222    0.000    1.222    0.000 {method 'rpartition' of 'str' objects}
  2745000    1.218    0.000    1.218    0.000 basepasses.py:66(name)
  5307000    1.210    0.000    1.210    0.000 instruction.py:179(definition)
  1515000    1.202    0.000    9.934    0.000 <__array_function__ internals>:2(dot)
   915000    1.190    0.000    5.972    0.000 gate.py:85(assemble)
  1098000    1.186    0.000    5.089    0.000 parameterexpression.py:148(_raise_if_passed_non_real_value)
  8052000    1.185    0.000    1.185    0.000 register.py:154(__hash__)
732000/549000    1.176    0.000    2.067    0.000 runningpassmanager.py:258(controller_factory)
   183000    1.173    0.000    1.943    0.000 basis_translator.py:298(<dictcomp>)
   765000    1.173    0.000   17.924    0.000 numpy_discriminator.py:94(single_layer_forward_propagation)
   549000    1.171    0.000    3.565    0.000 symbol.py:209(__new__)
   549000    1.162    0.000    1.162    0.000 {is_directed_acyclic_graph}
   549000    1.144    0.000   11.108    0.000 parameter.py:26(__new__)
   732000    1.130    0.000   11.459    0.000 libmpf.py:491(from_rational)
  2196000    1.129    0.000    1.776    0.000 libmpf.py:454(to_float)
  4026000    1.121    0.000    1.368    0.000 {method 'discard' of 'set' objects}
  4026000    1.119    0.000    1.119    0.000 {method 'values' of 'mappingproxy' objects}
  1464000    1.119    0.000    1.119    0.000 {built-in method numpy.seterrobj}
   732000    1.109    0.000    1.892    0.000 _collections_abc.py:664(__contains__)
   366000    1.104    0.000    3.290    0.000 libmpf.py:410(from_float)
   183000    1.090    0.000   75.466    0.000 threading.py:264(wait)
   366000    1.076    0.000    1.076    0.000 uuid.py:266(__str__)
  1098000    1.071    0.000    1.575    0.000 fencedobjs.py:65(__init__)
   549000    1.071    0.000    6.134    0.000 dagcircuit.py:665(depth)
  1098000    1.047    0.000    2.733    0.000 basic.py:2063(_make_find_query)
  4392000    1.042    0.000    1.042    0.000 {built-in method math.sin}
  1098000    1.026    0.000    4.345    0.000 _collections_abc.py:790(pop)
  1098000    1.024    0.000    1.419    0.000 basic.py:954(<listcomp>)
  5124000    1.023    0.000    1.023    0.000 parameter.py:57(name)
  1464000    1.010    0.000    3.536    0.000 numbers.py:2080(_as_mpf_val)
  4758000    0.996    0.000    0.996    0.000 basis_translator.py:209(<lambda>)
  2196000    0.993    0.000    3.350    0.000 _collections_abc.py:701(__len__)
  1500000    0.989    0.000    2.334    0.000 <__array_function__ internals>:2(shape)
  2205000    0.979    0.000    0.979    0.000 fromnumeric.py:71(<dictcomp>)
  1218000    0.977    0.000    7.786    0.000 basic.py:357(__ne__)
  2745000    0.966    0.000    1.684    0.000 basepasses.py:81(is_transformation_pass)
  1281000    0.964    0.000    1.148    0.000 quantumcircuit.py:1557(<listcomp>)
  1464000    0.955    0.000    1.443    0.000 basis_translator.py:90(<genexpr>)
   915000    0.954    0.000    0.954    0.000 {method 'item' of 'numpy.generic' objects}
  3660000    0.946    0.000    0.946    0.000 runningpassmanager.py:216(__iter__)
  1647000    0.941    0.000    1.288    0.000 quantumcircuit.py:866(<listcomp>)
  2562000    0.938    0.000    1.614    0.000 <string>:1(__new__)
  1098000    0.927    0.000    3.761    0.000 parameterexpression.py:149(<dictcomp>)
   549000    0.913    0.000    1.262    0.000 fencedobjs.py:32(__getitem__)
  4392000    0.910    0.000    0.910    0.000 {built-in method math.cos}
   732000    0.907    0.000    6.144    0.000 _ufunc_config.py:433(__enter__)
  3660000    0.899    0.000    0.899    0.000 dagcircuit.py:133(qubits)
   732000    0.890    0.000   61.598    0.000 <__array_function__ internals>:2(allclose)
  1098000    0.879    0.000    3.824    0.000 numbers.py:807(__hash__)
   549000    0.877    0.000    8.209    0.000 depth.py:23(run)
  2196000    0.876    0.000    1.226    0.000 parametertable.py:79(__len__)
   549000    0.875    0.000    3.659    0.000 runningpassmanager.py:61(append)
   183000    0.867    0.000    1.136    0.000 transpile.py:234(_check_circuits_coupling_map)
   330000    0.861    0.000    0.861    0.000 {method '__deepcopy__' of 'numpy.ndarray' objects}
  1464000    0.859    0.000    1.241    0.000 parametertable.py:76(__iter__)
  2928000    0.855    0.000    1.123    0.000 {method 'index' of 'list' objects}
  1098000    0.853    0.000    1.019    0.000 parameterexpression.py:84(<dictcomp>)
   366000    0.849    0.000  221.301    0.001 n_local.py:734(assign_parameters)
   183000    0.836    0.000    1.514    0.000 result.py:308(_get_experiment)
   732000    0.835    0.000    2.901    0.000 <__array_function__ internals>:2(size)
  1830000    0.830    0.000    0.830    0.000 {method 'startswith' of 'str' objects}
  4392000    0.830    0.000    0.830    0.000 dagcircuit.py:475(_map_condition)
   366000    0.830    0.000    3.669    0.000 blueprintcircuit.py:82(qregs)
   219000    0.825    0.000    3.156    0.000 fromnumeric.py:39(_wrapit)
  2196000    0.819    0.000    0.819    0.000 _collections_abc.py:698(__init__)
   183000    0.817    0.000    1.345    0.000 assemble.py:347(_parse_circuit_args)
  1647000    0.811    0.000    0.811    0.000 parameterexpression.py:29(__init__)
   732000    0.807    0.000   49.818    0.000 <__array_function__ internals>:2(isclose)
   549000    0.801    0.000    1.457    0.000 unroll_custom_definitions.py:26(__init__)
   183000    0.796    0.000   33.457    0.000 quantum_instance.py:247(assemble)
   183000    0.793    0.000    1.090    0.000 threading.py:216(__init__)
  4026000    0.781    0.000    0.781    0.000 {built-in method sys.getrecursionlimit}
   732000    0.775    0.000    3.980    0.000 _ufunc_config.py:438(__exit__)
  1647000    0.770    0.000    0.770    0.000 {method 'intersection_update' of 'set' objects}
   183000    0.768    0.000    1.866    0.000 backend_utils.py:73(is_aer_provider)
   366000    0.763    0.000    1.386    0.000 backend_utils.py:131(is_statevector_backend)
   360000    0.753    0.000    1.025    0.000 quantum_instance.py:381(set_config)
   732000    0.747    0.000    1.457    0.000 quantumcircuit.py:744(qbit_argument_conversion)
  4209000    0.742    0.000    0.742    0.000 dagcircuit.py:242(_check_condition)
  2928000    0.738    0.000    0.738    0.000 {method 'pop' of 'dict' objects}
   183000    0.735    0.000    5.302    0.000 passmanager.py:220(_create_running_passmanager)
  4026000    0.724    0.000    0.724    0.000 {method 'items' of 'collections.OrderedDict' objects}
   549000    0.723    0.000    1.198    0.000 fencedobjs.py:28(__getattribute__)
   183000    0.722    0.000    0.722    0.000 {method 'put' of '_queue.SimpleQueue' objects}
   915000    0.704    0.000    0.980    0.000 quantumcircuit.py:1746(parameters)
   366000    0.693    0.000   46.860    0.000 blueprintcircuit.py:136(copy)
   732000    0.693    0.000    5.032    0.000 numbers.py:1236(_as_mpf_val)
   732000    0.687    0.000    0.987    0.000 instruction.py:210(<listcomp>)
  2928000    0.686    0.000    0.686    0.000 {built-in method numpy.geterrobj}
   732000    0.686    0.000    1.977    0.000 <__array_function__ internals>:2(result_type)
   183000    0.674    0.000    7.406    0.000 user_config.py:98(get_config)
  3477000    0.671    0.000    0.671    0.000 register.py:103(__len__)
  1098000    0.669    0.000   24.303    0.000 basic.py:951(<lambda>)
   366000    0.669    0.000    2.620    0.000 quantumcircuit.py:797(<listcomp>)
   549000    0.667    0.000    0.667    0.000 {method 'format' of 'str' objects}
  4575000    0.665    0.000    0.665    0.000 basis_translator.py:227(<genexpr>)
  4209000    0.664    0.000    0.664    0.000 {built-in method builtins.callable}
   549000    0.661    0.000    1.629    0.000 passmanager.py:68(append)
   366000    0.651    0.000    1.197    0.000 libmpf.py:64(dps_to_prec)
  2013000    0.650    0.000    0.650    0.000 blueprintcircuit.py:77(qregs)
   732000    0.647    0.000    0.647    0.000 {built-in method math.ldexp}
        1    0.642    0.642 7945.119 7945.119 qgan.py:270(train)
  1098000    0.636    0.000    0.636    0.000 fencedobjs.py:40(_check_if_fenced)
   732000    0.630    0.000    0.630    0.000 _ufunc_config.py:429(__init__)
  1824000    0.628    0.000    3.462    0.000 _asarray.py:86(asanyarray)
   732000    0.617    0.000    0.955    0.000 instruction.py:344(broadcast_arguments)
  1098000    0.615    0.000    1.866    0.000 assemble_circuits.py:61(<genexpr>)
  1281000    0.607    0.000    0.607    0.000 {built-in method builtins.max}
   183000    0.605    0.000 6696.688    0.037 passmanager.py:172(run)
   366000    0.602    0.000    1.310    0.000 blueprintcircuit.py:86(<listcomp>)
  1281000    0.601    0.000    0.601    0.000 fencedobjs.py:24(__init__)
  1098000    0.599    0.000    0.599    0.000 {method 'pop' of 'list' objects}
  1464000    0.595    0.000    0.595    0.000 dagcircuit.py:424(<dictcomp>)
   366000    0.593    0.000    1.530    0.000 n_local.py:666(_invalidate)
   183000    0.593    0.000    1.683    0.000 _base.py:312(__init__)
   183000    0.593    0.000    0.812    0.000 transpile.py:256(_log_transpile_time)
   183000    0.591    0.000    0.908    0.000 runningpassmanager.py:35(__init__)
   183000    0.590    0.000    1.006    0.000 os.py:676(__getitem__)
   915000    0.581    0.000    0.581    0.000 {built-in method from_bytes}
  4026000    0.580    0.000    0.580    0.000 inspect.py:2835(parameters)
  1464000    0.580    0.000    0.580    0.000 {built-in method math.atan2}
  2196000    0.569    0.000    0.569    0.000 quantumcircuit.py:1904(_rebind_definition)
   180000    0.562    0.000  124.679    0.001 numpy_discriminator.py:153(single_layer_backward_propagation)
  1464000    0.561    0.000    0.561    0.000 {method 'split' of 'str' objects}
   549000    0.552    0.000    1.813    0.000 level1.py:171(_opt_control)
   366000    0.548    0.000    1.128    0.000 n_local.py:458(parameters)
   255000    0.543    0.000   30.799    0.000 numpy_discriminator.py:285(get_label)
  1098000    0.543    0.000    0.543    0.000 {built-in method _heapq.heappop}
    30000    0.538    0.000    1.142    0.000 numpy_discriminator.py:299(loss)
   549000    0.535    0.000    0.653    0.000 runningpassmanager.py:87(_normalize_flow_controller)
   183000    0.534    0.000    3.313    0.000 result.py:265(get_statevector)
    60000    0.531    0.000    0.531    0.000 numpy_discriminator.py:141(sigmoid_backward)
  3477000    0.527    0.000    0.527    0.000 quantumcircuit.py:911(<genexpr>)
   549000    0.518    0.000    0.909    0.000 passmanager.py:162(_normalize_passes)
   183000    0.516    0.000    0.598    0.000 qasm_simulator.py:278(_set_options)
   180000    0.513    0.000    2.945    0.000 function_base.py:4616(append)
   183000    0.511    0.000    0.824    0.000 backend_utils.py:89(is_basicaer_provider)
   366000    0.506    0.000    0.551    0.000 qasm_qobj.py:251(__init__)
  3294000    0.505    0.000    0.505    0.000 core.py:71(<lambda>)
   732000    0.489    0.000    0.635    0.000 bit.py:78(__eq__)
   915000    0.483    0.000    0.483    0.000 qasm_qobj.py:41(__init__)
  1338000    0.479    0.000    0.479    0.000 basic.py:738(args)
  3477000    0.475    0.000    0.475    0.000 quantumcircuit.py:913(<genexpr>)
  1500000    0.463    0.000    0.463    0.000 fromnumeric.py:1915(shape)
   183000    0.463    0.000    0.663    0.000 dense_layout.py:39(__init__)
   183000    0.455    0.000    0.689    0.000 models.py:57(to_dict)
   225000    0.455    0.000    0.455    0.000 {method 'flatten' of 'numpy.ndarray' objects}
   183000    0.453    0.000    0.879    0.000 transpile.py:484(_parse_coupling_map)
    30000    0.453    0.000  140.594    0.005 numpy_discriminator.py:370(gradient_function)
   732000    0.449    0.000    0.449    0.000 {built-in method builtins.divmod}
   183000    0.447    0.000    0.640    0.000 assemble.py:37(_log_assembly_time)
  1281000    0.445    0.000    0.542    0.000 transpile.py:478(<genexpr>)
   183000    0.441    0.000    0.630    0.000 basicaerjob.py:56(__init__)
   978000    0.441    0.000    0.441    0.000 numbers.py:1285(__nonzero__)
  1098000    0.436    0.000    0.436    0.000 numbers.py:1215(_hashable_content)
  3534000    0.435    0.000    0.435    0.000 basic.py:2059(__iter__)
   732000    0.435    0.000    0.542    0.000 quantumcircuit.py:708(_bit_argument_conversion)
   732000    0.434    0.000    0.434    0.000 fromnumeric.py:3117(size)
   366000    0.433    0.000    0.585    0.000 instructionset.py:43(add)
  2013000    0.430    0.000    0.430    0.000 parametervector.py:52(__len__)
  2196000    0.429    0.000    0.429    0.000 {method 'lower' of 'str' objects}
   183000    0.429    0.000    1.318    0.000 transpile.py:471(_parse_basis_gates)
  1098000    0.429    0.000    0.567    0.000 parameter.py:53(subs)
  2970000    0.412    0.000    0.412    0.000 parameter.py:68(__deepcopy__)
  1098000    0.411    0.000    0.634    0.000 basic.py:2070(<lambda>)
   240000    0.410    0.000    1.066    0.000 symbol.py:257(_hashable_content)
   183000    0.410    0.000   13.891    0.000 run_circuits.py:136(_safe_submit_qobj)
   732000    0.406    0.000    0.524    0.000 quantumcircuit.py:692(__len__)
   183000    0.399    0.000    0.570    0.000 stochastic_swap.py:52(__init__)
  2196000    0.399    0.000    0.399    0.000 fromnumeric.py:2333(_all_dispatcher)
   183000    0.394    0.000    0.558    0.000 controlledgate.py:194(_open_ctrl)
  1098000    0.387    0.000    0.387    0.000 quantumcircuit.py:230(cls_prefix)
  2562000    0.384    0.000    0.384    0.000 {method 'values' of 'dict' objects}
   183000    0.378    0.000    2.581    0.000 result.py:112(data)
   240000    0.378    0.000    0.519    0.000 symbol.py:266(assumptions0)
  1830000    0.373    0.000    0.373    0.000 parametervector.py:35(params)
  1647000    0.358    0.000    0.358    0.000 quantumcircuit.py:880(<listcomp>)
   732000    0.357    0.000    0.357    0.000 {method 'replace' of 'str' objects}
   183000    0.357    0.000    5.100    0.000 genericpath.py:27(isfile)
  1830000    0.356    0.000    0.356    0.000 circuit_to_instruction.py:91(<listcomp>)
   366000    0.354    0.000    0.354    0.000 {built-in method _abc._abc_subclasscheck}
   183000    0.351    0.000    0.434    0.000 backend_utils.py:143(is_simulator_backend)
  1932000    0.346    0.000    0.346    0.000 fromnumeric.py:194(_reshape_dispatcher)
   549000    0.336    0.000    0.336    0.000 logic.py:93(fuzzy_bool)
   366000    0.333    0.000    1.718    0.000 quantum_instance.py:496(is_statevector)
   366000    0.332    0.000    0.332    0.000 {built-in method math.frexp}
   915000    0.327    0.000    0.327    0.000 {method 'count' of 'list' objects}
   183000    0.327    0.000    0.778    0.000 transpile.py:630(_parse_faulty_qubits_map)
   183000    0.326    0.000    1.632    0.000 os.py:772(getenv)
   915000    0.321    0.000    0.321    0.000 basebackend.py:57(configuration)
   183000    0.320    0.000    0.648    0.000 set_layout.py:28(__init__)
   300000    0.319    0.000    1.246    0.000 numeric.py:144(ones)
   366000    0.315    0.000    0.315    0.000 {built-in method builtins.round}
   549000    0.314    0.000    0.515    0.000 qasm_qobj.py:325(__init__)
   183000    0.313    0.000   77.633    0.000 basicaerjob.py:77(result)
   732000    0.312    0.000    0.312    0.000 {built-in method math.acos}
   183000    0.310    0.000    0.310    0.000 passmanager_config.py:22(__init__)
   183000    0.307    0.000    0.510    0.000 transpile.py:556(_parse_initial_layout)
   183000    0.306    0.000    0.415    0.000 transpile.py:511(_parse_backend_properties)
   183000    0.302    0.000    0.738    0.000 runningpassmanager.py:298(__init__)
   300000    0.302    0.000    1.293    0.000 <__array_function__ internals>:2(concatenate)
   183000    0.299    0.000    1.306    0.000 _collections_abc.py:657(get)
   732000    0.299    0.000    0.299    0.000 inspect.py:478(getmro)
   183000    0.297    0.000    0.297    0.000 threading.py:75(RLock)
   366001    0.292    0.000    0.292    0.000 basebackend.py:94(name)
   366000    0.290    0.000    0.385    0.000 circuit_to_instruction.py:77(<listcomp>)
   366000    0.285    0.000    0.285    0.000 instructionset.py:25(__init__)
   366000    0.283    0.000    0.401    0.000 result.py:339(<genexpr>)
   183000    0.283    0.000   77.915    0.000 basicaerjob.py:36(_wrapper)
  1515000    0.277    0.000    0.277    0.000 multiarray.py:706(dot)
   915000    0.277    0.000    0.277    0.000 parametertable.py:55(get_keys)
   183000    0.276    0.000    0.324    0.000 run_config.py:32(__init__)
   183000    0.276    0.000    0.323    0.000 transpile.py:440(_create_faulty_qubits_map)
   183000    0.274    0.000    0.469    0.000 full_ancilla_allocation.py:36(__init__)
  1464000    0.270    0.000    0.270    0.000 {method 'rstrip' of 'str' objects}
   366000    0.269    0.000    0.332    0.000 quantumcircuitdata.py:73(__len__)
   366000    0.269    0.000    0.269    0.000 register.py:137(__eq__)
   183000    0.266    0.000    0.266    0.000 qasm_qobj.py:387(__init__)
   183000    0.264    0.000    0.428    0.000 optimize_1q_gates.py:35(__init__)
  1098000    0.263    0.000    0.263    0.000 process.py:36(current_process)
   183000    0.262    0.000    0.478    0.000 layout_2q_distance.py:34(__init__)
   183000    0.262    0.000    0.431    0.000 basis_translator.py:55(__init__)
    30000    0.261    0.000 7302.419    0.243 optimizer.py:133(function_wrapper)
  1464000    0.261    0.000    0.261    0.000 dagcircuit.py:149(<listcomp>)
  1098000    0.260    0.000    0.260    0.000 quantumcircuit.py:224(cls_instances)
    30000    0.259    0.000    0.459    0.000 linalg.py:2363(norm)
   549000    0.258    0.000    0.258    0.000 runningpassmanager.py:290(__init__)
  1098000    0.257    0.000    0.257    0.000 {method 'issubset' of 'set' objects}
   183000    0.256    0.000    0.574    0.000 blueprintcircuit.py:89(data)
   183000    0.253    0.000    0.253    0.000 {method '_acquire_restore' of '_thread.RLock' objects}
   183000    0.250    0.000    0.286    0.000 thread.py:176(_adjust_thread_count)
   183000    0.249    0.000    0.249    0.000 passmanager.py:33(__init__)
  1500000    0.248    0.000    0.248    0.000 fromnumeric.py:1911(_shape_dispatcher)
   549000    0.248    0.000    0.364    0.000 uuid.py:254(__hash__)
   183000    0.247    0.000    0.905    0.000 assemble.py:364(_expand_parameters)
   390000    0.241    0.000    0.241    0.000 {method 'ravel' of 'numpy.ndarray' objects}
   183000    0.239    0.000    0.467    0.000 trivial_layout.py:34(__init__)
   183000    0.238    0.000    0.417    0.000 os.py:754(encode)
   180000    0.237    0.000    0.543    0.000 fromnumeric.py:1705(ravel)
     3000    0.234    0.000   42.804    0.014 qgan.py:247(get_rel_entr)
   915000    0.234    0.000    0.234    0.000 dagcircuit.py:159(global_phase)
   183000    0.226    0.000    0.375    0.000 fixed_point.py:30(__init__)
   366000    0.225    0.000    0.501    0.000 assemble.py:384(<genexpr>)
   732000    0.224    0.000    0.224    0.000 instruction.py:172(definition)
   183000    0.223    0.000    0.392    0.000 check_map.py:28(__init__)
   366000    0.222    0.000    0.222    0.000 instruction.py:364(<listcomp>)
   915000    0.219    0.000    0.219    0.000 gate.py:92(label)
   183000    0.219    0.000    0.317    0.000 fencedobjs.py:58(__init__)
   183000    0.218    0.000    0.256    0.000 run_circuits.py:64(_combine_result_objects)
   300000    0.218    0.000    0.735    0.000 <__array_function__ internals>:2(copyto)
   915000    0.214    0.000    0.214    0.000 quantumcircuit.py:663(qubits)
   183000    0.210    0.000    0.210    0.000 thread.py:46(__init__)
   366000    0.207    0.000    0.207    0.000 n_local.py:859(_build)
   549000    0.203    0.000    0.203    0.000 {method 'zfill' of 'str' objects}
   183000    0.201    0.000    2.166    0.000 remove_reset_in_zero_state.py:24(run)
   183000    0.200    0.000    0.379    0.000 check_cx_direction.py:28(__init__)
   183000    0.199    0.000    0.328    0.000 transpile.py:545(_parse_backend_num_qubits)
   183000    0.198    0.000    0.373    0.000 cx_direction.py:38(__init__)
   732000    0.195    0.000    0.195    0.000 parametertable.py:63(get_names)
   183000    0.194    0.000    0.194    0.000 qasm_qobj.py:176(__init__)
   732000    0.192    0.000    0.192    0.000 {method 'strip' of 'str' objects}
   732000    0.192    0.000    0.192    0.000 fromnumeric.py:3113(_size_dispatcher)
   300000    0.191    0.000    0.191    0.000 {built-in method numpy.empty}
   366000    0.190    0.000    0.618    0.000 transpile.py:177(<genexpr>)
   183000    0.189    0.000    0.189    0.000 basejob.py:33(__init__)
   183000    0.186    0.000    0.436    0.000 runningpassmanager.py:211(__init__)
   183000    0.186    0.000    0.186    0.000 backend_utils.py:57(has_aer)
    15000    0.183    0.000  146.738    0.010 numpy_discriminator.py:382(train)
   183000    0.175    0.000    0.175    0.000 assemble.py:359(<dictcomp>)
   732000    0.173    0.000    0.173    0.000 numeric.py:2117(_allclose_dispatcher)
   366000    0.170    0.000    0.193    0.000 assemble.py:145(<genexpr>)
    30000    0.170    0.000 7689.090    0.256 adam_amsgrad.py:215(optimize)
   183000    0.167    0.000    0.197    0.000 postprocess.py:176(format_statevector)
   915000    0.163    0.000    0.163    0.000 {method 'remove' of 'set' objects}
   183000    0.160    0.000    0.264    0.000 threading.py:240(__enter__)
   183000    0.158    0.000    0.158    0.000 {method 'encode' of 'str' objects}
   183000    0.156    0.000    0.242    0.000 transpile.py:641(_parse_output_name)
   366000    0.154    0.000    0.508    0.000 abc.py:141(__subclasscheck__)
   549000    0.152    0.000    0.152    0.000 numeric.py:1969(warn_if_insufficient)
   180000    0.148    0.000    0.813    0.000 <__array_function__ internals>:2(ravel)
   366000    0.145    0.000    0.145    0.000 run_config.py:72(to_dict)
    15000    0.141    0.000 7542.802    0.503 quantum_generator.py:335(train)
   732000    0.139    0.000    0.139    0.000 multiarray.py:634(result_type)
   183000    0.139    0.000    0.191    0.000 threading.py:243(__exit__)
   180000    0.136    0.000    3.279    0.000 <__array_function__ internals>:2(append)
   549000    0.136    0.000    0.136    0.000 {built-in method builtins.bin}
   183000    0.135    0.000    0.175    0.000 transpile.py:506(<listcomp>)
   183000    0.131    0.000    0.183    0.000 backend_utils.py:155(is_local_backend)
   366000    0.131    0.000    0.131    0.000 circuit_to_instruction.py:67(<dictcomp>)
   165000    0.129    0.000    0.129    0.000 {method 'transpose' of 'numpy.ndarray' objects}
   183000    0.128    0.000    0.128    0.000 assemble.py:216(<dictcomp>)
   732000    0.126    0.000    0.126    0.000 numeric.py:2193(_isclose_dispatcher)
   183000    0.125    0.000    0.125    0.000 {built-in method _thread.allocate_lock}
    18000    0.125    0.000    0.125    0.000 {method 'round' of 'numpy.ndarray' objects}
   183000    0.122    0.000    0.160    0.000 transpile.py:580(<listcomp>)
   366000    0.121    0.000    0.121    0.000 basebackend.py:74(provider)
   183000    0.120    0.000    0.120    0.000 {method '_release_save' of '_thread.RLock' objects}
   366000    0.116    0.000    0.116    0.000 transpile.py:236(<genexpr>)
    30000    0.109    0.000    0.232    0.000 optimizer.py:148(optimize)
   732000    0.108    0.000    0.108    0.000 {built-in method _operator.index}
    15000    0.107    0.000    4.366    0.000 numpy_discriminator.py:342(objective_function)
   120000    0.107    0.000    4.498    0.000 basic.py:983(_subs)
   240000    0.105    0.000    0.105    0.000 symbol.py:268(<dictcomp>)
   183000    0.103    0.000    0.103    0.000 {method '__enter__' of '_thread.RLock' objects}
   183000    0.101    0.000    0.101    0.000 _base.py:382(__get_result)
   183000    0.090    0.000    0.112    0.000 transpile.py:594(_parse_routing_method)
   183000    0.089    0.000    0.112    0.000 transpile.py:588(_parse_layout_method)
   183000    0.086    0.000    0.086    0.000 basejob.py:44(job_id)
   183000    0.086    0.000    0.086    0.000 transpile.py:667(<listcomp>)
   183000    0.085    0.000    0.085    0.000 controlledgate.py:134(num_ctrl_qubits)
   183000    0.084    0.000    0.105    0.000 transpile.py:600(_parse_translation_method)
   183000    0.083    0.000    0.106    0.000 transpile.py:624(_parse_callback)
   300000    0.080    0.000    0.080    0.000 multiarray.py:143(concatenate)
   183000    0.079    0.000    0.079    0.000 controlledgate.py:159(ctrl_state)
   366000    0.078    0.000    0.078    0.000 circuit_to_instruction.py:78(<listcomp>)
   183000    0.077    0.000    0.098    0.000 transpile.py:606(_parse_seed_transpiler)
   366000    0.075    0.000    0.075    0.000 basebackend.py:65(properties)
   183000    0.072    0.000    0.095    0.000 transpile.py:612(_parse_optimization_level)
   366000    0.072    0.000    0.072    0.000 propertyset.py:22(__missing__)
   366000    0.072    0.000    0.072    0.000 quantumcircuit.py:798(<listcomp>)
   183000    0.069    0.000    0.069    0.000 quantum_instance.py:431(run_config)
     9000    0.066    0.000    0.066    0.000 {method 'round' of 'numpy.generic' objects}
   366000    0.063    0.000    0.063    0.000 instruction.py:365(<listcomp>)
     3000    0.062    0.000    0.199    0.000 _distn_infrastructure.py:2612(entropy)
   183000    0.057    0.000    0.057    0.000 {method 'append' of 'collections.deque' objects}
   183000    0.052    0.000    0.052    0.000 {method '__exit__' of '_thread.RLock' objects}
    30000    0.051    0.000    0.556    0.000 <__array_function__ internals>:2(norm)
   366000    0.051    0.000    0.051    0.000 inspect.py:2521(default)
   300000    0.050    0.000    0.050    0.000 multiarray.py:1043(copyto)
    30000    0.049    0.000    0.049    0.000 optimizer.py:241(is_bounds_required)
   183000    0.045    0.000    0.045    0.000 {method 'reverse' of 'list' objects}
   183000    0.038    0.000    0.038    0.000 transpile.py:559(_layout_from_raw)
   183000    0.036    0.000    0.036    0.000 {method 'keys' of 'collections.OrderedDict' objects}
   183000    0.036    0.000    0.036    0.000 {method '_is_owned' of '_thread.RLock' objects}
   180000    0.033    0.000    0.033    0.000 function_base.py:4612(_append_dispatcher)
   180000    0.031    0.000    0.031    0.000 fromnumeric.py:1701(_ravel_dispatcher)
    15000    0.030    0.000    0.030    0.000 optimizer.py:221(is_gradient_required)
    27000    0.024    0.000    0.358    0.000 <__array_function__ internals>:2(around)
    30000    0.023    0.000    0.023    0.000 optimizer.py:251(is_initial_point_ignored)
    27000    0.023    0.000    0.300    0.000 fromnumeric.py:3168(around)
    30000    0.022    0.000    0.028    0.000 linalg.py:112(isComplexType)
    15000    0.018    0.000    0.018    0.000 optimizer.py:211(is_gradient_ignored)
     9000    0.016    0.000    0.087    0.000 fromnumeric.py:2105(sum)
    15000    0.015    0.000    0.015    0.000 numpy_discriminator.py:326(_get_objective_function)
     9000    0.013    0.000    0.112    0.000 <__array_function__ internals>:2(sum)
    15000    0.011    0.000    0.011    0.000 quantum_generator.py:306(_get_objective_function)
    15000    0.011    0.000    0.011    0.000 quantum_generator.py:183(set_discriminator)
    15000    0.010    0.000    0.010    0.000 numpy_discriminator.py:354(_get_gradient_function)
    15000    0.010    0.000    0.010    0.000 optimizer.py:122(wrap_function)
     3000    0.010    0.000    0.010    0.000 qgan.py:256(<listcomp>)
    30000    0.009    0.000    0.009    0.000 linalg.py:2359(_norm_dispatcher)
    27000    0.005    0.000    0.005    0.000 fromnumeric.py:3164(_around_dispatcher)
     3000    0.005    0.000    0.008    0.000 <__array_function__ internals>:2(empty_like)
     3000    0.004    0.000    0.016    0.000 <__array_function__ internals>:2(swapaxes)
     3000    0.004    0.000    0.008    0.000 <__array_function__ internals>:2(ndim)
     3000    0.004    0.000    0.004    0.000 {method 'swapaxes' of 'numpy.ndarray' objects}
     3000    0.003    0.000    0.003    0.000 aqua_globals.py:72(random)
     9000    0.003    0.000    0.003    0.000 fromnumeric.py:2100(_sum_dispatcher)
     3000    0.002    0.000    0.009    0.000 fromnumeric.py:550(swapaxes)
     3000    0.001    0.000    0.001    0.000 fromnumeric.py:3075(ndim)
     3000    0.001    0.000    0.001    0.000 fromnumeric.py:3071(_ndim_dispatcher)
     3000    0.001    0.000    0.001    0.000 fromnumeric.py:546(_swapaxes_dispatcher)
     3000    0.001    0.000    0.001    0.000 multiarray.py:75(empty_like)
        1    0.000    0.000 7945.119 7945.119 {built-in method builtins.exec}
        1    0.000    0.000 7945.119 7945.119 qgan.py:332(_run)
        1    0.000    0.000 7945.119 7945.119 quantum_algorithm.py:48(run)
        1    0.000    0.000 7945.119 7945.119 <string>:1(<module>)
        1    0.000    0.000    0.000    0.000 quantum_instance.py:491(backend_name)
        1    0.000    0.000    0.000    0.000 quantum_algorithm.py:81(quantum_instance)
        1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

@mtreinish
Copy link
Member

Taking a quick look at that profile it looks like the overhead from parameter binding. bind_parameters() on a circuit object copies the circuit which quickly becomes a big bottleneck. We really need to redesign the parameter binding case on the terra side since it's a big bottleneck for the case where there are a lot of parameters being bound. (my thinking is that it something we can add on to the interface of Backend.run() with Qiskit/qiskit#5086 )

In the shorter term @hhorii has been looking at aqua-side optimizations to leverage aer's parameterized qobj that can significantly reduce this overhead (in that case it was specifically for UCCSD in chemistry applications) see: qiskit-community/qiskit-aqua#1206 We probably can leverage a similar mechanism for this too.

@Zoufalc
Copy link
Contributor Author

Zoufalc commented Sep 28, 2020

First of all, you are absolutely right about the number of training epochs. The number is far too large.

Would it be sufficient to pretrain some epochs and then use them as a starting point instead of random initialization?

@Zoufalc
Copy link
Contributor Author

Zoufalc commented Sep 28, 2020

@mtreinish Thanks for looking into this!

@nonhermitian nonhermitian self-requested a review October 7, 2020 15:44
@nonhermitian nonhermitian merged commit 4c53637 into Qiskit:master Oct 7, 2020
manoelmarques pushed a commit to manoelmarques/qiskit-machine-learning that referenced this pull request Mar 11, 2021
* Update qgans_for_loading_random_distributions.ipynb

* move qGAN tutorial from legacy_tutorials to tutorials

* Update qgans_for_loading_random_distributions.ipynb

* Remove Torch import

* change Kernel

* Update qgans_for_loading_random_distributions.ipynb

Co-authored-by: Paul Nation <nonhermitian@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants