Skip to content

Commit

Permalink
Merge branch 'dev-fuse-qkv' of github.com:DrownFish19/PaddleNLP into …
Browse files Browse the repository at this point in the history
…dev-fuse-qkv
  • Loading branch information
DrownFish19 committed Apr 12, 2024
2 parents f0d19f6 + a1aa078 commit 110983d
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 5 deletions.
12 changes: 12 additions & 0 deletions paddlenlp/peft/lora/lora_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import json
import math
import os
from dataclasses import asdict, dataclass, field
from typing import List, Optional, Union
Expand Down Expand Up @@ -94,6 +95,15 @@ def __post_init__(self):
)
self.use_quick_lora = False

@property
def scaling(self):
if not self.rslora and not self.pissa:
return self.lora_alpha / self.r
elif self.pissa:
return 1.0
else:
return self.lora_alpha / math.sqrt(self.r)

@property
def __dict__(self):
return asdict(self)
Expand All @@ -114,6 +124,7 @@ def save_pretrained(self, save_directory):
os.makedirs(save_directory, exist_ok=True)

output_dict = self.__dict__
output_dict["scaling"] = self.scaling
output_path = os.path.join(save_directory, LORA_CONFIG_NAME)

# save it
Expand All @@ -136,6 +147,7 @@ def from_pretrained(cls, pretrained_model_name_or_path, **kwargs):
raise ValueError(f"Can't find lora_config.json at '{pretrained_model_name_or_path}'")

loaded_attributes = cls.from_json_file(config_file)
loaded_attributes.pop("scaling", None)

config = cls(**kwargs)

Expand Down
4 changes: 2 additions & 2 deletions paddlenlp/trainer/plugins/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ def __init__(self, name):
def start(self):
"""Start the timer."""
assert not self.started_, f"{self.name} timer has already started"
if "gpu" in paddle.device.get_device():
if "cpu" not in paddle.device.get_device():
paddle.device.synchronize()
self.start_time = time.time()
self.started_ = True

def stop(self):
"""Stop the timers."""
assert self.started_, f"{self.name} timer is not started."
if "gpu" in paddle.device.get_device():
if "cpu" not in paddle.device.get_device():
paddle.device.synchronize()
self.elapsed_ += time.time() - self.start_time
self.started_ = False
Expand Down
1 change: 1 addition & 0 deletions scripts/distribute/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ install_paddlenlp(){
python -m pip uninstall paddlenlp -y
rm -rf build/ && rm -rf paddlenlp.egg-info/ && rm -rf dist/
python -m pip install --ignore-installed -r requirements.txt
python -m pip install --ignore-installed -r requirements-dev.txt
python setup.py install
python setup.py build_ext
python setup.py bdist_wheel
Expand Down
1 change: 1 addition & 0 deletions scripts/regression/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ nlp_build (){
rm -rf dist/

python -m pip install -r requirements.txt
python -m pip install -r requirements-dev.txt
python setup.py bdist_wheel
# python -m pip install --ignore-installed dist/p****.whl
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

python -m pip install -r ../requirements.txt
pip install regex
python -m pip install -r ../requirements-dev.txt

cd ../llm/
rm -rf data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

python -m pip install -r ../requirements.txt
python -m pip install -r ../requirements-dev.txt

# install fused_ln custom ops
cd ../model_zoo/gpt-3/external_ops/
Expand Down
2 changes: 1 addition & 1 deletion tests/test_tipc/dygraph/ft/benchmark_common/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

python -m pip install -r ../requirements.txt
pip install regex
python -m pip install -r ../requirements-dev.txt

cd ../llm

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# limitations under the License.

python -m pip install -r ../requirements.txt
python -m pip install regex
python -m pip install -r ../requirements-dev.txt
# get data
cd ../llm/gpt-3
rm -rf data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

python -m pip install -r ../requirements.txt
python -m pip install -r ../requirements-dev.txt

# install fused_ln custom ops
cd ../model_zoo/gpt-3/external_ops/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

python -m pip install -r ../requirements.txt
python -m pip install -r ../requirements-dev.txt

# install fused_ln custom ops
cd ../model_zoo/gpt-3/external_ops/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

python -m pip install -r ../requirements.txt
python -m pip install -r ../requirements-dev.txt

python -m pip install tiktoken

Expand Down
1 change: 1 addition & 0 deletions tests/test_tipc/llm/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

cd ..
sed -i -e "s/paddlepaddle/#paddlepaddle/g" requirements-dev.txt
sed -i -e "s/pip install paddlepaddle/#pip install paddlepaddle/g" Makefile

make install

Expand Down

0 comments on commit 110983d

Please sign in to comment.