From 3e5165c3ed824ee86721424d34fb12fedff2cfd1 Mon Sep 17 00:00:00 2001 From: "Yang, Bo" Date: Sat, 15 Jul 2023 00:32:46 -0700 Subject: [PATCH] Directly load GPTBigCode to specified device This PR directly load GPTBigCode to specified device, avoiding moving model between devices. --- .../text_generation_server/models/santacoder.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/text_generation_server/models/santacoder.py b/server/text_generation_server/models/santacoder.py index a2b38737..81928c1d 100644 --- a/server/text_generation_server/models/santacoder.py +++ b/server/text_generation_server/models/santacoder.py @@ -51,14 +51,14 @@ class SantaCoder(CausalLM): "pad_token": EOD, } ) - - model = AutoModelForCausalLM.from_pretrained( - model_id, - revision=revision, - torch_dtype=dtype, - load_in_8bit=quantize == "bitsandbytes", - trust_remote_code=trust_remote_code, - ).to(device) + with device: + model = AutoModelForCausalLM.from_pretrained( + model_id, + revision=revision, + torch_dtype=dtype, + load_in_8bit=quantize == "bitsandbytes", + trust_remote_code=trust_remote_code, + ) super(CausalLM, self).__init__( model=model,