Fix: Move model load inside @spaces.GPU to prevent CPU OOM crash

#4
Build Small Hackathon org
πŸ€–
smolagents/ml-intern

The current app.py loads the 67GB model at module level (outside @spaces.GPU), which crashes during Gradio startup on CPU. This PR moves model loading into a lazy cache inside @spaces.GPU, so it only loads when GPU is active. Also increases GPU duration from 180s to 300s to accommodate cold model load.

Changes:

  • Replace module-level AutoTokenizer.from_pretrained + AutoModelForCausalLM.from_pretrained with lazy _load() inside @spaces.GPU
  • Increase duration from 180s to 300s
  • Add _model_cache to avoid reloading per call
specimba changed pull request status to open
specimba changed pull request status to merged

Sign up or log in to comment