update model_worker.py
Browse files182 unmodified lines18318418518618718718818919034 unmodified lines22522622722822923023123223323423523623723823924024124280 unmodified lines323324325314315316326318319320321322327328329182 unmodified lines else: self.model_name = model_name
self.import_flash_attn() logger.info(f"Loading the model {self.model_name} on worker {worker_id} ...")
tokenizer = AutoTokenizer.from_pretrained( model_path, trust_remote_code=True, use_fast=False )34 unmodified lines ) self.heart_beat_thread.start()
@spaces.GPU def import_flash_attn(self): try: import flash_attn except ImportError:
def install_flash_attn(): os.system("pip install flash-attn==2.5.9.post1")
install_flash_attn() # import flash_attn
def reload_model(self): del self.model torch.cuda.empty_cache()80 unmodified lines @spaces.GPU @torch.inference_mode() def generate_stream(self, params): try: import flash_attn except ImportError:
def install_flash_attn(): os.system("pip install flash-attn==2.5.9.post1")
install_flash_attn() # import flash_attn system_message = params["prompt"][0]["content"] send_messages = params["prompt"][1:] max_input_tiles = params["max_input_tiles"]model_worker.py+13-9