-
Notifications
You must be signed in to change notification settings - Fork 8
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
document pcells implicit dependency on gdsfactory #28
Comments
Looks like the dependency was introduced in 5805c8f |
yes, i agree that we should keep the gdsfactory PDK separate from the pure klayout PDK, so we avoid implicit dependencies if you want to keep it this way we can create a klayout package for gdsfactory and gf180 pdk and mark it as a dependency |
We had the pure klayout implementation before. Due to the more powerful tools provided with gdsfactory, I decided to remove the pure klayout implementation. gdsfactory has very strong tools allowing easier manipulation of pcell code and parameterization. BTW, https://github.com/gdsfactory/skywater130/ might be old implementation for the pcells and also this repo is for skywaters which different than gf180mcu pcell implementation. As for the requirement of GDS factory, Please check the |
@FaragElsayed2 Could you please add the documentation that the user need to install the |
But that would get installed in the Python environment embedded in klayout per default, and gdsfactory also brings native dependencies like gdstk that mirror some of the functionality already present in klayout.
That's a PDK specifically for gdsfactory, so it's meant to be used outside of klayout when working directly on a design with gdsfactory.
That seems desirable to keep this for the klayout integration, and to have a separate gdsfactory PDK for usage within the gdsfactory ecosystem. |
@proppy https://github.com/gdsfactory/skywater130/ was written to work with Klayout mainly using |
@proppy My thought process is that whatever is working at the backend. It doesn't matter for the end user as long as the pcells are generating the correct output. |
I don't think that's the case, according to https://gdsfactory.github.io/skywater130/notebooks/intro.html this is mainly design for interactive/scripted usage within a regular python environment outside of klayout. |
This does have some implication on packaging, and making sure the dependencies are accessible from the klayout environment. Additionally, this most likely would end up installing the |
@proppy We are the ones who developed those pcells. @joamatab took what we have and taken our backend implementation to demonstrate how gdsfactory works for analog pcells as well. Our intent was to allow both use cases, scripted through gdsfactory and interactive using klayout with the same backend implementation. @joamatab Could you please comment on this? |
yes it may have some issues. but careful usage and documentation should help. For the interactive user, it would be seamless according to our testing. |
Are you referring to this PR? gdsfactory/skywater130#40
Wouldn't it make sense to use klayout 'pya` as the lowest common denominator? is gdsfactory able to import a klayout pcells and expose them as a component? The alternative could be to make the backend of gdsfactory plugable, so that it can work both when embedded in the klayout app (importing
This does have some implication on packaging, and making sure the dependencies are accessible from the klayout environment: Klayout has it's own way to discover python dependencies which differ from platform to platform, see the paragraph on https://www.klayout.de/doc-qt5/programming/python.html#:~:text=The%20Python%20macro,Python%20%3E%3D%203.x). about
Currently the PDK is distributed as a standalone archive thru volare which doesn't include an automated way to gdsfactory also comes with a lot of dependencies that you don't actually need for drawing pcells (netlist editing, routing, 3d rendering, simulator interface, etc), so unless the primitive are exposed as separate package (https://github.com/gdsfactory/kfactory?) you would require the users to install transitively a lot of unecessary packages. On possibility avenue could be to bundle the drawing primitive from gdsfactory as a standalone pure python module that we vendor and distribute with the klayout pcells as part of the pdk build process. Maybe https://www.klayout.de/doc/about/packages.html#:~:text=the%20subversion%20equivalent.-,Installation%20Hooks,-Scripts%20can%20register could be useful here, if we were packaging the klayout integration as a klayout package, we could rely on hooks to fetch/install dependencies. @klayoutmatthias @joamatab @mithro any thoughts here? |
@joamatab - Any thoughts? |
At the moment, the gdsfactory klayout package only contains the gdsfactory klayout integration (live updates, shortcuts ...) We can register gdsfactory as a klayout package and mark it as a dependency for the gf180mcu-pdk |
@proppy and @mithro original PCells for skywaters 130nm written using GDS Factory: https://github.com/efabless/sky130_klayout_pdk/tree/main/sky130_tech/tech/sky130/pymacros/cells |
it actually works well on linux, but probably not yet on MacOs and Windows you can install gdsfactory as part of the pdk initialization |
Amro, the run drc does not work from the macro @atorkmabrains |
@joamatab is gdsfactory using |
gdsfactory uses the way mabrains did gf180 is different from the skywater 130nm pure python package (which does not use klayout API at all) in the sky130 the klayout integration provides layercolors, DRC ... but not PCells on the GUI |
@joamatab the thing I dislike about the current gf180mcu pcell integration, is that it will leverage gdsfactory to save a temporary gds file to disk and then re-read it thru klayout API to integrate it in the current layout, see: If we want to use an higher level API like gdsfactory, I'd prefer us to do so on top of existing klayout |
Another question for @joamatab, would it make sense to provide an alternative Happy to contribute here too if you think it makes sense. |
There is a test ongoing for that. For that case I wrote the Although these cells have a risk of being off grid unless proper care is taken (no safeguards in there yet). |
Yes, so then a small remark. For a layout with 1-50 mio polygons, KLayout PCells are definitely the wrong choice, no matter whether you want to use Also, when doing such a boolean, it is important to utilize the proper tools, e.g. klayout can do booleans hierarchical by using the deep shape storage. Also for XOR there are tools that can use the tiling mode in order to split the work on more workers and do it directly internally instead of having to go to ruby/python. And finally, when using the PCells of the UI, if you have concerns about the stability, I think that might be much more related to the PCell interface rather than the actual core KLayout parts. In my previous project, I found that the PCells sometimes execute code twice (or at least used to), so that can can give you a gigantic performance hit if not properly taken care of. |
Thanks @sebastian-goeldi . Appreciate this summary. |
@sebastian-goeldi and @proppy Caravel chip "Without user design" has around 1 million to 2 million polygons for diffusion and poly alone. BTW, @sebastian-goeldi I'm not undermining Klayout at all. For me it's an amazing tool. An it's the open source tool of choice for editing and viewing layouts. But when it comes to DRC/LVS and other heavy batch processing jobs like layer manipulation, basic pcell generation, ease of automation for layout, I think |
And what is average number of polygons for the gf180 primitives instantiated by the PCells we've been discussing here? |
@proppy It's very low (20 to 100 polygons). That's not the problem. Again, the main driving factor here is the advanced relative layout functionality that comes with |
No worries. I know that the klayout API seems not super user friendly when coming from a python world. I just got it a lot that "klayout is so complicated". And I understand where the people are coming from, but I disagree. It has a steeper learning curve, but once there, I personally like it so much more (and the people that I know that invested the time to learn it a bit as well). I don't want to create a new cell every time just for a boolean (especially in photonics) for example, which is the case in gdstk/gdspy. And I think overall, kfactory aims to do the same thing as gdsfactory when it comes to usability and features. So, you wouldn't need to load everything in the layout, you can just hook into the layout, or at works copy on a C++ level from one layout to another (whichever is preferable). |
On side note, @sebastian-goeldi we are working with @klayoutmatthias to optimize the performance of klayout DRC/LVS engine. We have done and advanced profiling for the klayout C++ core code and issues that we will open source soon to understand the the bottlenecks in klayout. Thanks to @klayoutmatthias, he helped a lot optimizing our DRC code for large layouts. Just FYI, I have digged in klayout C++ deeply, I understand how it works in and out specially for DRC/LVS side. |
@atorkmabrains It's good news you understand the C++ code! Matthias P.S. do you plan to attend FSiC2023 in Paris? |
There is no specific measure to make sure polygons are well-behaving. The only compromise KLayout makes is to create a copy of the polygons that go into the target layout. If you're talking about Python-generated layout, it's for sure unrealistic to have 1-50meg polygons generated by Python. C++ PCells are possible which may be able to generate such big things, but in general PCells are not the right place to put elaborate algorithms into. That is the domain of generators which produce ready-to-integrate and verified hard macros such as the OpenRAM generator. For fun this creates a C++ PCell (Basic library) with something like 1..2M polygons:
It executes in a few seconds in my case (only a very small portion shown): |
A little bit rusty, but it's there. The last time I coded serious C++ was about 12 years back, LOL. Unfortunately, I was hoping to attend the conference. But I can't may be next year. |
Nice, but I think for pcells the main reason, we moved to |
And finally without intending to fuel this discussion more than necessary: performance is always relative. Give me a benchmark and I'll be happy to accept the challenge. KLayout's booleans are not always on the level of boost.polygon for example, but I know how to optimize them (which I can't claim on boost.polygon) and they are all-angle robust which for me is a very important feature. I am myself using KLayout on a daily basis on very large layouts - we're not using GDS anymore, but OASIS. I am talking about full mask layouts with literally billions of polygons. Working with such layouts - for example density calculations, booleans or DRC is not snappy, but with enough CPU power quite manageable. However, you need to be careful to choose the right ways like tiling mode for flat data or deep mode for hierarchical data. You also need to have some understanding of the basic functionality to be able to optimize which BTW is also the case for the $$$ commercial alternatives. In contrast to the vendor tools, I did not spend much time in optimizing yet, but - again - drop me a benchmark and let me help. In most cases, there a low hanging fruits that improve performance by orders of magnitude sometimes. And commenting on the PCells for devices: the true value of such an implementation does not lie in performance or actual code, but to provide a reference design for devices with appropriate parameters, their physical outline and - most importantly - the correlation with the models. To me it does not matter at all what tool the device primitives are implemented in. But it is very important that the implementation can act as a blueprint (i.e. is readable, comprehensible and executable) for other implementations, supplying the model to hardware correlation. In the end it's not realistic that every user of the devices uses the same single implementation - to attract a broad user community, you need to serve many kind of platforms. The goal should be to have a description of the polygons I need to draw in order to generate a device with predictable properties. If that is executable code, the better - whatever system you deploy that to, as long it is open source. Matthias |
As always @klayoutmatthias, perfectly said. Can't agree more. You're always helpful. Your insights on the performance were always helpful to my team. |
@proppy Here is my recommendation:
If you agreed with that direction, please confirm. If not, please let me know what is the direction that you want us to follow? |
That's aligned with my thinking as well, to me the implementation of the PCell should have a strong affinity with the audience of the environment it is deployed on. If running inside Klayout it makes sense to target Klayout It also makes sense to have another gdsfactory implementation of the PCells, targeted to the gdsfactory community that want to draw layout programmatically outside of klayout using gdsfactory constructs. We can always have test suites that verify the conformity of drawn devices with the PDK primitive specifications. |
I'd love to get @mithro input there, but I don't think this path is desirable. While I think it's important to have a gdsfactory version of the PCells, using them for klayout creates significant environment and cognitive burden on the target audience: the klayout community:
Another observation: |
@proppy As discussed here, we will go back to the Thanks @proppy and @klayoutmatthias Appreciate all the help. |
@proppy Well ... "love to" may not be the right wording in that context, but I am ready to take the callenge :) Please go ahead and file a ticket! |
Sorry about speaking on your behalf (I should have used
What about moving it to a separate repo under the
Thanks for considering it. I thought about another issue that might arise with the current approach: |
@joamatab Could you please create a repo to move the |
@proppy BTW, Skywaters klayout support in the Is that something you want changed as well? |
is that different from https://github.com/gdsfactory/skywater130/, can we consolidate there and revert back to klayout based cells (for the same reason pointed out in #28 (comment) and #28 (comment)) /cc @mithro |
https://github.com/gdsfactory/skywater130/ is an older version of the same pcells. I have filed an issue on that repo to update to the latest implementation: BTW, we never had |
|
Those are corrupted and should be removed. Thanks for pointing this out. @proppy |
Or in other words, not ready for production. @proppy |
See https://github.com/gdsfactory/gf180 still needs some work, PRs are welcome, see |
@proppy @klayoutmatthias Klayout issue has been opened: KLayout/klayout#1336 |
@proppy and @joamatab Also, I have created an issue on gdsfactory which I think might help here as well: gdsfactory/gdsfactory#1536 |
When starting klayout, the following error is raised when gdsfactory is not installed causing the pcells not to load:
This effectively means that the PDK is now dependend on gdsfactory, we should make sure that this is explicitly documented (as most people won't have it installed by default when using klayout and/or volare).
My feelings is that we'd prefer the base klayout integration not to depend on gdsfactory, and have a separate gdsfactory based PDK similar to what @joamatab did with https://github.com/gdsfactory/skywater130/.
curious what @mithro and @joamatab thinks?
The text was updated successfully, but these errors were encountered: