Skip to content

Memory error while running eig_qb.run_epr() #1018

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

Open
curious424 opened this issue Apr 20, 2025 · 0 comments
Open

Memory error while running eig_qb.run_epr() #1018

curious424 opened this issue Apr 20, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@curious424
Copy link

Information

  • Qiskit Metal version: 0.1.5
  • Python version: 3.11.10
  • Operating system: Windows 10
  • Notebook: 7.2.2

What is the current behavior?

When I set n_modes to 6, it results into error and tell me that it can not allocate memory.

Steps to reproduce the problem

The problem occurs when I set n_modes to 6. I put all of my codes at the end.

What is the expected behavior?

I expect the code to work because I have a lot of memory. The code also worked with no problem when I set n_modes is 4.

Suggested solutions

Well I tried working with parameters like max_passes or change the max allowed memory use of juypter notebook in the configuration, but it didn't work.

My full message:

Hi everyone, I hope you are doing well.

I am trying to simulates two qubits for resonator coupling and get different parameters as answer. I created an instance of the EPRanalysis class, and did some configurations like n_modes = 6, max_passes = 12, etc. You can find all of codes at the end of my post.

I ran the code with n_modes = 4, and there was no problem. The problem is that when I set n_modes to 6, I get the following error while running eig_qb.run_epr():

MemoryError                               Traceback (most recent call last)
MemoryError: Could not allocate memory.

I was monitoring the process of the code being executed. The run of eig_qb.sim.run(name="twoqubit", components=[], open_terminations=[]) took 16 min to be executed, and there was no error.

The code eig_qb.run_epr() took about 20 min to be executed and resulted in kernel to die. Jupyter note book told me:

The kernel for my_file.ipynb appears to have died. It will restart automatically.

MemoryError: Traceback (most recent call last)
MemoryError: Could not allocate memory

When eig_qb.run_epr() was running, for the first 5 min, it used something about 1 or 2 GB of my RAM, and then started using more RAM step by step. (100MB in each step.) It continued to increase using RAM until 31GB, then RAM usage suddenly increased to 71GB, stayed in 71GB for some seconds, and decreased to 8GB. It was using 8GB of RAM for 5 min and then jupyter notebook told me that my_file.ipynb appears to have died, and I got the mentioned error that says can not allocate memory. I put the full log at the end of my post.

The error says it can not allocate enough memory, I have 128GB of memory though. I want to know if 128GB of RAM is not enough for this task, or there is another problem or issue that I must solve to be able to run the code properly. If there is a problem in my code that can be solved or a configuration that can be applied to solve the issue, I would be thankful if you can help.

I’d really appreciate any help or advice you can offer—thanks so much in advance! Let me know if you need more details, and I’ll be happy to clarify.

Best regards.


Here are my codes. I put lines between each block of code in jupyter notebook. There were also come configurations about the layout that I didn't think they are important here, so I didn't include them. If they are needed, let me know please so I include them too.

# ----------------------------------------------------
# import
import numpy as np
from collections import OrderedDict

from qiskit_metal import designs, draw
from qiskit_metal import MetalGUI, Dict, Headings

design = designs.DesignPlanar()
gui = MetalGUI(design)

# if you disable the next line, then you will need to delete a component [<component>.delete()] before recreating it
design.overwrite_enabled = True

# ----------------------------------------------------
# import
from qiskit_metal.qlibrary.qubits.transmon_pocket_cl import TransmonPocketCL
from qiskit_metal.qlibrary.qubits.transmon_pocket_6 import TransmonPocket6
from qiskit_metal.qlibrary.qubits.transmon_pocket import TransmonPocket
from qiskit_metal.qlibrary.tlines.meandered import RouteMeander
from qiskit_metal.qlibrary.tlines.anchored_path import RouteAnchors
from qiskit_metal.qlibrary.tlines.pathfinder import RoutePathfinder
from qiskit_metal.qlibrary.terminations.launchpad_wb import LaunchpadWirebond
from qiskit_metal.qlibrary.terminations.launchpad_wb_coupled import LaunchpadWirebondCoupled
asym = 500
from qiskit_metal.qlibrary.tlines.mixed_path import RouteMixed
import numpy as np
from collections import OrderedDict
ops=dict(fillet='25um')

# ----------------------------------------------------
# configure design
design.variables['cpw_width'] = '10 um'
design.variables['cpw_gap'] = '6 um'
design._chips['main']['size']['size_x'] = '9mm'
design._chips['main']['size']['size_y'] = '6.5mm'

# ----------------------------------------------------
# Create qubit q_1 and q_2
options =  dict(
    pad_width = '425 um', 
    pocket_height = '470um',
    connection_pads=dict(
        bus1 = dict(loc_W=0, loc_H=-1, pad_width = '90um', pad_gap = '50um'),
        bus2 = dict(loc_W=0, loc_H=+1, pad_width = '90um', pad_gap = '50um'),      
    ))

q_1 = TransmonPocket6(design,'Q_1', options = dict(
    pos_x='+1250um', pos_y='500um', orientation = '270', 
        gds_cell_name ='FakeJunction_01',
    pocket_width = '600um',
        hfss_inductance ='14nH',
        **options))

q_2 = TransmonPocket6(design,'Q_2', options = dict(
    pos_x='-1250um', pos_y='-500um', orientation = '270', 
        gds_cell_name ='FakeJunction_01',
        hfss_inductance ='14nH',
    pocket_width = '600um',
        **options))

# ----------------------------------------------------
# Create coupling resonator
design.delete_component('line3')
anchors = OrderedDict()

anchors[0] = np.array([0.15,0.5])
anchors[1] = np.array([0.15,0.1])
anchors[2] = np.array([0.075,0.1])
anchors[3] = np.array([0.075,0.5])
anchors[4] = np.array([0.0,0.5])
anchors[5] = np.array([0.0,-0.5])
anchors[6] = np.array([-0.075,-0.5])
anchors[7] = np.array([-0.075,-0.1])
anchors[8] = np.array([-0.15,-0.1])
anchors[9] = np.array([-0.15,-0.5])

between_anchors = OrderedDict() # S, M, PF
between_anchors[0] = "PF"
between_anchors[1] = "S"
between_anchors[2] = "S"
between_anchors[3] = "S"
between_anchors[4] = "S"
between_anchors[5] = "S"
between_anchors[6] = "S"
between_anchors[7] = "S"
between_anchors[8] = "S"
between_anchors[9] = "S"
between_anchors[10] = "S"

jogsS = OrderedDict()

jogsE = OrderedDict()

optionsR = {'pin_inputs': {
              'start_pin': {'component': 'Q_1', 'pin': 'bus1'}, 
              'end_pin': {'component': 'Q_2', 'pin': 'bus2'}
            },
            'total_length': '6mm',
            'chip': 'main',
            'layer': '1',
            'trace_width': 'cpw_width',
            'step_size': '0.25mm',
            'anchors': anchors,
            'between_anchors': between_anchors,
            'advanced': {'avoid_collision': 'true'},
            'meander': {
              'spacing': '75um',
              'asymmetry': '0um'
            },
            'snap': 'true',
            'lead': {
            'start_straight': '0.1mm',
              'end_straight': '0.1mm',
              'start_jogged_extension': jogsS,
              'end_jogged_extension': jogsE
            },
            **ops
          }

qc = RouteMixed(design, 'line3', optionsR)


# ----------------------------------------------------
# Some configurations related to layout. 


# ----------------------------------------------------

from qiskit_metal.analyses.quantization import EPRanalysis
eig_qb = EPRanalysis(design, "hfss")
# ----------------------------------------------------

hfss = eig_qb.sim.renderer

# ----------------------------------------------------
em_p = eig_qb.sim.setup

# ----------------------------------------------------
em_p.name = 'QubitTune'
em_p.min_freq_ghz = 4
em_p.n_modes = 6
em_p.max_passes = 12
em_p.max_delta_f = 0.1
em_p.min_converged = 2
em_p.pct_refinement= 85
# Design variables can also be added in for direct simulation sweeps.
em_p.vars = Dict({'Lj1': '10 nH', 'Cj1': '2 fF',
                  'Lj2': '10 nH', 'Cj2': '2 fF' })

eig_qb.sim.setup

# ----------------------------------------------------
eig_qb.sim.run(name="twoqubit", components=[], open_terminations=[])

# ----------------------------------------------------
eig_qb.sim.plot_convergences()

# ----------------------------------------------------
eig_qb.sim.convergence_f

# ----------------------------------------------------
hfss.plot_fields('main')

# ----------------------------------------------------
eig_qb.del_junction()
eig_qb.add_junction('jj1', 'Lj1', 'Cj1', rect='JJ_rect_Lj_Q_1_rect_jj', line='JJ_Lj_Q_1_rect_jj_')
eig_qb.add_junction('jj2', 'Lj2', 'Cj2', rect='JJ_rect_Lj_Q_2_rect_jj', line='JJ_Lj_Q_2_rect_jj_')
eig_qb.setup.sweep_variable = 'Lj1'
eig_qb.setup

# ----------------------------------------------------
eig_qb.run_epr()

Here is the full log of eig_qb.run_epr():

Design "twoqubit_hfss" info:
	# eigenmodes    6
	# variations    1
Design "twoqubit_hfss" info:
	# eigenmodes    6
	# variations    1

        energy_elec_all       = 2.92463955415546e-24
        energy_elec_substrate = 2.69214176752933e-24
        EPR of substrate = 92.1%

        energy_mag    = 1.12320054285689e-26
        energy_mag % of energy_elec_all  = 0.4%
        

Variation 0  [1/1]

  Mode 0 at 5.34 GHz   [1/6]
    Calculating ℰ_magnetic,ℰ_electric
       (ℰ_E-ℰ_H)/ℰ_E       ℰ_E       ℰ_H
               99.6%  1.462e-24 5.616e-27

    Calculating junction energy participation ration (EPR)
	method=`line_voltage`. First estimates:
	junction        EPR p_0j   sign s_0j    (p_capacitive)
		Energy fraction (Lj over Lj&Cj)= 97.80%
	jj1              1.35225  (+)        0.0304474
		Energy fraction (Lj over Lj&Cj)= 97.80%
	jj2             0.0406401  (+)        0.000915056
		(U_tot_cap-U_tot_ind)/mean=-15.05%
WARNING: This simulation must not have converged well!!!                The difference in the total cap and ind energies is larger than 10%.                Proceed with caution.
Calculating Qdielectric_main for mode 0 (0/5)
p_dielectric_main_0 = 0.9205037809545499

  Mode 1 at 5.34 GHz   [2/6]
    Calculating ℰ_magnetic,ℰ_electric
       (ℰ_E-ℰ_H)/ℰ_E       ℰ_E       ℰ_H
               99.6%  2.621e-24 9.913e-27

    Calculating junction energy participation ration (EPR)
	method=`line_voltage`. First estimates:
	junction        EPR p_1j   sign s_1j    (p_capacitive)
		Energy fraction (Lj over Lj&Cj)= 97.79%
	jj1             0.0406839  (+)        0.000917494
		Energy fraction (Lj over Lj&Cj)= 97.79%
	jj2              1.35229  (+)        0.0304965
		(U_tot_cap-U_tot_ind)/mean=-15.05%
WARNING: This simulation must not have converged well!!!                The difference in the total cap and ind energies is larger than 10%.                Proceed with caution.
Calculating Qdielectric_main for mode 1 (1/5)
p_dielectric_main_1 = 0.9206192680000123

  Mode 2 at 7.73 GHz   [3/6]
    Calculating ℰ_magnetic,ℰ_electric
       (ℰ_E-ℰ_H)/ℰ_E       ℰ_E       ℰ_H
                0.0%  7.945e-24 7.945e-24

    Calculating junction energy participation ration (EPR)
	method=`line_voltage`. First estimates:
	junction        EPR p_2j   sign s_2j    (p_capacitive)
		Energy fraction (Lj over Lj&Cj)= 95.49%
	jj1             1.80304e-08  (+)        8.51594e-10
		Energy fraction (Lj over Lj&Cj)= 95.49%
	jj2             1.25457e-08  (+)        5.92549e-10
		(U_tot_cap-U_tot_ind)/mean=0.00%
Calculating Qdielectric_main for mode 2 (2/5)
p_dielectric_main_2 = 0.9209544888669964

  Mode 3 at 9.41 GHz   [4/6]
    Calculating ℰ_magnetic,ℰ_electric
       (ℰ_E-ℰ_H)/ℰ_E       ℰ_E       ℰ_H
                0.0%  4.262e-24 4.262e-24

    Calculating junction energy participation ration (EPR)
	method=`line_voltage`. First estimates:
	junction        EPR p_3j   sign s_3j    (p_capacitive)
		Energy fraction (Lj over Lj&Cj)= 93.47%
	jj1             1.13929e-07  (+)        7.96511e-09
		Energy fraction (Lj over Lj&Cj)= 93.47%
	jj2             1.19221e-07  (+)        8.33515e-09
		(U_tot_cap-U_tot_ind)/mean=-0.00%
Calculating Qdielectric_main for mode 3 (3/5)
p_dielectric_main_3 = 0.9216175356031272

  Mode 4 at 10.76 GHz   [5/6]
    Calculating ℰ_magnetic,ℰ_electric
       (ℰ_E-ℰ_H)/ℰ_E       ℰ_E       ℰ_H
                0.0%  1.462e-25 1.462e-25

    Calculating junction energy participation ration (EPR)
	method=`line_voltage`. First estimates:
	junction        EPR p_4j   sign s_4j    (p_capacitive)
		Energy fraction (Lj over Lj&Cj)= 91.62%
	jj1             2.0754e-07  (+)        1.89763e-08
		Energy fraction (Lj over Lj&Cj)= 91.62%
	jj2             0.00018631  (+)        1.70352e-05
		(U_tot_cap-U_tot_ind)/mean=-0.00%
Calculating Qdielectric_main for mode 4 (4/5)
p_dielectric_main_4 = 0.9204153968651636

  Mode 5 at 10.77 GHz   [6/6]
    Calculating ℰ_magnetic,ℰ_electric
       (ℰ_E-ℰ_H)/ℰ_E       ℰ_E       ℰ_H
                0.0%  1.603e-25 1.603e-25

    Calculating junction energy participation ration (EPR)
	method=`line_voltage`. First estimates:
	junction        EPR p_5j   sign s_5j    (p_capacitive)
		Energy fraction (Lj over Lj&Cj)= 91.62%
	jj1             0.000182746  (+)        1.67213e-05
		Energy fraction (Lj over Lj&Cj)= 91.62%
	jj2             1.2605e-07  (+)        1.15336e-08
		(U_tot_cap-U_tot_ind)/mean=-0.00%
Calculating Qdielectric_main for mode 5 (5/5)
p_dielectric_main_5 = 0.9205305979038966

WARNING 06:28PM [__init__]: <p>Error: <class 'IndexError'></p>
ERROR 06:28PM [_get_participation_normalized]: WARNING: U_tot_cap-U_tot_ind / mean = 30.1% is > 15%.                     
Is the simulation converged? Proceed with caution

ANALYSIS DONE. Data saved to:

C:\data-pyEPR\Project1\twoqubit_hfss\2025-04-20 18-26-56.npz


	 Differences in variations:



 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 
Variation 0

---------------------------------------------------------------------------
MemoryError                               Traceback (most recent call last)
MemoryError: Could not allocate memory.
@curious424 curious424 added the bug Something isn't working label Apr 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant