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

Qiskit Metal v0.5: PySide6, Removing GDSPY to GDSTK, PYAEDT v1.0, and many more changes #1002

Open
wants to merge 53 commits into
base: main
Choose a base branch
from

Conversation

shanto268
Copy link

@shanto268 shanto268 commented Nov 18, 2024

What are the issues this pull addresses (issue numbers / links)?

Porting Qiskit Metal from PySide2 to PySide6 so that it can work natively on M* Macs (Apple Silicon).

Issues addressed:

Did you add tests to cover your changes (yes/no)?

No. N/A

Did you update the documentation accordingly (yes/no)?

Yes

Did you read the CONTRIBUTING document (yes/no)?

Yes

Summary

Fixed changes from PR #908 to pass automated CI workflows and tests, ensuring compatibility with updated dependencies, environment configurations, and the latest (11/17/2024) main branch.

Details and comments

  1. Built on top of changes made by @obrienpja in PR #908.

  2. Changes to QWidget_PlaceholderText and QTableView_AllComponents:

    • Refactored the QWidget_PlaceholderText class to ensure proper initialization and compatibility with PySide6.
    • Resolved issues with placeholder text styling by updating palette usage to align with PySide6 standards.
    • Updated QTableView_AllComponents to correctly inherit and integrate with QWidget_PlaceholderText, ensuring both functionality and visual styling work seamlessly.
    • Fixed initialization errors and ensured that the placeholder label behaves as intended when no components are available.
  3. Requirements and environment updates:

    • Updated the environment.yml file to use stable, OS-agnostic dependencies for Python 3.10.
    • Added missing dependencies, such as pyaedt, to ensure a consistent build across different operating systems.
    • Ensured that all dependencies align with the workflows and requirements in the lab's testing environment.
  4. Testing and validation:

    • Verified that the changes integrate seamlessly with the existing workflows and CI processes used in our lab.
    • Tested the updated branch against the current main branch workflows to confirm identical behavior.
    • All CI tests now pass successfully across all supported platforms (Windows, macOS, Ubuntu) and Python versions (3.9 and 3.10).

@CLAassistant
Copy link

CLAassistant commented Nov 18, 2024

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 3 committers have signed the CLA.

✅ obrienpja
✅ priti-ashvin-shah-ibm
❌ shanto268
You have signed the CLA already but the status is still pending? Let us recheck it.

@zlatko-minev
Copy link
Collaborator

Thank you, @shanto268! The tests are running. This is a giant PR, so it would be good to have more eyes on it than just you and me. Has anyone else from your lab tried this? I think after merging this, we could bump the Qiskit Metal version from 0.1.5 to 0.2. I just want to make sure it runs.

@PositroniumJS
Copy link
Contributor

@zlatko-minev on a fresh python 3.10.11 venv I still face problems:
On the first import of qiskit-metal inside a jupyter notebook, I get an interference with matplotlib, but on the second import the error is solved:

AttributeError                            Traceback (most recent call last)
Cell In[2], line 1
----> 1 import qiskit_metal as metal
      2 from qiskit_metal import designs, draw
      3 from qiskit_metal import MetalGUI, Dict, open_docs

File c:\Users\account\Python_venv\qiskit-metal-10-test\lib\site-packages\qiskit_metal\__init__.py:116
    112         import matplotlib.pyplot as plt
    113         plt.ion()  # interactive
--> 116 __setup_Qt_backend()
    117 del __setup_Qt_backend
    119 ## Setup logging

File c:\Users\account\Python_venv\qiskit-metal-10-test\lib\site-packages\qiskit_metal\__init__.py:113, in __setup_Qt_backend()
    111 # pylint: disable=redefined-outer-name
    112 import matplotlib.pyplot as plt
--> 113 plt.ion()

File c:\Users\account\Python_venv\qiskit-metal-10-test\lib\site-packages\matplotlib\pyplot.py:554, in ion()
    552 stack.callback(ion if isinteractive() else ioff)
    553 matplotlib.interactive(True)
--> 554 install_repl_displayhook()
    555 return stack

File c:\Users\account\Python_venv\qiskit-metal-10-test\lib\site-packages\matplotlib\pyplot.py:157, in install_repl_displayhook()
    155 ipython_gui_name = backend2gui.get(get_backend())
    156 if ipython_gui_name:
--> 157     ip.enable_gui(ipython_gui_name)

File c:\Users\account\Python_venv\qiskit-metal-10-test\lib\site-packages\ipykernel\zmqshell.py:491, in ZMQInteractiveShell.enable_gui(self, gui)
    488 from .eventloops import enable_gui as real_enable_gui
    490 try:
--> 491     real_enable_gui(gui)
    492     self.active_eventloop = gui
    493 except ValueError as e:

File c:\Users\account\Python_venv\qiskit-metal-10-test\lib\site-packages\ipykernel\eventloops.py:597, in enable_gui(gui, kernel)
    594 else:
    595     if gui.startswith("qt"):
    596         # Prepare the kernel here so any exceptions are displayed in the client.
--> 597         make_qt_app_for_kernel(gui, kernel)
    599 loop = loop_map[gui]
    600 if (
    601     loop and kernel.eventloop is not None and kernel.eventloop is not loop  # type:ignore[unreachable]
    602 ):

File c:\Users\account\Python_venv\qiskit-metal-10-test\lib\site-packages\ipykernel\eventloops.py:568, in make_qt_app_for_kernel(gui, kernel)
    565 from IPython.external.qt_for_kernel import QtCore
    566 from IPython.lib.guisupport import get_app_qt4
--> 568 kernel.app = get_app_qt4([" "])
    569 kernel.app.qt_event_loop = QtCore.QEventLoop(kernel.app)

File c:\Users\account\Python_venv\qiskit-metal-10-test\lib\site-packages\IPython\lib\guisupport.py:115, in get_app_qt4(*args, **kwargs)
    113 """Create a new qt4 app or return an existing one."""
    114 from IPython.external.qt_for_kernel import QtGui
--> 115 app = QtGui.QApplication.instance()
    116 if app is None:
    117     if not args:

AttributeError: module 'PySide6.QtPrintSupport' has no attribute 'QApplication'

Then when I try to launch the GUI, in the console I get this:

03:07PM 31s CRITICAL [_qt_message_handler]: line: 0, func: None(), file: None  WARNING: endResetModel called on QSortFilterProxyModel(0x2dc08222640) without calling beginResetModel first

I have two windows that open but they are "not responding" and totally blank

@vegaonline
Copy link

@shanto268, even after installation of Pyside6, I am getting
self.logger.warning( 541 "WARNING: No capacitance bodies added to the model other " 542 "than those connected to ground. ElmerFEM cannot run a " 543 "capacitance extraction analysis without any bodies. ")
and ultimately final error points to
self.logger.warning( 541 "WARNING: No capacitance bodies added to the model other " 542 "than those connected to ground. ElmerFEM cannot run a " 543 "capacitance extraction analysis without any bodies. ").

@zlatko-minev zlatko-minev changed the title PySide6 Compatibility Qiskit Metal v0.5: PySide6, Removing GDSPY to GDSTK, PYAEDT v1.0, and many more changes Jan 26, 2025
1. Added traceback reporting in the logging.
2.  Fixed - "metal: WARNING: endResetModel called on LibraryFileProxyModel(0x17fda8200) without calling beginResetModel first (No context available from Qt)"
3. Fixed MPL Rendere axes issue "Ignoring fixed y limits to fulfill fixed data aspect with adjustable data limits. Ignoring fixed x limits to fulfill fixed data aspect with adjustable data limits."
4. Added red border style to new component UI create button to underscore
@zlatko-minev
Copy link
Collaborator

zlatko-minev commented Jan 26, 2025

QISKIT METAL v0.5 (2025) Partial Updates in Progress

Major Updates

This release addresses significant package changes and ports:

  • PyQt5 to PySide6: A complete overhaul of the GUI.
  • GDSPY to GDSTK: Replaced GDSPY with the more robust GDSTK library.
  • PYAEDT to Ansys (v1.0): Major update with a new syntax. Extensive testing required.
  • Installation Improvements: Transitioned to venv for faster environment setup, moving away from conda as the default. Also, most package versions have been floated and upgraded.

GUI Enhancements

  1. Traceback Reporting: Added detailed traceback reporting in the logging system to aid debugging.
  2. Model Reset Issue: Fixed the issue causing the warning: "metal: WARNING: endResetModel called on LibraryFileProxyModel(0x17fda8200) without calling beginResetModel first (No context available from Qt)".
  3. MPL Renderer Issue: Working toresovle the error: "Ignoring fixed y limits to fulfill fixed data aspect with adjustable data limits. Ignoring fixed x limits to fulfill fixed data aspect with adjustable data limits.".
  4. UI Button Update: Added a red border style to the "Create Component" button in the UI for better visibility.

PYAEDT Update

  • FutureWarning: The pyaedt module has been restructured and is now an alias for the new package structure based on ansys.aedt.core. To avoid issues in future versions, please update your imports to use the new architecture. Additionally, several files have been renamed to follow the PEP 8 naming conventions. For more information, refer to the Ansys AEDT documentation.

The current files have many of these changes, inclduign the GDSTK Update, please do check. I have not yet pushed the HFSS part as this is still work in progress and hard

@PositroniumJS
Copy link
Contributor

Thank you for these updates, I tried with python 3.12.7 and I faced several issues:

requirements

To install, I needed to change a couple of requirements:

numpy>=1.24.2,<2
scipy>=1.10.0

numpy because geopandas is incompatible with numpy 2, scipy because this version is not compatible with my python version.

The error message I got for numpy
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

GUI

It looks to work fine except that it is composed of a small window and a big one, the small used to close itself after launch but now it remains opened; I have a custom QComponent which is flipped (bottom-top) when I create it directly from the GUI but not from the jupyter nb and its options are printed in the jupyter cell; a message is showing frequently in the jupyter cell output:

Ignoring fixed y limits to fulfill fixed data aspect with adjustable data limits.
Ignoring fixed x limits to fulfill fixed data aspect with adjustable data limits.

GDS renderer

To render a GDS, I faced several issues in gds_renderer.py:

  • TypeError: 'max_points' is an invalid keyword argument for FlexPath()
    I removed this argument everywhere in the file.
    An example of detailed error message
-> 2469         new_flexpath = gdstk.FlexPath(
   2470             path_points,
   2471             use_width,
   2472             layer=layer_num,
   2473             datatype=11,
   2474             max_points=max_points,
   2475         )
   2476         return new_flexpath
   2478 self.logger.warning(f"Unsupported geometry type={type(geom)} in"
   2479                     " _qgeometry_to_gds. Expected Polygon/LineString.")

TypeError: 'max_points' is an invalid keyword argument for FlexPath()
  • Library.new_cell() takes no keyword arguments
    I removed the argument overwrite_duplicate=True for this function everywhere in the file
-> 1556     all_chips_top = lib.new_cell(all_chips_top_name,
   1557                                  overwrite_duplicate=True)
   1558     for chip_name, _ in self.chip_info.items():
   1559         chip_only_top_name = f"TOP_{chip_name}"

TypeError: Library.new_cell() takes no keyword arguments
   1740 subtract_cell.add(
   1741     self.chip_info[chip_name][chip_layer]["q_subtract_true"])
   1743 # gdspy.boolean() is not documented clearly.  If there are multiple
   1744 # elements to subtract (both poly & path), the way I could
   1745 # make it work is to put them into a cell, within lib. I used
   1746 # the method cell_name.get_polygons(), which appears to convert
   1747 # all elements within the cell to poly. After the boolean(),
   1748 # I deleted the cell from lib. The memory is freed up then.
   1749 diff_geometry = gdstk.boolean(
   1750     [self.chip_info[chip_name]["subtract_poly"]],
   1751     subtract_cell.polygons,
   (...)
   1756     max_points=max_points,
   1757 )

TypeError: Arguments must be Polygon, FlexPath, RobustPath, Label or Reference.
  • max_points again
1749 diff_geometry = gdstk.boolean(
   1750     [self.chip_info[chip_name]["subtract_poly"]],
   1751     subtract_cell.polygons,
   1752     "not",
   1753     layer=chip_layer,
   1754     datatype=10,
   1755     precision=precision,
   1756     max_points=max_points,
   1757 )
   1759 lib.remove(subtract_cell)
   1761 if diff_geometry is None:

TypeError: boolean() takes at most 6 arguments (7 given)
  • get_bounding_box --> bounding_box
 1582 if chip_only_top.get_bounding_box() is not None:
   1583     all_chips_top.add(gdstk.Reference(chip_only_top))
   1584 else:

AttributeError: 'gdstk.Cell' object has no attribute 'get_bounding_box'
  • the export is not looking good
    I noticed several errors in the export when opening the gds file, at very least there are errors on fillet and cpw

image

@SamWolski
Copy link

If I had to guess, I suspect the unexpected output in the gds file would be due to some fundamental differences between gdspy and gdstk under the hood.

The primary motivation for gdstk was to modify the underlying structure and processes of the module, indicating that even if the functions execute with the changes as suggested by @PositroniumJS, there are some "new ways of doing things" with gdstk that the GDS exporter does not yet account for.

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

Successfully merging this pull request may close these issues.

8 participants