Slimshard
Browse filesAllow execution from inside repo folder
- slimshard.py +5 -0
- slimshard_gui.py +13 -6
slimshard.py
CHANGED
|
@@ -39,11 +39,16 @@ import os
|
|
| 39 |
import re
|
| 40 |
import shutil
|
| 41 |
import struct
|
|
|
|
| 42 |
import tempfile
|
| 43 |
from pathlib import Path
|
| 44 |
|
| 45 |
import numpy as np
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
try:
|
| 48 |
import torch
|
| 49 |
import torch.nn.functional as F
|
|
|
|
| 39 |
import re
|
| 40 |
import shutil
|
| 41 |
import struct
|
| 42 |
+
import sys
|
| 43 |
import tempfile
|
| 44 |
from pathlib import Path
|
| 45 |
|
| 46 |
import numpy as np
|
| 47 |
|
| 48 |
+
if __package__ in (None, ""):
|
| 49 |
+
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
| 50 |
+
__package__ = "hpc_quantize_v2"
|
| 51 |
+
|
| 52 |
try:
|
| 53 |
import torch
|
| 54 |
import torch.nn.functional as F
|
slimshard_gui.py
CHANGED
|
@@ -30,6 +30,7 @@ from __future__ import annotations
|
|
| 30 |
import datetime as dt
|
| 31 |
import queue
|
| 32 |
import shlex
|
|
|
|
| 33 |
import threading
|
| 34 |
import time
|
| 35 |
import tkinter as tk
|
|
@@ -38,6 +39,10 @@ from tkinter import filedialog, messagebox, ttk
|
|
| 38 |
|
| 39 |
import numpy as np
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
from .cuda_backend import cuda_device_name, cuda_is_available
|
| 42 |
from .slimshard import (
|
| 43 |
HPCConfig,
|
|
@@ -569,14 +574,16 @@ class SlimShardGUI:
|
|
| 569 |
)
|
| 570 |
|
| 571 |
def _auto_populate_defaults(self) -> None:
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
|
| 577 |
-
|
|
|
|
| 578 |
if shards:
|
| 579 |
self._set_shard_and_companions(shards[0])
|
|
|
|
| 580 |
|
| 581 |
def _set_shard_and_companions(self, shard_path: Path) -> None:
|
| 582 |
self.shard_var.set(str(shard_path))
|
|
|
|
| 30 |
import datetime as dt
|
| 31 |
import queue
|
| 32 |
import shlex
|
| 33 |
+
import sys
|
| 34 |
import threading
|
| 35 |
import time
|
| 36 |
import tkinter as tk
|
|
|
|
| 39 |
|
| 40 |
import numpy as np
|
| 41 |
|
| 42 |
+
if __package__ in (None, ""):
|
| 43 |
+
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
| 44 |
+
__package__ = "hpc_quantize_v2"
|
| 45 |
+
|
| 46 |
from .cuda_backend import cuda_device_name, cuda_is_available
|
| 47 |
from .slimshard import (
|
| 48 |
HPCConfig,
|
|
|
|
| 574 |
)
|
| 575 |
|
| 576 |
def _auto_populate_defaults(self) -> None:
|
| 577 |
+
repo_root = Path(__file__).resolve().parent.parent
|
| 578 |
+
for base in (Path.cwd(), repo_root):
|
| 579 |
+
raon_shard = base / "Raon-1-mini-preview" / "model-00001-of-00007.safetensors"
|
| 580 |
+
if raon_shard.exists():
|
| 581 |
+
self._set_shard_and_companions(raon_shard)
|
| 582 |
+
return
|
| 583 |
+
shards = sorted(base.glob("*/*.safetensors"))
|
| 584 |
if shards:
|
| 585 |
self._set_shard_and_companions(shards[0])
|
| 586 |
+
return
|
| 587 |
|
| 588 |
def _set_shard_and_companions(self, shard_path: Path) -> None:
|
| 589 |
self.shard_var.set(str(shard_path))
|