-
Notifications
You must be signed in to change notification settings - Fork 320
fix incorrect torch version test #2786
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
Changes from all commits
0ada4b5
de7a877
3818cbf
747026b
37b7089
05edf52
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -348,27 +348,33 @@ def _is_float8_type(dtype: torch.dtype) -> bool: | |
|
||
|
||
def parse_version(version_string): | ||
# Extract just the X.Y.Z part from the version string | ||
match = re.match(r"(\d+\.\d+\.\d+)", version_string) | ||
""" | ||
Parse version string representing pre-release with -1 | ||
Examples: "2.5.0.dev20240708+cu121" -> [2, 5, -1], "2.5.0" -> [2, 5, 0] | ||
""" | ||
# Check for pre-release indicators | ||
is_prerelease = bool(re.search(r"(git|dev)", version_string)) | ||
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. please also verify the version string for pytorch, if you build it from source 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.
Aren't the above comments mentioning 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. Yeah should be 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. yeah I was referring to torchao as well but then realized this is for torch |
||
match = re.match(r"(\d+)\.(\d+)\.(\d+)", version_string) | ||
if match: | ||
version = match.group(1) | ||
return [int(x) for x in version.split(".")] | ||
major, minor, patch = map(int, match.groups()) | ||
if is_prerelease: | ||
patch = -1 | ||
return [major, minor, patch] | ||
else: | ||
raise ValueError(f"Invalid version string format: {version_string}") | ||
|
||
|
||
def compare_versions(v1, v2): | ||
v1_parts = parse_version(v1) | ||
v2_parts = parse_version(v2) | ||
return (v1_parts > v2_parts) - (v1_parts < v2_parts) | ||
|
||
|
||
def is_fbcode(): | ||
return not hasattr(torch.version, "git_version") | ||
|
||
|
||
def torch_version_at_least(min_version): | ||
return is_fbcode() or compare_versions(torch.__version__, min_version) >= 0 | ||
if is_fbcode(): | ||
return True | ||
|
||
# Parser for local identifiers | ||
return parse_version(torch.__version__) >= parse_version(min_version) | ||
|
||
|
||
def _deprecated_torch_version_at_least(version_str: str) -> str: | ||
|
@@ -983,13 +989,13 @@ def is_sm_at_least_100(): | |
def check_cpu_version(device, version="2.6.0"): | ||
if isinstance(device, torch.device): | ||
device = device.type | ||
return device == "cpu" and compare_versions(torch.__version__, version) >= 0 | ||
return device == "cpu" and torch_version_at_least(version) | ||
|
||
|
||
def check_xpu_version(device, version="2.8.0"): | ||
if isinstance(device, torch.device): | ||
device = device.type | ||
return device == "xpu" and compare_versions(torch.__version__, version) >= 0 | ||
return device == "xpu" and torch_version_at_least(version) | ||
|
||
|
||
def ceil_div(a, b): | ||
|
Uh oh!
There was an error while loading. Please reload this page.