File size: 4,166 Bytes
41b0a37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
## 3. version_check.py

#```python
#!/usr/bin/env python3
"""
Version and compatibility check for DeepSeek-V3.1-4bit model
"""

import argparse
import logging
import sys
from pathlib import Path
import importlib.metadata

logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)

def check_package_version(package_name, min_version=None):
    """Check if a package is installed and meets version requirements"""
    try:
        version = importlib.metadata.version(package_name)
        status = "βœ…"
        if min_version and version < min_version:
            status = "⚠️"
        logger.info(f"{status} {package_name}: {version} {'(>= ' + min_version + ')' if min_version else ''}")
        return version
    except importlib.metadata.PackageNotFoundError:
        logger.error(f"❌ {package_name}: Not installed")
        return None

def check_system_requirements():
    """Check system requirements for running the model"""
    logger.info("=" * 50)
    logger.info("πŸ–₯️ System Requirements Check")
    logger.info("=" * 50)
    
    # Check Python version
    python_version = sys.version.split()[0]
    logger.info(f"βœ… Python: {python_version}")
    
    # Check required packages
    required_packages = [
        ("transformers", "4.35.0"),
        ("huggingface-hub", "0.16.0"),
        ("mlx", "0.0.6"),
        ("numpy", "1.21.0"),
        ("torch", "2.0.0"),
    ]
    
    for package, min_version in required_packages:
        check_package_version(package, min_version)
    
    # Check optional packages
    logger.info("\nπŸ“¦ Optional Packages:")
    optional_packages = [
        "accelerate",
        "safetensors",
        "tokenizers",
    ]
    
    for package in optional_packages:
        check_package_version(package)

def check_model_compatibility(model_path):
    """Check if the model files are compatible with MLX"""
    logger.info("\n" + "=" * 50)
    logger.info("πŸ” Model Compatibility Check")
    logger.info("=" * 50)
    
    model_dir = Path(model_path)
    
    # Check for required files
    required_files = [
        "config.json",
        "tokenizer.json",
        "tokenizer_config.json",
    ]
    
    weight_files = [
        "model.safetensors",
        "model.npz",
        "*.gguf",
        "*.mlx"
    ]
    
    logger.info("πŸ“ Required Files:")
    missing_files = []
    for file in required_files:
        if (model_dir / file).exists():
            logger.info(f"βœ… {file}")
        else:
            logger.info(f"❌ {file}")
            missing_files.append(file)
    
    logger.info("\nπŸ“¦ Weight Files:")
    found_weights = False
    for pattern in weight_files:
        for file in model_dir.glob(pattern):
            size_mb = file.stat().st_size / (1024 * 1024)
            logger.info(f"βœ… {file.name} ({size_mb:.1f} MB)")
            found_weights = True
    
    if not found_weights:
        logger.error("❌ No weight files found!")
        return False
    
    if missing_files:
        logger.warning(f"⚠️ Missing {len(missing_files)} required files")
        return False
    
    return True

def main():
    parser = argparse.ArgumentParser(description="Check version and compatibility for DeepSeek-V3.1-4bit")
    parser.add_argument("--model-path", type=str, default="./deepseek_v3_4bit",
                       help="Path to the downloaded model")
    
    args = parser.parse_args()
    
    # Check system requirements
    check_system_requirements()
    
    # Check model compatibility if path exists
    if Path(args.model_path).exists():
        check_model_compatibility(args.model_path)
    else:
        logger.warning(f"Model path does not exist: {args.model_path}")
        logger.info("Run download script first: python download_deepseek_v3_4bit.py")
    
    logger.info("\nπŸ’‘ Recommendations:")
    logger.info("   - Ensure you have at least 40GB free disk space")
    logger.info("   - For inference, recommend 64GB+ RAM")
    logger.info("   - Use Apple Silicon (M1/M2/M3) for best performance")
    
    return 0

if __name__ == "__main__":
    exit(main())
#```