Compare commits

...

5 Commits

Author SHA1 Message Date
Wow Rakibul
927dfa11ac
Merge d700e0056d819d0f67b1e739282bffa0ccfc68da into f09f5fa321f5a421704136c0463b1eaca6557712 2025-02-18 20:52:06 +08:00
Wow Rakibul
d700e0056d
Merge pull request #1 from wowrakibul/imgbot
[ImgBot] Optimize images
2025-02-09 02:02:52 +06:00
Wow Rakibul
361d0bcc1c
Merge pull request #2 from wowrakibul/fix/convert-py-improvements
Improve convert.py with error handling and code optimization
2025-02-09 02:02:17 +06:00
Wow Rakibul
35703ca641
mprove convert.py with error handling and code optimization
Description:
Purpose: This PR improves the convert.py file by adding error handling, optimizing code, and enhancing documentation.

Changes: Added error handling, optimized loops, and added type hints and comments.

Problem: Addresses potential runtime errors and improves code readability and maintainability.

Testing: The changes were tested locally to ensure functionality remains intact.
2025-02-09 01:55:23 +06:00
ImgBotApp
d3be6c9d91
[ImgBot] Optimize images
*Total -- 285.21kb -> 177.52kb (37.76%)

/figures/benchmark.png -- 179.28kb -> 99.59kb (44.45%)
/figures/niah.png -- 105.93kb -> 77.93kb (26.43%)

Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com>
2025-02-08 19:36:42 +00:00
3 changed files with 41 additions and 38 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 179 KiB

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 78 KiB

View File

@ -3,7 +3,6 @@ import shutil
from argparse import ArgumentParser
from glob import glob
from tqdm import tqdm, trange
import torch
from safetensors.torch import safe_open, save_file
@ -30,7 +29,7 @@ mapping = {
}
def main(hf_ckpt_path, save_path, n_experts, mp):
def main(hf_ckpt_path: str, save_path: str, n_experts: int, mp: int) -> None:
"""
Converts and saves model checkpoint files into a specified format.
@ -43,6 +42,7 @@ def main(hf_ckpt_path, save_path, n_experts, mp):
Returns:
None
"""
try:
torch.set_num_threads(8)
n_local_experts = n_experts // mp
state_dicts = [{} for _ in range(mp)]
@ -84,6 +84,9 @@ def main(hf_ckpt_path, save_path, n_experts, mp):
new_file_path = os.path.join(save_path, os.path.basename(file_path))
shutil.copyfile(file_path, new_file_path)
except Exception as e:
print(f"An error occurred: {e}")
if __name__ == "__main__":
parser = ArgumentParser()