forked from AI-Hypercomputer/jetstream-pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor so that environment and engine (AI-Hypercomputer#65)
* Refactor so that environment and engine so that they dont depend on llama specific stuff such as ModelArgs * Fix lints
- Loading branch information
Showing
8 changed files
with
101 additions
and
105 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
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,29 @@ | ||
import torch | ||
import jax | ||
from jetstream_pt.third_party.llama2 import model_args | ||
from jetstream_pt import environment | ||
|
||
|
||
def make_env_tiny(bf16_enable=True): | ||
torch_dtype = torch.bfloat16 if bf16_enable else torch.float32 | ||
torch.set_default_dtype(torch_dtype) | ||
jax.config.update("jax_dynamic_shapes", False) | ||
jax.config.update("jax_traceback_filtering", "off") | ||
config = model_args.get_model_args("tiny", 128, 1, 32000, True) | ||
environment_data = environment.JetEngineEnvironmentData() | ||
environment_data.max_input_sequence_length = 128 | ||
environment_data.max_input_sequence_length = 128 | ||
environment_data.cache_sequence_length = 128 | ||
environment_data.bf16_enable = bf16_enable | ||
environment_data.model_type = "llama-2-tiny" | ||
environment_data.batch_size = 1 | ||
environment_data.num_layers = config.n_layers | ||
environment_data.cache_shape = ( | ||
1, | ||
config.n_kv_heads, | ||
environment_data.cache_sequence_length, | ||
config.dim // config.n_heads, | ||
) | ||
env = environment.JetEngineEnvironment(environment_data) | ||
env.apply_sharding = lambda *args, **kwargs: None # don't shard on cpu | ||
return env, config |
File renamed without changes.
Oops, something went wrong.