|
|
|
|
|
|
|
|
|
""" |
|
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) |
|
|
|
|
|
python_version = sys.version.split()[0] |
|
logger.info(f"✅ Python: {python_version}") |
|
|
|
|
|
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) |
|
|
|
|
|
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) |
|
|
|
|
|
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() |
|
|
|
|
|
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()) |
|
|