-
Notifications
You must be signed in to change notification settings - Fork 60
feat: better reporting of the variant being requested. #422
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
sayakpaul
wants to merge
1
commit into
main
Choose a base branch
from
better-variant-reporting
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+102
−9
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -198,11 +198,8 @@ def resolve_variant( | |
| return resolved[0] if resolved else None | ||
|
|
||
|
|
||
| def resolve_variants( | ||
| variants: list[Variant], backend: str | None = None | ||
| ) -> list[Variant]: | ||
| """Return the matching variants for the current system, sorted | ||
| by decreasing order of preference.""" | ||
| def _get_system_info(backend: str | None = None): | ||
| """Gather system information used for variant resolution.""" | ||
| selected_backend = _select_backend(backend) | ||
|
|
||
| cpu = platform.machine() | ||
|
|
@@ -232,6 +229,59 @@ def resolve_variants( | |
| tvm_ffi_version = parse(tvm_ffi.__version__) | ||
| tvm_ffi_version = Version(f"{tvm_ffi_version.major}.{tvm_ffi_version.minor}") | ||
|
|
||
| return selected_backend, cpu, os, torch_version, torch_cxx11_abi, tvm_ffi_version | ||
|
|
||
|
|
||
| def describe_system_variant(backend: str | None = None) -> str: | ||
| """Return a human-readable description of the variant the current system requires.""" | ||
| selected_backend, cpu, os, torch_version, torch_cxx11_abi, tvm_ffi_version = ( | ||
| _get_system_info(backend) | ||
| ) | ||
| return _describe_system_variant( | ||
| selected_backend=selected_backend, | ||
| cpu=cpu, | ||
| os=os, | ||
| torch_version=torch_version, | ||
| torch_cxx11_abi=torch_cxx11_abi, | ||
| tvm_ffi_version=tvm_ffi_version, | ||
| ) | ||
|
|
||
|
|
||
| def _describe_system_variant( | ||
| selected_backend: Backend, | ||
| cpu: str, | ||
| os: str, | ||
| torch_version: Version | None, | ||
| torch_cxx11_abi: bool | None, | ||
| tvm_ffi_version: Version | None, | ||
| ) -> str: | ||
| """Return a human-readable description of the requested variant given explicit system parameters.""" | ||
| parts = [] | ||
|
|
||
| if torch_version is not None: | ||
| parts.append(f"torch{torch_version.major}{torch_version.minor}") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should go back to manual variant creation, it is flaky and breaks things. (E.g. here it breaks the deprecation of the |
||
|
|
||
| if tvm_ffi_version is not None: | ||
| parts.append(f"tvm-ffi{tvm_ffi_version.major}{tvm_ffi_version.minor}") | ||
|
|
||
| if torch_cxx11_abi is not None: | ||
| parts.append("cxx11" if torch_cxx11_abi else "cxx98") | ||
|
|
||
| parts.append(selected_backend.variant_str) | ||
| parts.append(f"{cpu}-{os}") | ||
|
|
||
| return "-".join(parts) | ||
|
|
||
|
|
||
| def resolve_variants( | ||
| variants: list[Variant], backend: str | None = None | ||
| ) -> list[Variant]: | ||
| """Return the matching variants for the current system, sorted | ||
| by decreasing order of preference.""" | ||
| selected_backend, cpu, os, torch_version, torch_cxx11_abi, tvm_ffi_version = ( | ||
| _get_system_info(backend) | ||
| ) | ||
|
|
||
| return _resolve_variant_for_system( | ||
| variants=variants, | ||
| selected_backend=selected_backend, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Result of
make style