-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(deps): Copy KHD imports into
scattermoe_utils
(#127)
* fix: move necessary khd functions into scattermoe_utils Signed-off-by: Will Johnson <mwjohnson728@gmail.com> * remove requirements-khd, update README Signed-off-by: Will Johnson <mwjohnson728@gmail.com> * fix: remove ext dep from benchmarks Signed-off-by: Will Johnson <mwjohnson728@gmail.com> * fix: move files to khd folder Signed-off-by: Will Johnson <mwjohnson728@gmail.com> * fmt Signed-off-by: Will Johnson <mwjohnson728@gmail.com> * fix lint Signed-off-by: Will Johnson <mwjohnson728@gmail.com> * rm copyright Signed-off-by: Will Johnson <mwjohnson728@gmail.com> * reference cute kernels Signed-off-by: Will Johnson <mwjohnson728@gmail.com> * cute kernels reference Signed-off-by: Will Johnson <mwjohnson728@gmail.com> --------- Signed-off-by: Will Johnson <mwjohnson728@gmail.com>
- Loading branch information
Showing
11 changed files
with
1,207 additions
and
30 deletions.
There are no files selected for viewing
This file contains 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 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 was deleted.
Oops, something went wrong.
This file contains 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 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
17 changes: 17 additions & 0 deletions
17
plugins/accelerated-moe/src/fms_acceleration_moe/utils/scattermoe_utils/khd/__init__.py
This file contains 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright The FMS HF Tuning Authors | ||
# Copyright 2024 Databricks | ||
# | ||
# 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. | ||
|
||
# Local | ||
from .custom_op import torch_custom_op |
47 changes: 47 additions & 0 deletions
47
plugins/accelerated-moe/src/fms_acceleration_moe/utils/scattermoe_utils/khd/custom_op.py
This file contains 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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Standard | ||
from typing import Any, Callable, Iterable | ||
|
||
# Third Party | ||
import torch | ||
|
||
try: | ||
# Third Party | ||
from torch.library import custom_op | ||
|
||
_IS_CUSTOM_OP_IN_PYTORCH = True | ||
except: | ||
_IS_CUSTOM_OP_IN_PYTORCH = False | ||
|
||
|
||
class _IdentityOp: | ||
def __init__(self, fn: Callable) -> None: | ||
self.fn = fn | ||
|
||
def __call__(self, *args: Any, **kwargs: Any) -> Any: | ||
return self.fn(*args, **kwargs) | ||
|
||
def register_fake(self, fn: Callable) -> Callable: | ||
return fn | ||
|
||
|
||
def torch_custom_op( | ||
name: str, | ||
fn: Callable | None = None, | ||
/, | ||
*, | ||
mutates_args: str | Iterable[str], | ||
device_types: torch.device = None, | ||
schema: str | None = None, | ||
) -> Callable | _IdentityOp: | ||
if _IS_CUSTOM_OP_IN_PYTORCH: | ||
op = custom_op( | ||
name, | ||
fn, | ||
mutates_args=mutates_args, | ||
device_types=device_types, | ||
schema=schema, | ||
) | ||
else: | ||
op = _IdentityOp if fn is None else _IdentityOp(fn) | ||
|
||
return op |
22 changes: 22 additions & 0 deletions
22
...s/accelerated-moe/src/fms_acceleration_moe/utils/scattermoe_utils/khd/kernels/__init__.py
This file contains 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright The FMS HF Tuning Authors | ||
# Copyright 2024 Databricks | ||
# | ||
# 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. | ||
|
||
# Local | ||
from .kernels import ( | ||
group_triton_kernel, | ||
groupXtY_triton_kernel, | ||
scatter2scatter_lora_triton_kernel, | ||
scatter2scatter_triton_kernel, | ||
) |
Oops, something went wrong.