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

Library Logic Format Simplification #1365

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Conversation

b-shi
Copy link
Contributor

@b-shi b-shi commented Nov 19, 2024

This PR makes a few changes to the library logic format and related for simplification purposes:

  1. Fields in the library logic are now structured as key-value pairs (previously a list)
  2. Removed ProblemType field in each solution - the global one is used instead
  3. Add a DefaultSolution field in each logic file.
  4. For each solution, parameters that are set to default their values are omitted in the logic file.
    • During library load, we reference DefaultSolution in each logic file to fill in the missing parameter values
  5. Add a new field LibraryLogicVersion to track any logic file format changes in the future.
  6. Add a new merge script mergeV2.py for merging logic files in new format .

With the format changes the total disk usage of the logic files is reduced ~40%. Sample logic file using new format here.

Tensilite changes are in a separate commit for ease of review.

@jichangjichang
Copy link
Collaborator

why do we need to keep merge.py? Should we just update merge.py for new format?

@@ -320,11 +343,10 @@ def parseLibraryLogicList(data, srcFile="?"):
.format(srcFile, len(data)))

rv = {}

rv["LibraryLogicVersion"] = "0.0.0"
Copy link
Contributor

@bstefanuk bstefanuk Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We hard code the library logic version to 0.0.0? Should this instead be extracted from the library logic directly?

edit: I see, the original list-style logic files won't have a version; disregard, or perhaps a comment could be useful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, parseLibraryLogicList can be removed once all the logic files are in the new format. Currently its only being used to help convert the legacy format to new format.

Comment on lines 255 to +259
if isinstance(data, List):
# TODO: this can be removed when all logic files have dict format
data = parseLibraryLogicList(data, srcFile)
else:
libraryType = data["LibraryType"]
Copy link
Contributor

@bstefanuk bstefanuk Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if here on the else branch, we should convert it into an elif and check against the expected type (Dict) and the library logic version, then add an else block that raises if nothing matches?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good point, I will have it check the LibraryLogicVersion and type

@KKyang
Copy link
Contributor

KKyang commented Nov 21, 2024

I don't think we need a mergeV2.py, we should let merge.py to support the new format and make sure it also supports transferring legacy yamls to new format.

@b-shi
Copy link
Contributor Author

b-shi commented Nov 21, 2024

why do we need to keep merge.py? Should we just update merge.py for new format?

@babakpst, can we replace the old merge.py with the new version instead?

@b-shi
Copy link
Contributor Author

b-shi commented Nov 21, 2024

I don't think we need a mergeV2.py, we should let merge.py to support the new format and make sure it also supports transferring legacy yamls to new format.

Just to check, if we convert all the existing logic files to the newer format, would we still have a need to support the legacy format? One of the motivations for converting all the logic files to the new format in this PR is to avoid adding support for the legacy format (main issue is there a several places where the fields are hard coded).

@KKyang
Copy link
Contributor

KKyang commented Nov 21, 2024

The reason why we still need a converter is that customers are using our tuning guides and having their own logic yamls kept in their hands. This change without a converter will break the compatibility.

@b-shi
Copy link
Contributor Author

b-shi commented Nov 21, 2024

The reason why we still need a converter is that customers are using our tuning guides and having their own logic yamls kept in their hands. This change without a converter will break the compatibility.

Ah.. thats a good point, thoughts on adding a convert option in merge.py and then having most of the logic in merge.py only support the dictionary format?

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.

4 participants