Skip to content

Commit

Permalink
add licensing notices
Browse files Browse the repository at this point in the history
Signed-off-by: Yu Chin Fabian Lim <[email protected]>
  • Loading branch information
fabianlim committed May 28, 2024
1 parent c2f7c05 commit f2b34b5
Show file tree
Hide file tree
Showing 17 changed files with 193 additions and 0 deletions.
47 changes: 47 additions & 0 deletions plugins/framework/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,50 @@ Each [package](#packages) in this monorepo:

- When instantiating `fms_acceleration.AccelerationFramework`, it internally parses through the configuration stanzas. For plugins that are installed, it will instantiate them; for those that are not, it will simply *passthrough*.
- `AccelerationFramework` will manage plugins transparently for user. User only needs to call `AccelerationFramework.model_loader` and `AccelerationFramework.augmentation`.

## Adding New Plugins

To add new plugins:

1. Create an appropriately `pip`-packaged plugin in `plugins`; the package needs to be named like `fms-acceleration-<postfix>` .
2. For `framework` to properly load and manage plugin, add the package `<postfix>` to [constants.py](./src/fms_acceleration/constants.py):

```python
PLUGINS = [
"peft",
"unsloth",
"<postfix>",
]
```
3. Create a sample template YAML file inside the `<PLUGIN_DIR>/configs` to demonstrate how to configure the plugin. As an example, reference the [sample config for accelerated peft](../accelerated-peft/configs/autogptq.yaml).
4. Update [generate_sample_configurations.py](../../scripts/generate_sample_configurations.py) and run `tox -e gen-configs` on the top level directory to generate the sample configurations.

```python
KEY_AUTO_GPTQ = "auto_gptq"
KEY_BNB_NF4 = "bnb-nf4"
PLUGIN_A = "<NEW PLUGIN NAME>"

CONFIGURATIONS = {
KEY_AUTO_GPTQ: "plugins/accelerated-peft/configs/autogptq.yaml",
KEY_BNB_NF4: (
"plugins/accelerated-peft/configs/bnb.yaml",
[("peft.quantization.bitsandbytes.quant_type", "nf4")],
),
PLUGIN_A: (
"plugins/<plugin>/configs/plugin_config.yaml",
[
(<1st field in plugin_config.yaml>, <value>),
(<2nd field in plugin_config.yaml>, <value>),
]
)
}

# Passing a tuple of configuration keys will combine the templates together
COMBINATIONS = [
("accelerated-peft-autogptq", (KEY_AUTO_GPTQ,)),
("accelerated-peft-bnb-nf4", (KEY_BNB_NF4,)),
(<"combined name with your plugin">), (KEY_AUTO_GPTQ, PLUGIN_A)
(<"combined name with your plugin">), (KEY_BNB_NF4, PLUGIN_A)
]
```
5. Update [scenarios YAML](../../scripts/benchmarks/scenarios.yaml) to configure benchmark test scenarios that will be triggered when running `tox -e run-benches` on the top level directory.
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
# Copyright The FMS HF Tuning Authors
#
# 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.

from .framework_plugin_fast_quantized_peft import FastQuantizedPeftAccelerationPlugin
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright The FMS HF Tuning Authors
#
# 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.

from transformers import TrainingArguments
from peft import LoraConfig
from typing import Tuple, Dict, Callable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2023-present Daniel Han-Chen & the Unsloth team. All rights reserved.
#
# 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.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# taken from
# https://github.com/jeromeku/unsloth/commit/
# 2839d390ef3bb318904289bfb9a7751a782c4e44
Empty file.
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# taken from
# https://github.com/jeromeku/unsloth/commit/
# 2839d390ef3bb318904289bfb9a7751a782c4e44

import math
from dataclasses import dataclass
from logging import getLogger
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# taken from
# https://github.com/jeromeku/unsloth/commit/
# 2839d390ef3bb318904289bfb9a7751a782c4e44
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# taken from
# https://github.com/jeromeku/unsloth/commit/
# 2839d390ef3bb318904289bfb9a7751a782c4e44

import itertools
from logging import getLogger

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# taken from
# https://github.com/jeromeku/unsloth/commit/
# 2839d390ef3bb318904289bfb9a7751a782c4e44

import logging

import torch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# taken from
# https://github.com/jeromeku/unsloth/commit/
# 2839d390ef3bb318904289bfb9a7751a782c4e44

import builtins
import heapq
import math
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2023-present Daniel Han-Chen & the Unsloth team. All rights reserved.
#
# 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.
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright The FMS HF Tuning Authors
#
# 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.

from .model_patcher import ModelPatcher

PATCHES = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright The FMS HF Tuning Authors
#
# 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.

from transformers.models.llama.modeling_llama import LlamaAttention
from transformers.models.llama.modeling_llama import LlamaRMSNorm

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright The FMS HF Tuning Authors
#
# 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.

from transformers.models.mistral.modeling_mistral import MistralAttention
from transformers.models.mistral.modeling_mistral import MistralRMSNorm

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright The FMS HF Tuning Authors
#
# 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.

from dataclasses import dataclass, asdict
from typing import Type, Callable, Union, List, Dict, Tuple, Set, Optional, Any
import torch
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright The FMS HF Tuning Authors
#
# 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.

import torch
from typing import Callable, List, Type

Expand Down

0 comments on commit f2b34b5

Please sign in to comment.