-
Notifications
You must be signed in to change notification settings - Fork 524
Reorg the sparse/quant/common kernel dir #1303
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
7e00248
bab5022
e1fcf06
bc81615
a7125fd
004f966
6939da2
11cf16a
2a31b12
7f031d9
43916aa
8b0a02b
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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-FileCopyrightText: Copyright (c) 2023-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
|
|
@@ -13,38 +13,4 @@ | |
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Shared Triton kernels for modelopt (attention, quantization, etc.).""" | ||
|
|
||
| import torch | ||
|
|
||
| from modelopt.torch.utils import import_plugin | ||
|
|
||
| IS_AVAILABLE = False | ||
| attention = None | ||
| attention_calibrate = None | ||
| register_triton_attention = None | ||
|
|
||
| if torch.cuda.is_available(): | ||
| with import_plugin( | ||
| "triton", | ||
| msg_if_missing=( | ||
| "Your device is potentially capable of using the triton attention " | ||
| "kernel. Try to install triton with `pip install triton`." | ||
| ), | ||
| ): | ||
| from .triton_fa import attention as _attention | ||
| from .triton_fa import attention_calibrate as _attention_calibrate | ||
|
|
||
| attention = _attention | ||
| attention_calibrate = _attention_calibrate | ||
| IS_AVAILABLE = True | ||
| from .hf_triton_attention import register_triton_attention as _register_triton_attention | ||
|
|
||
| register_triton_attention = _register_triton_attention | ||
|
|
||
| __all__ = [ | ||
| "IS_AVAILABLE", | ||
| "attention", | ||
| "attention_calibrate", | ||
| "register_triton_attention", | ||
| ] | ||
| """ModelOpt kernel library: common, quantization (conv, gemm), sparsity (attention, gemm).""" | ||
|
kevalmorabia97 marked this conversation as resolved.
jingyu-ml marked this conversation as resolved.
Collaborator
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. Critical (unresolved from two prior reviews): The old public symbols ( Please add a
Contributor
Author
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. Mentioned it in the changelog
Collaborator
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. Critical (unresolved from three prior reviews): The CHANGELOG claims "these four names continue to work at the old location via a Please either:
The |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2023-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Common (non-domain-specific) kernels. Base FA lives in ``common/attention``.""" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Shared Triton kernels for modelopt (attention, quantization, etc.).""" | ||
|
|
||
| import torch | ||
|
|
||
| from modelopt.torch.utils import import_plugin | ||
|
|
||
| IS_AVAILABLE = False | ||
| attention = None | ||
| attention_calibrate = None | ||
| register_triton_attention = None | ||
|
|
||
| if torch.cuda.is_available(): | ||
| with import_plugin( | ||
| "triton", | ||
| msg_if_missing=( | ||
| "Your device is potentially capable of using the triton attention " | ||
| "kernel. Try to install triton with `pip install triton`." | ||
| ), | ||
| ): | ||
| from .triton_fa import attention as _attention | ||
|
|
||
| attention = _attention | ||
| IS_AVAILABLE = True | ||
| from .hf_triton_attention import register_triton_attention as _register_triton_attention | ||
|
|
||
| register_triton_attention = _register_triton_attention | ||
|
|
||
| # Calibration lives in the sparsity subpackage (skip-softmax specific). | ||
| # Imported here so ``from modelopt.torch.kernels.common.attention import | ||
| # attention_calibrate`` keeps working. | ||
| from modelopt.torch.kernels.sparsity.attention.calibrate import ( | ||
| attention_calibrate as _attention_calibrate, | ||
| ) | ||
|
|
||
| attention_calibrate = _attention_calibrate | ||
|
|
||
| __all__ = [ | ||
| "IS_AVAILABLE", | ||
| "attention", | ||
| "attention_calibrate", | ||
| "register_triton_attention", | ||
| ] |
Uh oh!
There was an error while loading. Please reload this page.