qiskit-community / qiskit-metal

Quantum Hardware Design. Open-source project for engineers and scientists to design superconducting quantum devices with ease.
https://qiskit-community.github.io/qiskit-metal/
Apache License 2.0
270 stars 201 forks source link

Saving and loading QDesign is throwing errors #910

Closed jagandecapri closed 1 year ago

jagandecapri commented 1 year ago

Information

What is the current behavior?

Currently, when saving a QDesign using the save_design method, throws an error saying ERROR WHILE SAVING: 'NoneType' object is not callable.

When the save_design error is fixed using suggested solution (implementing getstate alone), then, another error appear when load_design. The error is RecursionError: maximum recursion depth exceeded.

Steps to reproduce the problem

Saving design

  1. Create a design
  2. Save the design using save_design method
design = metal.designs.DesignPlanar()
gui = metal.MetalGUI(design)
design.overwrite_enabled = True

q_0 = TransmonPocket(design,'Q_0', options = dict(
        pos_x='-1.25mm', 
        pos_y='0.5mm', 
        gds_cell_name ='FakeJunction_01',
        hfss_inductance ='14nH',
        pad_width = '425 um', 
        pocket_height = '650um',
        connection_pads=dict(
            readout = dict(loc_W=-1, loc_H=1, pad_width = '80um', pad_gap = '50um'),
            bus_01 = dict(loc_W=1, loc_H=1, pad_width = '60um', pad_gap = '10um'),
            bus_02 = dict(loc_W=-1, loc_H=-1, pad_width = '60um', pad_gap = '10um')        
    )))

design.save_design(path)
gui.rebuild()
gui.autoscale()

After fixing saving design

  1. Load a design using load_design method
design = design.load_design(path)
gui = metal.MetalGUI(design)
gui.rebuild()
gui.autoscale()

What is the expected behavior?

Saving and loading design is successful

Suggested solutions

Adding __getstate__ and __setstate__ method to the Components class seems to fix the issues.

    def __getstate__(self): return self.__dict__
    def __setstate__(self, d): self.__dict__.update(d)
jagandecapri commented 1 year ago

Closed as per discussion in https://github.com/Qiskit/qiskit-metal/pull/911.