-
Notifications
You must be signed in to change notification settings - Fork 5.6k
misc: cache is_hopper_arch #6799
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 1 commit
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 |
|---|---|---|
|
|
@@ -41,8 +41,14 @@ def _to_tensor_scalar_tuple(x): | |
| return (None, x) | ||
|
|
||
|
|
||
| _IS_HOPPER_ARCH = None | ||
|
|
||
|
|
||
| def is_hopper_arch() -> bool: | ||
| # Hopper arch's compute capability == 9.0 | ||
| device = torch.cuda.current_device() | ||
| major, minor = torch.cuda.get_device_capability(device) | ||
| return major == 9 | ||
| global _IS_HOPPER_ARCH | ||
| if _IS_HOPPER_ARCH is None: | ||
| # Hopper arch's compute capability == 9.0 | ||
| device = torch.cuda.current_device() | ||
| major, _ = torch.cuda.get_device_capability(device) | ||
| _IS_HOPPER_ARCH = major == 9 | ||
| return _IS_HOPPER_ARCH | ||
|
Contributor
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. The current implementation for caching Using
To implement this, you would need to add What are your thoughts on refactoring to use @functools.lru_cache(maxsize=1)
def is_hopper_arch() -> bool:
# Hopper arch's compute capability == 9.0
device = torch.cuda.current_device()
major, _ = torch.cuda.get_device_capability(device)
return major == 9 |
||
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.
I think it would be better to cache it after this line
sglang/sgl-kernel/python/sgl_kernel/elementwise.py
Line 4 in 1da8d23
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.
But implementing in the function also has its advantages, except for element wise ops, everything else can be used.
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.
yeah maybe keep it here because other functions may call it in the future?