File size: 1,701 Bytes
a9fdace
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python3
"""
llama.cpp Hugging Face to GGUF conversion script
"""

import os
import sys
import json
import subprocess
from pathlib import Path

def main():
    # Model paths
    model_path = "trained_models/isaac_sim_hf/complete_merged_model"
    output_path = "trained_models/isaac_sim_hf/gguf_final/isaac_sim_qwen2.5_coder.gguf"
    
    print(f"Converting {model_path} to {output_path}")
    
    # Use llama.cpp convert_hf_to_gguf.py script directly
    convert_script = "/mnt/s/Train a Reasoning Model with NeMo/llama.cpp/convert_hf_to_gguf.py"
    if not os.path.exists(convert_script):
        print(f"❌ Convert script not found: {convert_script}")
        return False
    
    # Run the conversion using llama.cpp convert_hf_to_gguf.py
    cmd = [
        sys.executable, convert_script,
        model_path,
        "--outfile", output_path,
        "--outtype", "f16",
        "--model-type", "qwen2"
    ]
    
    try:
        print(f"Running: {' '.join(cmd)}")
        result = subprocess.run(cmd, capture_output=True, text=True, check=True)
        print("✅ Conversion completed successfully")
        print(f"Output: {result.stdout}")
        
        # Show file info
        if os.path.exists(output_path):
            size_mb = os.path.getsize(output_path) / (1024 * 1024)
            print(f"📁 Output file size: {size_mb:.1f} MB")
        
    except subprocess.CalledProcessError as e:
        print(f"❌ Conversion failed: {e.stderr}")
        return False
    except Exception as e:
        print(f"❌ Unexpected error: {str(e)}")
        return False
    
    return True

if __name__ == "__main__":
    success = main()
    sys.exit(0 if success else 1)