-
Notifications
You must be signed in to change notification settings - Fork 2
Quickly plot sweeps #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,79 @@ | ||
| """ | ||
| Plots the results of a sweep for the current git hash. | ||
| """ | ||
| import argparse | ||
|
|
||
| import git | ||
| import matplotlib.pyplot as plt | ||
| import seaborn as sns | ||
| import pandas as pd | ||
|
|
||
|
|
||
| DEFAULT_BATCH_SIZE = 1 | ||
| DEFAULT_PROMPT_LENGTH = 1000 | ||
|
|
||
|
|
||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument( | ||
| "--sweep", | ||
| type=str, | ||
| choices=["batch", "length"], | ||
| required=True, | ||
| help="Select which type of sweep to plot" | ||
| ) | ||
| args = parser.parse_args() | ||
|
|
||
| # 1. Read file and retrieve relevant data | ||
| results_file = "./results/results_llama.csv" | ||
| df = pd.read_csv(results_file) | ||
|
|
||
| repo = git.Repo(search_parent_directories=True) | ||
| current_git_hash = repo.git.rev_parse(repo.head, short=True) | ||
| df = df[df["Git hash"] == current_git_hash] | ||
| if df.empty: | ||
| raise ValueError(f"No results found for current git hash ({current_git_hash})") | ||
|
|
||
| if args.sweep == "batch": | ||
| df = df[df["Prompt length"] == DEFAULT_PROMPT_LENGTH] | ||
| else: | ||
| df = df[df["Batch size"] == DEFAULT_BATCH_SIZE] | ||
| df = df[df["Prompt length"] != DEFAULT_PROMPT_LENGTH] | ||
|
|
||
| if df.empty: | ||
| raise ValueError("Something went wrong -- no results in the filtered dataframe") | ||
|
|
||
| # 2. Plot -- we expect 3 series: original model, preallocated, and preallocated + compiled | ||
| if args.sweep == "batch": | ||
| x_col_name = "Batch size" | ||
| else: | ||
| x_col_name = "Prompt length" | ||
|
|
||
| df["Type"] = df["Preallocate"].astype("str") + df["Compile"] | ||
| df["Type"] = df["Type"].replace({"Falseno": "original", "Trueno": "Preallocate", "Truestatic": "Pre + comp."}) | ||
|
|
||
| g = sns.catplot( | ||
| data=df, | ||
| kind="bar", | ||
| x=x_col_name, | ||
| y="Tokens per second", | ||
| hue="Type", | ||
| palette={"original": "blue", "Preallocate": "orange", "Pre + comp.": "red"}, | ||
| alpha=.9, | ||
| ) | ||
| g.despine(left=True) | ||
| g.set_axis_labels("Batch size" if args.sweep == "batch" else "Prompt length", "Tokens per second") | ||
| g.legend.set_title("LLaMA code version") | ||
| plt.setp(g._legend.get_texts(), fontsize='7') # for legend text | ||
|
|
||
| title_constant = f'{"Batch size = " + str(DEFAULT_BATCH_SIZE) if args.sweep == "length" else "Prompt length = " + str(DEFAULT_PROMPT_LENGTH)}' | ||
| g.set(title=f'LLaMA sweep ({title_constant})') | ||
|
|
||
| # Add the number to the top of each bar | ||
| ax = g.facet_axis(0, 0) | ||
| for i in ax.containers: | ||
| ax.bar_label(i, fontsize=7) | ||
|
|
||
| g.tight_layout() | ||
| plt_path = f"./results/llama_sweep_{current_git_hash}_{args.sweep}.png" | ||
| plt.savefig(plt_path, dpi=300) | ||
| print(f"Plot stored at {plt_path}") |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To see how fast we can get with compile :) Happy to revert if you feel like it won't be the planned use case!