- Notifications
You must be signed in to change notification settings - Fork 4
Profiling and misc #10
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
Show all changes
23 commits Select commit Hold shift + click to select a range
e7473b9
dockerfile
jlamypoirier f101f76
Refactor and profiling
jlamypoirier 1c95f1f
style
jlamypoirier 068430d
formatting and fixes
jlamypoirier 33e8e11
cleanup
jlamypoirier e742a53
style
jlamypoirier ee237d2
Merge branch 'dockerfile' into profiling
jlamypoirier 633619e
cleanup
jlamypoirier 008a2d4
improvements
jlamypoirier 06797e7
misc
jlamypoirier 06a803e
cleanup
jlamypoirier 916d01a
fix_import
jlamypoirier c1b4e4a
fixes
jlamypoirier 9cf847f
Merge branch 'main' into profiling
jlamypoirier c1efe53
Update transformers
jlamypoirier 4c77db1
Update transformers, improve profiling output, configurable activatio…
jlamypoirier 64ff77d
Update makefile
jlamypoirier 03115bc
--no-cache-dir
mayank31398 d7fe3dd
move constants
mayank31398 ec62e17
call as a module
mayank31398 b04d9bc
cleanup
jlamypoirier c9681ae
Revert "call as a module"
jlamypoirier 13561bb
Revert "move constants"
jlamypoirier 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
Original file line number | Diff line number | Diff line change |
---|---|---|
| @@ -6,69 +6,49 @@ style: | |
| ||
batch_size := 1 | ||
| ||
install-mqa-transformers: | ||
git clone https://github.com/bigcode-project/transformers.git; \ | ||
cd transformers; \ | ||
git checkout mayank/multi_query; \ | ||
pip install .; \ | ||
cd ..; \ | ||
rm -rf transformers; | ||
install: | ||
git submodule update --init | ||
pip install -r requirements.txt | ||
| ||
# BLOOM AliBi | ||
hf-1b-bloom-fp32: | ||
python src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_GPU_Pipeline --model_class BLOOM --dtype float32 --batch_size ${batch_size} | ||
python3 src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_Pipeline --model_class BLOOM --dtype float32 --batch_size ${batch_size} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mayank31398 I don't see why we should have it as a module. It's a script and not installed as a package. | ||
| ||
hf-1b-bloom-bf16: | ||
python src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_GPU_Pipeline --model_class BLOOM --dtype bfloat16 --batch_size ${batch_size} | ||
python3 src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_Pipeline --model_class BLOOM --dtype bfloat16 --batch_size ${batch_size} | ||
| ||
hf-1b-bloom-int8: | ||
python src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_GPU_Pipeline --model_class BLOOM --dtype int8 --batch_size ${batch_size} | ||
python3 src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_Pipeline --model_class BLOOM --dtype int8 --batch_size ${batch_size} | ||
| ||
ds-inference-1b-bloom-fp16: | ||
deepspeed --num_gpus 1 src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class DS_Inference_Pipeline --model_class BLOOM --batch_size ${batch_size} | ||
deepspeed --num_gpus 1 src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class DS_Pipeline --model_class BLOOM --batch_size ${batch_size} | ||
| ||
# GPT2 MHA | ||
hf-1b-GPT2-mha-fp32: | ||
python src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_GPU_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 1 --dtype float32 --batch_size ${batch_size} | ||
python3 src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 1 --dtype float32 --batch_size ${batch_size} | ||
| ||
hf-1b-GPT2-mha-bf16: | ||
python src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_GPU_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 1 --dtype bfloat16 --batch_size ${batch_size} | ||
python3 src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 1 --dtype bfloat16 --batch_size ${batch_size} | ||
| ||
hf-1b-GPT2-mha-int8: | ||
python src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_GPU_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 1 --dtype int8 --batch_size ${batch_size} | ||
python3 src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 1 --dtype int8 --batch_size ${batch_size} | ||
| ||
ds-inference-1b-GPT2-mha-fp16: | ||
deepspeed --num_gpus 1 src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class DS_Inference_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 1 --batch_size ${batch_size} | ||
| ||
# GPT2 MQA | ||
hf-1b-GPT2-mqa-fp32: | ||
python src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_GPU_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 2 --dtype float32 --batch_size ${batch_size} | ||
| ||
hf-1b-GPT2-mqa-bf16: | ||
python src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_GPU_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 2 --dtype bfloat16 --batch_size ${batch_size} | ||
| ||
hf-1b-GPT2-mqa-int8: | ||
python src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_GPU_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 2 --dtype int8 --batch_size ${batch_size} | ||
| ||
ds-inference-1b-GPT2-mqa-fp16: | ||
deepspeed --num_gpus 1 src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class DS_Inference_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 2 --batch_size ${batch_size} | ||
deepspeed --num_gpus 1 src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class DS_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 1 --batch_size ${batch_size} | ||
| ||
# GPT2 MQA1 | ||
hf-1b-GPT2-mqa1-fp32: | ||
python src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_GPU_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 3 --dtype float32 --batch_size ${batch_size} | ||
python3 src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 2 --dtype float32 --batch_size ${batch_size} | ||
| ||
hf-1b-GPT2-mqa1-bf16: | ||
python src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_GPU_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 3 --dtype bfloat16 --batch_size ${batch_size} | ||
python3 src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 2 --dtype bfloat16 --batch_size ${batch_size} | ||
| ||
hf-1b-GPT2-mqa1-int8: | ||
python src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_GPU_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 3 --dtype int8 --batch_size ${batch_size} | ||
| ||
ds-inference-1b-GPT2-mqa1-fp16: | ||
deepspeed --num_gpus 1 src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class DS_Inference_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 3 --batch_size ${batch_size} | ||
python3 src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 2 --dtype int8 --batch_size ${batch_size} | ||
| ||
# Input length experiments | ||
hf-1b-GPT2-mqa1-int8-input-length: | ||
python src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_GPU_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 3 --dtype int8 --batch_size ${batch_size} --max_input_length ${max_input_length} | ||
python3 src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 2 --dtype int8 --batch_size ${batch_size} --max_input_length ${max_input_length} | ||
| ||
hf-1b-GPT2-mha-int8-input-length: | ||
python src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_GPU_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 1 --dtype int8 --batch_size ${batch_size} --max_input_length ${max_input_length} | ||
python3 src/main.py --hidden_size 2048 --n_head 16 --n_layer 24 --pipeline_class HF_Pipeline --model_class GPT2 --n_positions 2048 --attention_type 1 --dtype int8 --batch_size ${batch_size} --max_input_length ${max_input_length} |
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
accelerate==0.15.0 | ||
bitsandbytes | ||
deepspeed==0.7.7 | ||
./transformers | ||
-e ./transformers | ||
| ||
# TODO: Dev only | ||
isort>=5.5.4 | ||
|
Empty file.
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 |
---|---|---|
@@ -1,19 +1,23 @@ | ||
import pipelines | ||
from utils import benchmark_end_to_end, get_arg_parser, get_args, get_dummy_batch | ||
from typing import List, Optional | ||
| ||
from src.pipelines import get_pipeline_class | ||
from src.utils.arguments import parse_args | ||
from src.utils.benchmark import benchmark_end_to_end | ||
from src.utils.input import get_dummy_batch | ||
from src.utils.logging import configure_logging | ||
| ||
def main() -> None: | ||
# deepspeed.init_distributed("nccl") | ||
| ||
args = get_args(get_arg_parser()) | ||
def main(argv: Optional[List[str]] = None) -> None: | ||
args = parse_args(argv=argv) | ||
| ||
inputs = get_dummy_batch(args.batch_size, args.max_input_length) | ||
| ||
generate_kwargs = dict(max_new_tokens=args.max_new_tokens, do_sample=False) | ||
generate_kwargs = {"max_new_tokens": args.max_new_tokens, "do_sample": False} | ||
| ||
pipeline_class = getattr(pipelines, args.pipeline_class) | ||
pipeline_class = get_pipeline_class(args.pipeline_class) | ||
benchmark_end_to_end(args, pipeline_class, inputs, generate_kwargs) | ||
| ||
| ||
if __name__ == "__main__": | ||
configure_logging() | ||
main() |
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 |
---|---|---|
@@ -1,3 +1,11 @@ | ||
from .ds_inference import DS_Inference_Pipeline | ||
from .hf import HF_CPU_Pipeline, HF_GPU_Pipeline | ||
from .pipeline import Pipeline | ||
def get_pipeline_class(name): | ||
if name == "HF_Pipeline": | ||
from src.pipelines.transformers import HF_Pipeline | ||
| ||
return HF_Pipeline | ||
elif name == "DS_Pipeline": | ||
from src.pipelines.ds import DS_Pipeline | ||
| ||
return DS_Pipeline | ||
else: | ||
raise NotImplementedError(f"Unsupported pipeline class: {name}") |
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,25 @@ | ||
import os | ||
from argparse import Namespace | ||
| ||
import deepspeed | ||
import torch | ||
| ||
from src.pipelines.pipeline import Pipeline | ||
from src.utils.arguments import check_unused | ||
| ||
| ||
class DS_Pipeline(Pipeline): | ||
def __init__(self, args: Namespace) -> None: | ||
check_unused(args, {"device": torch.device("cuda")}, enforce=True) | ||
# TODO: Works with other dtypes? | ||
check_unused(args, {"dtype": torch.float16}) | ||
super().__init__(args) | ||
| ||
self.model = deepspeed.init_inference( | ||
self.model, | ||
mp_size=int(os.getenv("WORLD_SIZE", "1")), | ||
# base_dir="./", | ||
dtype=args.dtype, | ||
replace_with_kernel_inject=args.inject_kernel, | ||
enable_cuda_graph=args.cuda_graph, | ||
) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.