Spaces:
Sleeping
Sleeping
apehex commited on
Commit ·
5e133f5
1
Parent(s): 2431602
Remove unrelated code + use the GPU wrapper on the main process.
Browse files
app.py
CHANGED
|
@@ -39,28 +39,6 @@ def fetch_tokenizer(device: str='cpu') -> object:
|
|
| 39 |
# tuple of objects or (None, None)
|
| 40 |
return _TOKENIZERS.get(device, None)
|
| 41 |
|
| 42 |
-
# GENERATION ###################################################################
|
| 43 |
-
|
| 44 |
-
@spaces.GPU(duration=30)
|
| 45 |
-
def compute_states(
|
| 46 |
-
token_num: float,
|
| 47 |
-
topk_num: float,
|
| 48 |
-
topp_num: float,
|
| 49 |
-
prompt_str: str,
|
| 50 |
-
) -> tuple:
|
| 51 |
-
# load the model and tokenizer inside the GPU wrapper
|
| 52 |
-
__model = fetch_model(device='cuda')
|
| 53 |
-
__tokenizer = fetch_tokenizer(device='cuda')
|
| 54 |
-
# fill all the arguments that cannot be pickled
|
| 55 |
-
return _app.update_computation_state(
|
| 56 |
-
token_num=token_num,
|
| 57 |
-
topk_num=topk_num,
|
| 58 |
-
topp_num=topp_num,
|
| 59 |
-
prompt_str=prompt_str,
|
| 60 |
-
device_str='cuda',
|
| 61 |
-
model_obj=__model,
|
| 62 |
-
tokenizer_obj=__tokenizer)
|
| 63 |
-
|
| 64 |
# TOKENS #######################################################################
|
| 65 |
|
| 66 |
def compute_tokens(
|
|
@@ -87,6 +65,7 @@ def compute_indices(
|
|
| 87 |
|
| 88 |
# LOGITS #######################################################################
|
| 89 |
|
|
|
|
| 90 |
def compute_logits(
|
| 91 |
indices_arr: object,
|
| 92 |
) -> object:
|
|
|
|
| 39 |
# tuple of objects or (None, None)
|
| 40 |
return _TOKENIZERS.get(device, None)
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
# TOKENS #######################################################################
|
| 43 |
|
| 44 |
def compute_tokens(
|
|
|
|
| 65 |
|
| 66 |
# LOGITS #######################################################################
|
| 67 |
|
| 68 |
+
@spaces.GPU(duration=30)
|
| 69 |
def compute_logits(
|
| 70 |
indices_arr: object,
|
| 71 |
) -> object:
|