Views
No views yet
tensor.Shape for weights ([1, 8192]), raising following errors when loading with transformers:ValueError: Trying to set a tensor of shape torch.Size([1, 8192]) in "weight" (which has shape torch. Size ( [8192])), this looks incorrect.[8192] with following script:1import os
2from safetensors.torch import load_file, save_file
3
4# Update this to point to your safetensors directory
5MODEL_DIR = "/root/.cache/huggingface/hub/models--Tarek07--Progenitor-V5-Final-LLaMa-70B/snapshots/8ca900fd3a65a725902d525e518be1bf374c0247"
6DEST_DIR = "/output/Progenitor-V5-Final-LLaMa-70B"
7
8def fix_shard(shard_path, output_path):
9 # Load the shard
10 data = load_file(shard_path)
11 # data is a dict: key -> torch.Tensor
12
13 # Go through every tensor and fix the shape if necessary
14 for key, tensor in data.items():
15 # Check if the shape is (1, 8192) instead of (8192)
16 if list(tensor.shape) == [1, 8192]:
17 print(f" Fixing {key} in {os.path.basename(shard_path)} from {tensor.shape} to (8192,)")
18 # Either squeeze(0) or view(-1) or view(8192):
19 # data[key] = tensor.squeeze(0)
20 # or
21 data[key] = tensor.view(8192)
22
23 # Save the fixed shard to output_path
24 save_file(data, output_path, metadata={"format": "pt"})
25 print(f" -> Saved fixed shard to: {output_path}")
26
27def main():
28 # Look for .safetensors files in MODEL_DIR
29 for filename in sorted(os.listdir(MODEL_DIR)):
30 if filename.endswith(".safetensors"):
31 shard_path = os.path.join(MODEL_DIR, filename)
32 output_path = os.path.join(DEST_DIR, f"{filename}")
33
34 print(f"Processing: {shard_path}")
35 fix_shard(shard_path, output_path)
36
37if __name__ == "__main__":
38 main()1models:
2 - model: Sao10K/L3.1-70B-Hanami-x1
3 parameters:
4 weight: 0.20
5 density: 0.7
6 - model: Sao10K/70B-L3.3-Cirrus-x1
7 parameters:
8 weight: 0.20
9 density: 0.7
10 - model: SicariusSicariiStuff/Negative_LLAMA_70B
11 parameters:
12 weight: 0.20
13 density: 0.7
14 - model: TheDrummer/Anubis-70B-v1
15 parameters:
16 weight: 0.20
17 density: 0.7
18 - model: EVA-UNIT-01/EVA-LLaMA-3.33-70B-v0.1
19 parameters:
20 weight: 0.20
21 density: 0.7
22merge_method: della_linear
23base_model: meta-llama/Llama-3.3-70B-Instruct
24parameters:
25 epsilon: 0.2
26 lambda: 1.1
27 int8_mask: true
28dtype: float32
29out_dtype: bfloat16
30tokenizer:
31 source: SicariusSicariiStuff/Negative_LLAMA_70B