-
Notifications
You must be signed in to change notification settings - Fork 271
Run Llama2 with torch.compile on Gaudi2 #616
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
Changes from all commits
e8c6162
e13946f
11239b2
03596e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -115,7 +115,7 @@ def setup_env(args): | |
| check_min_version("4.34.0") | ||
| check_optimum_habana_min_version("1.9.0.dev0") | ||
|
|
||
| if args.global_rank == 0: | ||
| if args.global_rank == 0 and not args.torch_compile: | ||
| os.environ.setdefault("GRAPH_VISUALIZATION", "true") | ||
| shutil.rmtree(".graph_dumps", ignore_errors=True) | ||
|
|
||
|
|
@@ -151,6 +151,11 @@ def patch_scoped_linear_all_reduce(model): | |
| patch_scoped_linear_all_reduce(module) | ||
|
|
||
|
|
||
| def get_torch_compiled_model(model): | ||
| model.model = torch.compile(model.model, backend="aot_hpu_inference_backend") | ||
| return model | ||
|
|
||
|
|
||
| def setup_model(args, model_dtype, model_kwargs, logger): | ||
| logger.info("Single-device run.") | ||
|
|
||
|
|
@@ -170,6 +175,10 @@ def setup_model(args, model_dtype, model_kwargs, logger): | |
| model = wrap_in_hpu_graph(model, hash_with_views=not args.skip_hash_with_views) | ||
| else: | ||
| model = wrap_in_hpu_graph(model) | ||
|
|
||
| if args.torch_compile and model.config.model_type == "llama": | ||
| model = get_torch_compiled_model(model) | ||
|
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. @kausikmaiti Can we add model specific check as generation using torch.compile isn't verified on models
Contributor
Author
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. Added model specific check in separate commit. Please review. |
||
|
|
||
| return model | ||
|
|
||
|
|
||
|
|
||
|
Contributor
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. os.environ["WORLD_SIZE"] = "0" ? WORLD_SIZE should be set to 1 for 1x runs
Contributor
Author
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. As you mentioned offline, WORLD_SIZE setting does not matter, as I'm not using deepspeed / gaudi_spawn.py script. |
Uh oh!
There was an error while loading. Please reload this page.