-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Shard] Add sharding generation in shark studio
Signed-Off-by: Gaurav Shukla <[email protected]>
- Loading branch information
1 parent
c9de272
commit bd30044
Showing
5 changed files
with
91 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import gradio as gr | ||
import torch | ||
from transformers import AutoTokenizer | ||
from apps.language_models.src.model_wrappers.vicuna_model import CombinedModel | ||
from shark.shark_generate_model_config import GenerateConfigFile | ||
|
||
|
||
def get_model_config(): | ||
hf_model_path = "TheBloke/vicuna-7B-1.1-HF" | ||
tokenizer = AutoTokenizer.from_pretrained(hf_model_path, use_fast=False) | ||
compilation_prompt = "".join(["0" for _ in range(17)]) | ||
compilation_input_ids = tokenizer( | ||
compilation_prompt, | ||
return_tensors="pt", | ||
).input_ids | ||
compilation_input_ids = torch.tensor(compilation_input_ids).reshape( | ||
[1, 19] | ||
) | ||
firstVicunaCompileInput = (compilation_input_ids,) | ||
|
||
model = CombinedModel() | ||
c = GenerateConfigFile(model, 1, ["gpu_id"], firstVicunaCompileInput) | ||
return c.split_into_layers() | ||
|
||
|
||
with gr.Blocks() as model_config_web: | ||
with gr.Row(): | ||
hf_models = gr.Dropdown( | ||
label="Model List", | ||
choices=["Vicuna"], | ||
value="Vicuna", | ||
visible=True, | ||
) | ||
get_model_config_btn = gr.Button(value="Get Model Config") | ||
json_view = gr.JSON() | ||
|
||
get_model_config_btn.click( | ||
fn=get_model_config, | ||
inputs=[], | ||
outputs=[json_view], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters