Commit ·
e3e334f
1
Parent(s): 4500f92
Use actual parameter count for AOT decision instead of string matching
Browse files452 unmodified lines45345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848920 unmodified lines510511512513514515516517518519520452 unmodified linespipe = load_pipeline(model_name)# AOT compilation for performance optimization (only for larger models)# Estimate model sizemodel_size = 0if '30B' in model_name or '32B' in model_name:model_size = 30elif '20B' in model_name:model_size = 20elif '15B' in model_name or '14B' in model_name:model_size = 15elif '4B' in model_name or '3B' in model_name:model_size = 4elif '2B' in model_name or '1.7B' in model_name:model_size = 2elif '1.5B' in model_name or '1.2B' in model_name or '1.1B' in model_name:model_size = 1.5elif '1B' in model_name:model_size = 1elif '700M' in model_name or '600M' in model_name:model_size = 0.7elif '500M' in model_name:model_size = 0.5elif '360M' in model_name or '350M' in model_name:model_size = 0.35elif '270M' in model_name:model_size = 0.27elif '135M' in model_name:model_size = 0.135else:model_size = 4 # defaultuse_aot = model_size >= 2 # Only compile models >= 2B parametersif use_aot:try:20 unmodified lines)compiled = spaces.aoti_compile(exported)spaces.aoti_apply(compiled, pipe.model)print(f"AOT compilation successful for {model_name}")except Exception as e:print(f"AOT compilation failed for {model_name}: {e}")else:print(f"Skipping AOT compilation for small model {model_name}")prompt = format_conversation(history, enriched, pipe.tokenizer)prompt_debug = f"\n\n--- Prompt Preview ---\n```\n{prompt}\n```"452 unmodified lines45345445545645745845946046146220 unmodified lines483484485486487488489490491492493452 unmodified linespipe = load_pipeline(model_name)# Determine actual model size for AOT decisionactual_params = sum(p.numel() for p in pipe.model.parameters())model_size_b = actual_params / 1e9 # Convert to billionsuse_aot = model_size_b >= 2 # Only compile models >= 2B parametersif use_aot:try:20 unmodified lines)compiled = spaces.aoti_compile(exported)spaces.aoti_apply(compiled, pipe.model)print(f"AOT compilation successful for {model_name} ({model_size_b:.1f}B parameters)")except Exception as e:print(f"AOT compilation failed for {model_name}: {e}")else:print(f"Skipping AOT compilation for small model {model_name} ({model_size_b:.1f}B parameters)")prompt = format_conversation(history, enriched, pipe.tokenizer)prompt_debug = f"\n\n--- Prompt Preview ---\n```\n{prompt}\n```"
app.py+6-33