Spaces:
Runtime error
Runtime error
danavirtual
commited on
Commit
β’
eb0d58e
1
Parent(s):
40abe2f
added config (torch) to app
Browse files- InstructionTextGenerationPipeline.py +9 -1
- app.py +12 -2
- nohup.out +10 -44
InstructionTextGenerationPipeline.py
CHANGED
@@ -27,7 +27,13 @@ PROMPT_FOR_GENERATION_FORMAT = """{intro}
|
|
27 |
instruction="{instruction}",
|
28 |
response_key=RESPONSE_KEY,
|
29 |
)
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
class InstructionTextGenerationPipeline:
|
33 |
def __init__(
|
@@ -35,10 +41,12 @@ class InstructionTextGenerationPipeline:
|
|
35 |
model_name,
|
36 |
torch_dtype=torch.bfloat16,
|
37 |
trust_remote_code=True,
|
|
|
38 |
use_auth_token=None,
|
39 |
) -> None:
|
40 |
self.model = AutoModelForCausalLM.from_pretrained(
|
41 |
model_name,
|
|
|
42 |
torch_dtype=torch_dtype,
|
43 |
trust_remote_code=trust_remote_code,
|
44 |
use_auth_token=use_auth_token,
|
|
|
27 |
instruction="{instruction}",
|
28 |
response_key=RESPONSE_KEY,
|
29 |
)
|
30 |
+
#
|
31 |
+
#generate = InstructionTextGenerationPipeline(
|
32 |
+
# "mosaicml/mpt-7b-instruct",
|
33 |
+
# torch_dtype=torch.bfloat16,
|
34 |
+
# trust_remote_code=True,
|
35 |
+
# config=config,
|
36 |
+
#)
|
37 |
|
38 |
class InstructionTextGenerationPipeline:
|
39 |
def __init__(
|
|
|
41 |
model_name,
|
42 |
torch_dtype=torch.bfloat16,
|
43 |
trust_remote_code=True,
|
44 |
+
config=None,
|
45 |
use_auth_token=None,
|
46 |
) -> None:
|
47 |
self.model = AutoModelForCausalLM.from_pretrained(
|
48 |
model_name,
|
49 |
+
config=config,
|
50 |
torch_dtype=torch_dtype,
|
51 |
trust_remote_code=trust_remote_code,
|
52 |
use_auth_token=use_auth_token,
|
app.py
CHANGED
@@ -62,10 +62,17 @@ def complete(state="complete"):
|
|
62 |
complete(state='imports done')
|
63 |
|
64 |
complete(state="start generate")
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
generate = InstructionTextGenerationPipeline(
|
66 |
-
|
67 |
torch_dtype=torch.bfloat16,
|
68 |
trust_remote_code=True,
|
|
|
69 |
)
|
70 |
stop_token_ids = generate.tokenizer.convert_tokens_to_ids(["<|endoftext|>"])
|
71 |
complete(state="Model generated")
|
@@ -134,6 +141,9 @@ def tester(uPrompt, max_new_tokens, temperature, top_k, top_p):
|
|
134 |
results = f"{salutation} max_new_tokens{max_new_tokens}; temperature{temperature}; top_k{top_k}; top_p{top_p}; "
|
135 |
|
136 |
return response
|
|
|
|
|
|
|
137 |
demo = gr.Interface(
|
138 |
fn=tester,
|
139 |
inputs=[gr.Textbox(label="Prompt",info="Prompt",lines=3,value="Provide Prompt"),
|
@@ -144,7 +154,7 @@ demo = gr.Interface(
|
|
144 |
|
145 |
],
|
146 |
outputs=["text"],
|
147 |
-
title="
|
148 |
)
|
149 |
demo.launch(share=True,
|
150 |
server_name="0.0.0.0",
|
|
|
62 |
complete(state='imports done')
|
63 |
|
64 |
complete(state="start generate")
|
65 |
+
|
66 |
+
name = 'mosaicml/mpt-7b-instruct'
|
67 |
+
config = transformers.AutoConfig.from_pretrained(name, trust_remote_code=True)
|
68 |
+
config.attn_config['attn_impl'] = 'torch'
|
69 |
+
config.init_device = 'cuda:0' # For fast initialization directly on GPU!
|
70 |
+
|
71 |
generate = InstructionTextGenerationPipeline(
|
72 |
+
name,
|
73 |
torch_dtype=torch.bfloat16,
|
74 |
trust_remote_code=True,
|
75 |
+
config=config,
|
76 |
)
|
77 |
stop_token_ids = generate.tokenizer.convert_tokens_to_ids(["<|endoftext|>"])
|
78 |
complete(state="Model generated")
|
|
|
141 |
results = f"{salutation} max_new_tokens{max_new_tokens}; temperature{temperature}; top_k{top_k}; top_p{top_p}; "
|
142 |
|
143 |
return response
|
144 |
+
import torch
|
145 |
+
import transformers
|
146 |
+
|
147 |
demo = gr.Interface(
|
148 |
fn=tester,
|
149 |
inputs=[gr.Textbox(label="Prompt",info="Prompt",lines=3,value="Provide Prompt"),
|
|
|
154 |
|
155 |
],
|
156 |
outputs=["text"],
|
157 |
+
title="Mosaic MPT-7B",
|
158 |
)
|
159 |
demo.launch(share=True,
|
160 |
server_name="0.0.0.0",
|
nohup.out
CHANGED
@@ -1,51 +1,17 @@
|
|
1 |
-
sys.path : ['/home/
|
2 |
|
3 |
Cell imports done
|
4 |
|
5 |
Cell start generate
|
6 |
You are using config.init_device='cpu', but you can also use config.init_device="meta" with Composer + FSDP for fast initialization.
|
7 |
-
|
|
|
|
|
8 |
|
9 |
-
Cell
|
10 |
-
|
11 |
-
|
12 |
-
You are using config.init_device='cpu', but you can also use config.init_device="meta" with Composer + FSDP for fast initialization.
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
You are using config.init_device='cpu', but you can also use config.init_device="meta" with Composer + FSDP for fast initialization.
|
19 |
-
Traceback (most recent call last):
|
20 |
-
File "/home/ubuntu/Gradio/MPT7BTest/app.py", line 65, in <module>
|
21 |
-
generate = InstructionTextGenerationPipeline(
|
22 |
-
File "/home/ubuntu/Gradio/MPT7BTest/InstructionTextGenerationPipeline.py", line 40, in __init__
|
23 |
-
self.model = AutoModelForCausalLM.from_pretrained(
|
24 |
-
File "/home/ubuntu/.local/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py", line 479, in from_pretrained
|
25 |
-
return model_class.from_pretrained(
|
26 |
-
File "/home/ubuntu/.local/lib/python3.10/site-packages/transformers/modeling_utils.py", line 2675, in from_pretrained
|
27 |
-
model = cls(config, *model_args, **model_kwargs)
|
28 |
-
File "/home/ubuntu/.cache/huggingface/modules/transformers_modules/mosaicml/mpt-7b-instruct/e7119f37956c1a3865da33e25ef5ce9159ff2c16/modeling_mpt.py", line 222, in __init__
|
29 |
-
self.transformer = MPTModel(config)
|
30 |
-
File "/home/ubuntu/.cache/huggingface/modules/transformers_modules/mosaicml/mpt-7b-instruct/e7119f37956c1a3865da33e25ef5ce9159ff2c16/modeling_mpt.py", line 55, in __init__
|
31 |
-
self.apply(self.param_init_fn)
|
32 |
-
File "/home/ubuntu/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 884, in apply
|
33 |
-
module.apply(fn)
|
34 |
-
File "/home/ubuntu/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 884, in apply
|
35 |
-
module.apply(fn)
|
36 |
-
File "/home/ubuntu/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 884, in apply
|
37 |
-
module.apply(fn)
|
38 |
-
[Previous line repeated 1 more time]
|
39 |
-
File "/home/ubuntu/.local/lib/python3.10/site-packages/torch/nn/modules/module.py", line 885, in apply
|
40 |
-
fn(self)
|
41 |
-
File "/home/ubuntu/.cache/huggingface/modules/transformers_modules/mosaicml/mpt-7b-instruct/e7119f37956c1a3865da33e25ef5ce9159ff2c16/modeling_mpt.py", line 208, in param_init_fn
|
42 |
-
MODEL_INIT_REGISTRY[init_fn_name](module=module, n_layers=self.config.n_layers, d_model=self.config.d_model, **self.config.init_config)
|
43 |
-
File "/home/ubuntu/.cache/huggingface/modules/transformers_modules/mosaicml/mpt-7b-instruct/e7119f37956c1a3865da33e25ef5ce9159ff2c16/param_init_fns.py", line 167, in kaiming_normal_param_init_fn_
|
44 |
-
generic_param_init_fn_(module=module, init_fn_=kaiming_normal_, d_model=d_model, n_layers=n_layers, init_div_is_residual=init_div_is_residual, emb_init_std=emb_init_std, emb_init_uniform_lim=emb_init_uniform_lim, verbose=verbose)
|
45 |
-
File "/home/ubuntu/.cache/huggingface/modules/transformers_modules/mosaicml/mpt-7b-instruct/e7119f37956c1a3865da33e25ef5ce9159ff2c16/param_init_fns.py", line 49, in generic_param_init_fn_
|
46 |
-
fused_init_helper_(module, init_fn_)
|
47 |
-
File "/home/ubuntu/.cache/huggingface/modules/transformers_modules/mosaicml/mpt-7b-instruct/e7119f37956c1a3865da33e25ef5ce9159ff2c16/param_init_fns.py", line 26, in fused_init_helper_
|
48 |
-
init_fn_(module.weight[slice_indices])
|
49 |
-
File "/home/ubuntu/.local/lib/python3.10/site-packages/torch/nn/init.py", line 451, in kaiming_normal_
|
50 |
-
return tensor.normal_(0, std)
|
51 |
-
KeyboardInterrupt
|
|
|
1 |
+
sys.path : ['/home/ec2-user/Gradio/MPT7BTest', '/usr/lib64/python37.zip', '/usr/lib64/python3.7', '/usr/lib64/python3.7/lib-dynload', '/home/ec2-user/.local/lib/python3.7/site-packages', '/usr/lib64/python3.7/site-packages', '/usr/lib/python3.7/site-packages', '/home/ec2-user/workspace/Notebooks/lib']
|
2 |
|
3 |
Cell imports done
|
4 |
|
5 |
Cell start generate
|
6 |
You are using config.init_device='cpu', but you can also use config.init_device="meta" with Composer + FSDP for fast initialization.
|
7 |
+
|
8 |
+
/home/ec2-user/Gradio/MPT7BTest/InstructionTextGenerationPipeline.py:54: UserWarning: pad_token_id is not set for the tokenizer. Using eos_token_id as pad_token_id.
|
9 |
+
"pad_token_id is not set for the tokenizer. Using eos_token_id as pad_token_id."
|
10 |
|
11 |
+
Cell Model generated
|
12 |
+
Running on local URL: http://0.0.0.0:7860
|
13 |
+
Running on public URL: https://02eb0eb5bb97dfa857.gradio.live
|
|
|
|
|
14 |
|
15 |
+
This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)
|
16 |
+
Keyboard interruption in main thread... closing server.
|
17 |
+
Killing tunnel 0.0.0.0:7860 <> https://02eb0eb5bb97dfa857.gradio.live
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|