developer-lunark commited on
Commit
47c2de7
·
verified ·
1 Parent(s): 2bc7b43

fix: VARCO 모델 사전 다운로드로 콜드 스타트 타임아웃 해결

Browse files
Files changed (1) hide show
  1. app.py +41 -0
app.py CHANGED
@@ -306,6 +306,47 @@ class ModelManager:
306
  # Global model manager
307
  model_manager = ModelManager()
308
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
309
  # ============================================================
310
  # 시스템 프롬프트 생성
311
  # ============================================================
 
306
  # Global model manager
307
  model_manager = ModelManager()
308
 
309
+ # ============================================================
310
+ # 베이스 모델 사전 캐싱 (콜드 스타트 방지)
311
+ # ============================================================
312
+
313
+ def preload_base_models():
314
+ """Pre-download base models to avoid cold start timeout"""
315
+ if not TORCH_AVAILABLE:
316
+ print("Skipping preload: PyTorch not available")
317
+ return
318
+
319
+ from huggingface_hub import snapshot_download
320
+ import os
321
+
322
+ # Models that need pre-caching (large or slow to download)
323
+ models_to_cache = [
324
+ "NCSOFT/Llama-VARCO-8B-Instruct", # VARCO - 16GB, often times out on first load
325
+ ]
326
+
327
+ print("=" * 50)
328
+ print("Pre-downloading base models (this may take a while)...")
329
+ print("=" * 50)
330
+
331
+ for model_id in models_to_cache:
332
+ try:
333
+ print(f" Downloading: {model_id}")
334
+ # Download all model files to HF cache
335
+ cache_dir = snapshot_download(
336
+ repo_id=model_id,
337
+ ignore_patterns=["*.md", "*.txt"], # Skip docs
338
+ )
339
+ print(f" ✓ Downloaded to: {cache_dir}")
340
+
341
+ except Exception as e:
342
+ print(f" ✗ Failed to download {model_id}: {e}")
343
+
344
+ print("Pre-download complete!")
345
+ print("=" * 50)
346
+
347
+ # Run preload at startup
348
+ preload_base_models()
349
+
350
  # ============================================================
351
  # 시스템 프롬프트 생성
352
  # ============================================================