icxcn commited on
Commit
bd1fbc3
·
verified ·
1 Parent(s): 9a0b07b

Delete load_model.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. load_model.py +0 -42
load_model.py DELETED
@@ -1,42 +0,0 @@
1
- """Load Hydra BitNet model."""
2
- import torch
3
- from safetensors.torch import load_file
4
-
5
- def load_hydra(model_path: str, device: str = "cpu"):
6
- """Load Hydra model from HuggingFace format."""
7
- import sys
8
- from pathlib import Path
9
-
10
- # Add aisim to path if needed
11
- aisim_path = Path(__file__).parent.parent / "aisim"
12
- if aisim_path.exists():
13
- sys.path.insert(0, str(aisim_path))
14
-
15
- from bitnet_moe import M2MSentinel
16
- import json
17
-
18
- # Load config
19
- with open(f"{model_path}/config.json") as f:
20
- config = json.load(f)
21
-
22
- # Create model
23
- model = M2MSentinel(
24
- vocab_size=config["vocab_size"],
25
- dim=config["hidden_size"],
26
- depth=config["num_hidden_layers"],
27
- experts=config["num_experts"],
28
- )
29
-
30
- # Load weights
31
- weights = load_file(f"{model_path}/model.safetensors")
32
- model.load_state_dict(weights)
33
- model = model.to(device)
34
- model.eval()
35
-
36
- return model, config
37
-
38
- if __name__ == "__main__":
39
- import sys
40
- model_path = sys.argv[1] if len(sys.argv) > 1 else "."
41
- model, config = load_hydra(model_path)
42
- print(f"Loaded model: {config}")