a-normal-username commited on
Commit
9216300
·
verified ·
1 Parent(s): 174bd80

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +1 -0
  2. maxtext-setup/maxtext/.github/CODEOWNERS +2 -0
  3. maxtext-setup/maxtext/.github/workflows/AddLabel.yml +109 -0
  4. maxtext-setup/maxtext/.github/workflows/UnitTests.yml +168 -0
  5. maxtext-setup/maxtext/.github/workflows/UploadDockerImages.yml +53 -0
  6. maxtext-setup/maxtext/.github/workflows/build_and_upload_images.sh +58 -0
  7. maxtext-setup/maxtext/.github/workflows/utils/setup_runner.sh +77 -0
  8. maxtext-setup/maxtext/.gitignore +135 -0
  9. maxtext-setup/maxtext/.vscode/launch.json +36 -0
  10. maxtext-setup/maxtext/AUTHORS +2 -0
  11. maxtext-setup/maxtext/CONTRIBUTING.md +33 -0
  12. maxtext-setup/maxtext/LICENSE +201 -0
  13. maxtext-setup/maxtext/MaxText/__init__.py +15 -0
  14. maxtext-setup/maxtext/MaxText/__pycache__/accelerator_to_spec_map.cpython-310.pyc +0 -0
  15. maxtext-setup/maxtext/MaxText/__pycache__/checkpointing.cpython-310.pyc +0 -0
  16. maxtext-setup/maxtext/MaxText/__pycache__/common_types.cpython-310.pyc +0 -0
  17. maxtext-setup/maxtext/MaxText/__pycache__/max_logging.cpython-310.pyc +0 -0
  18. maxtext-setup/maxtext/MaxText/__pycache__/max_utils.cpython-310.pyc +0 -0
  19. maxtext-setup/maxtext/MaxText/__pycache__/maxtext_utils.cpython-310.pyc +0 -0
  20. maxtext-setup/maxtext/MaxText/__pycache__/multihost_dataloading.cpython-310.pyc +0 -0
  21. maxtext-setup/maxtext/MaxText/__pycache__/optimizers.cpython-310.pyc +0 -0
  22. maxtext-setup/maxtext/MaxText/__pycache__/pyconfig.cpython-310.pyc +0 -0
  23. maxtext-setup/maxtext/MaxText/__pycache__/sequence_packing.cpython-310.pyc +0 -0
  24. maxtext-setup/maxtext/MaxText/__pycache__/tokenizer.cpython-310.pyc +0 -0
  25. maxtext-setup/maxtext/MaxText/__pycache__/train.cpython-310.pyc +0 -0
  26. maxtext-setup/maxtext/MaxText/accelerator_to_spec_map.py +379 -0
  27. maxtext-setup/maxtext/MaxText/checkpointing.py +195 -0
  28. maxtext-setup/maxtext/MaxText/common_types.py +44 -0
  29. maxtext-setup/maxtext/MaxText/configs/README.md +77 -0
  30. maxtext-setup/maxtext/MaxText/configs/base.yml +249 -0
  31. maxtext-setup/maxtext/MaxText/configs/experimental/1024b.sh +28 -0
  32. maxtext-setup/maxtext/MaxText/configs/experimental/128b.sh +28 -0
  33. maxtext-setup/maxtext/MaxText/configs/experimental/256b.sh +28 -0
  34. maxtext-setup/maxtext/MaxText/configs/experimental/32b.sh +28 -0
  35. maxtext-setup/maxtext/MaxText/configs/experimental/512b.sh +28 -0
  36. maxtext-setup/maxtext/MaxText/configs/experimental/64b.sh +28 -0
  37. maxtext-setup/maxtext/MaxText/configs/gpu_smoke_test.yml +15 -0
  38. maxtext-setup/maxtext/MaxText/configs/llama2_7b_single_host_gpu.yml +17 -0
  39. maxtext-setup/maxtext/MaxText/configs/models/gemma-2b.yml +27 -0
  40. maxtext-setup/maxtext/MaxText/configs/models/gemma-7b.yml +27 -0
  41. maxtext-setup/maxtext/MaxText/configs/models/gpt3-175b.yml +44 -0
  42. maxtext-setup/maxtext/MaxText/configs/models/gpt3-22b.yml +40 -0
  43. maxtext-setup/maxtext/MaxText/configs/models/gpt3-52k.yml +40 -0
  44. maxtext-setup/maxtext/MaxText/configs/models/gpt3-6b.yml +40 -0
  45. maxtext-setup/maxtext/MaxText/configs/models/llama2-13b.yml +28 -0
  46. maxtext-setup/maxtext/MaxText/configs/models/llama2-70b.yml +27 -0
  47. maxtext-setup/maxtext/MaxText/configs/models/llama2-7b.yml +28 -0
  48. maxtext-setup/maxtext/MaxText/configs/models/mistral-7b.yml +28 -0
  49. maxtext-setup/maxtext/MaxText/configs/models/mixtral-8x7b.yml +30 -0
  50. maxtext-setup/maxtext/MaxText/configs/tpu_smoke_test.yml +14 -0
.gitattributes CHANGED
@@ -45,3 +45,4 @@ Mistral-7B-v0.1/full-checkpoint/ocdbt.process_0/d/5f96e30116e3c64eb48be0dcd852e2
45
  Mistral-7B-v0.1/full-checkpoint/ocdbt.process_0/d/725ec5fffd1e19943ee3db876b61e4c9 filter=lfs diff=lfs merge=lfs -text
46
  Mistral-7B-v0.1/full-checkpoint/ocdbt.process_0/d/a1f1e882590e106a9ac95bce84cebce6 filter=lfs diff=lfs merge=lfs -text
47
  Mistral-7B-v0.1/full-checkpoint/ocdbt.process_0/d/ed87bb9cdcf4384203b288a71e45b5f4 filter=lfs diff=lfs merge=lfs -text
 
 
45
  Mistral-7B-v0.1/full-checkpoint/ocdbt.process_0/d/725ec5fffd1e19943ee3db876b61e4c9 filter=lfs diff=lfs merge=lfs -text
46
  Mistral-7B-v0.1/full-checkpoint/ocdbt.process_0/d/a1f1e882590e106a9ac95bce84cebce6 filter=lfs diff=lfs merge=lfs -text
47
  Mistral-7B-v0.1/full-checkpoint/ocdbt.process_0/d/ed87bb9cdcf4384203b288a71e45b5f4 filter=lfs diff=lfs merge=lfs -text
48
+ maxtext-setup/maxtext/assets/tokenizer.gemma filter=lfs diff=lfs merge=lfs -text
maxtext-setup/maxtext/.github/CODEOWNERS ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ # Changes in this file should match with requiredReviewers in .github/workflows/AddLabel.yml
2
+ * @rwitten
maxtext-setup/maxtext/.github/workflows/AddLabel.yml ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2023 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ name: Add Label
16
+
17
+ on:
18
+ workflow_run:
19
+ workflows: [Unit Test, CodeQL]
20
+ types:
21
+ - completed
22
+ pull_request_review:
23
+ pull_request_review_comment:
24
+ workflow_dispatch:
25
+
26
+ jobs:
27
+ AddPullReady:
28
+ permissions:
29
+ checks: read
30
+ pull-requests: write
31
+ runs-on: ubuntu-latest
32
+
33
+ steps:
34
+ - uses: actions/github-script@v6
35
+ with:
36
+ script: |
37
+ const owner = "google"
38
+ const repo = "maxtext"
39
+ let pull_number = -1
40
+ if (context.payload.pull_request !== undefined) {
41
+ pull_number = context.payload.pull_request.number
42
+ } else if (context.payload.workflow_run !== undefined) {
43
+ if (context.payload.workflow_run.pull_requests.length === 0) {
44
+ console.log("This workflow is NOT running within a PR's context")
45
+ process.exit()
46
+ }
47
+ console.log(context.payload.workflow_run.pull_requests)
48
+ pull_number = context.payload.workflow_run.pull_requests[0].number
49
+ } else {
50
+ console.log("This workflow is running within an invalid context")
51
+ process.exit(1)
52
+ }
53
+
54
+ // This list should match with CODEOWNERS
55
+ let requiredReviewers = { rwitten: "" }
56
+ const reviews = await github.rest.pulls.listReviews({
57
+ owner,
58
+ repo,
59
+ pull_number,
60
+ })
61
+ if (reviews.data.length === 0) {
62
+ console.log("Not adding pull ready because the PR is not approved yet")
63
+ process.exit()
64
+ }
65
+ for (const review of reviews.data) {
66
+ if (review.state === "APPROVED") {
67
+ delete requiredReviewers[review.user.login]
68
+ }
69
+ }
70
+ if (Object.keys(requiredReviewers).length !== 0) {
71
+ console.log("Not adding pull ready because the PR is not approved yet")
72
+ process.exit()
73
+ }
74
+
75
+ const commits = await github.rest.pulls.listCommits({
76
+ owner,
77
+ repo,
78
+ pull_number,
79
+ per_page: 100,
80
+ })
81
+ // Check that the number of commits in the PR is 1.
82
+ if (commits.data.length !== 1) {
83
+ console.log("Not adding pull ready because the PR has more than one commit. Please squash your commits.")
84
+ process.exit(1)
85
+ }
86
+ const ref = commits.data.slice(-1)[0].sha
87
+ const checkRuns = await github.rest.checks.listForRef({
88
+ owner,
89
+ repo,
90
+ ref,
91
+ })
92
+ if (checkRuns.data.check_runs.length === 0) {
93
+ console.log("Not adding pull ready because no check runs are associated with the last commit: " + ref)
94
+ process.exit()
95
+ }
96
+ for (const checkRun of checkRuns.data.check_runs) {
97
+ if (checkRun.name.endsWith(context.job)) continue
98
+ if (checkRun.conclusion !== "success") {
99
+ console.log("Not adding pull ready because " + checkRun.name + " has not passed yet: " + checkRun.html_url)
100
+ process.exit()
101
+ }
102
+ }
103
+ console.log("Adding pull ready label because the PR is approved AND all the check runs have passed")
104
+ await github.rest.issues.addLabels({
105
+ issue_number: pull_number,
106
+ labels: ["pull ready"],
107
+ owner,
108
+ repo,
109
+ })
maxtext-setup/maxtext/.github/workflows/UnitTests.yml ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2023 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions
16
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
17
+
18
+ name: Unit Test
19
+
20
+ on:
21
+ pull_request:
22
+ push:
23
+ branches: [ "main" ]
24
+ workflow_dispatch:
25
+ schedule:
26
+ # Run the job every 2 hours
27
+ - cron: '0 */2 * * *'
28
+
29
+ jobs:
30
+ cpu:
31
+ runs-on: ${{ matrix.os }}
32
+ strategy:
33
+ matrix:
34
+ os: [ubuntu-20.04]
35
+ python-version: ['3.10']
36
+ steps:
37
+ - uses: actions/checkout@v3
38
+ - name: setup python
39
+ uses: actions/setup-python@v4
40
+ with:
41
+ python-version: ${{ matrix.python-version }}
42
+ - name: Install Dependencies
43
+ run: |
44
+ pip install pytype==2024.2.27
45
+ pip install pylint
46
+ - name: Typecheck the code with pytype
47
+ run: |
48
+ pytype --jobs auto --disable import-error MaxText/
49
+ - name: Analysing the code with pylint
50
+ run: |
51
+ pylint MaxText/
52
+
53
+
54
+ # IF YOU MODIFY THIS, YOU SHOULD ALSO ADD CORRESPONDING MODICATIONS TO 'gpu' job
55
+ tpu:
56
+ strategy:
57
+ fail-fast: false
58
+ matrix:
59
+ device-type: ["v4-8"]
60
+ name: "TPU test (${{ matrix.device-type }})"
61
+ runs-on: ["self-hosted", "tpu", "${{ matrix.device-type }}"]
62
+ steps:
63
+ - uses: actions/checkout@v3
64
+ - name: Cleanup old docker images
65
+ run: |
66
+ docker system prune --all --force
67
+ - name: Install dependencies
68
+ run: |
69
+ bash docker_build_dependency_image.sh
70
+ - name: Test gsutil installation
71
+ run: |
72
+ docker run -v /home/runner/actions-runner/_work/maxtext/maxtext:/app --rm --privileged maxtext_base_image bash -c \
73
+ 'which gsutil >/dev/null 2>&1 || { echo >&2 "gsutil is required but not installed. Aborting"; exit 24;}'
74
+ - name: Test with pytest
75
+ run: |
76
+ docker run -v /home/runner/actions-runner/_work/maxtext/maxtext:/app --rm --privileged maxtext_base_image bash -c 'cd MaxText;python3 -m pytest'
77
+ - name: Test train.py with c4
78
+ run: |
79
+ docker run -v /home/runner/actions-runner/_work/maxtext/maxtext:/app --rm --privileged maxtext_base_image bash -c \
80
+ 'python3 MaxText/train.py MaxText/configs/base.yml run_name=runner_$(date +%Y-%m-%d-%H-%M)-${RANDOM} base_output_directory=gs://runner-maxtext-logs dataset_path=gs://maxtext-dataset steps=2 enable_checkpointing=false'
81
+ - name: Test train.py with synthetic data
82
+ run: |
83
+ docker run -v /home/runner/actions-runner/_work/maxtext/maxtext:/app --rm --privileged maxtext_base_image bash -c \
84
+ 'python3 MaxText/train.py MaxText/configs/base.yml run_name=runner_$(date +%Y-%m-%d-%H-%M)-${RANDOM} base_output_directory=gs://runner-maxtext-logs dataset_path=gs://maxtext-dataset steps=2 enable_checkpointing=false dataset_type=synthetic'
85
+ - name: Test train.py with per_device_batch_size < 1
86
+ run: |
87
+ docker run -v /home/runner/actions-runner/_work/maxtext/maxtext:/app --rm --privileged maxtext_base_image bash -c \
88
+ 'python3 MaxText/train.py MaxText/configs/base.yml run_name=runner_$(date +%Y-%m-%d-%H-%M)-${RANDOM} base_output_directory=gs://runner-maxtext-logs dataset_path=gs://maxtext-dataset steps=2 per_device_batch_size=0.25 ici_tensor_parallelism=4 enable_checkpointing=false'
89
+ - name: Test decode.py
90
+ run: |
91
+ docker run -v /home/runner/actions-runner/_work/maxtext/maxtext:/app --rm --privileged maxtext_base_image bash -c \
92
+ 'python3 MaxText/decode.py MaxText/configs/base.yml run_name=runner_$(date +%Y-%m-%d-%H-%M)-${RANDOM} base_output_directory=gs://runner-maxtext-logs dataset_path=gs://maxtext-dataset steps=2 ici_tensor_parallelism=4 attention=dot_product enable_checkpointing=false max_target_length=128 per_device_batch_size=1'
93
+ - name: Test decode.py with per_device_batch_size < 1
94
+ run: |
95
+ docker run -v /home/runner/actions-runner/_work/maxtext/maxtext:/app --rm --privileged maxtext_base_image bash -c \
96
+ 'python3 MaxText/decode.py MaxText/configs/base.yml run_name=runner_$(date +%Y-%m-%d-%H-%M)-${RANDOM} base_output_directory=gs://runner-maxtext-logs dataset_path=gs://maxtext-dataset steps=2 ici_tensor_parallelism=4 attention=dot_product enable_checkpointing=false max_target_length=128 per_device_batch_size=.25'
97
+ - name: Test standalone_dataloader.py
98
+ run: |
99
+ docker run -v /home/runner/actions-runner/_work/maxtext/maxtext:/app --rm --privileged maxtext_base_image bash -c \
100
+ 'python3 MaxText/standalone_dataloader.py MaxText/configs/base.yml run_name=standalone_dataloader_$(date +%Y-%m-%d-%H-%M)-${RANDOM} base_output_directory=gs://runner-maxtext-logs dataset_path=gs://maxtext-dataset steps=100 enable_checkpointing=false'
101
+ - name: Test standalone_checkpointer.py
102
+ run: |
103
+ docker run -v /home/runner/actions-runner/_work/maxtext/maxtext:/app --rm --privileged maxtext_base_image bash -c \
104
+ 'python3 MaxText/standalone_checkpointer.py MaxText/configs/base.yml run_name=standalone_checkpointer_$(date +%Y-%m-%d-%H-%M)-${RANDOM} base_output_directory=gs://runner-maxtext-logs dataset_path=gs://maxtext-dataset steps=200 checkpoint_period=50 enable_checkpointing=True async_checkpointing=False'
105
+ - name: Test int8_training
106
+ run: |
107
+ docker run -v /home/runner/actions-runner/_work/maxtext/maxtext:/app --rm --privileged maxtext_base_image bash -c \
108
+ 'python3 MaxText/train.py MaxText/configs/base.yml run_name=runner_$(date +%Y-%m-%d-%H-%M)-${RANDOM} base_output_directory=gs://runner-maxtext-logs dataset_path=gs://maxtext-dataset quantization=int8 steps=2 enable_checkpointing=false'
109
+ - name: Test generate_param_only_checkpoint
110
+ run: |
111
+ docker run -v /home/runner/actions-runner/_work/maxtext/maxtext:/app --rm --privileged maxtext_base_image bash -c \
112
+ 'bash end_to_end/test_generate_param_only_checkpoint.sh -r runner_$(date +%Y-%m-%d-%H-%M)-${RANDOM} -o gs://runner-maxtext-logs -d gs://maxtext-dataset -i 4'
113
+ - name: Test grain checkpoint determinism
114
+ run: |
115
+ docker run -v /home/runner/actions-runner/_work/maxtext/maxtext:/app --rm --privileged maxtext_base_image bash -c \
116
+ 'bash end_to_end/test_checkpointing.sh runner gs://runner-maxtext-logs gs://maxtext-dataset False c4-array_record'
117
+ - name: Test checkpoint compatibility
118
+ run: |
119
+ docker run -v /home/runner/actions-runner/_work/maxtext/maxtext:/app --rm --privileged maxtext_base_image bash -c \
120
+ 'bash end_to_end/test_checkpoint_compatibility.sh runner gs://runner-maxtext-logs gs://maxtext-dataset'
121
+ - name: Validate Pedagogical Example, Shmap_collective_matmul
122
+ run: |
123
+ docker run -v /home/runner/actions-runner/_work/maxtext/maxtext:/app --rm --privileged maxtext_base_image bash -c \
124
+ 'python3 pedagogical_examples/shmap_collective_matmul.py'
125
+
126
+ # IF YOU MODIFY THIS, YOU SHOULD ALSO ADD CORRESPONDING MODICATIONS TO 'tpu' job
127
+ gpu:
128
+ strategy:
129
+ fail-fast: false
130
+ matrix:
131
+ device-type: ["a100-40gb-4"]
132
+ name: "GPU test (${{ matrix.device-type }})"
133
+ runs-on: ["self-hosted", "gpu", "${{ matrix.device-type }}"]
134
+ steps:
135
+ - uses: actions/checkout@v3
136
+ - name: Cleanup old docker images
137
+ run: |
138
+ docker system prune --all --force
139
+ - name: Install dependencies
140
+ run: |
141
+ bash docker_build_dependency_image.sh DEVICE=gpu
142
+ - name: Test gsutil installation
143
+ run: |
144
+ docker run --runtime=nvidia --gpus all -v /home/runner/actions-runner/_work/maxtext/maxtext:/app --rm --privileged maxtext_base_image bash -c \
145
+ 'which gsutil >/dev/null 2>&1 || { echo >&2 "gsutil is required but not installed. Aborting"; exit 24;}'
146
+ - name: Test with pytest
147
+ run: |
148
+ docker run -e XLA_PYTHON_CLIENT_MEM_FRACTION=0.65 -e TF_FORCE_GPU_ALLOW_GROWTH=true --shm-size=2g --runtime=nvidia --gpus all -v /home/runner/actions-runner/_work/maxtext/maxtext:/app --rm --privileged maxtext_base_image bash -c 'cd MaxText;python3 -m pytest -m "not tpu"'
149
+ - name: Test train.py
150
+ run: |
151
+ docker run -e XLA_PYTHON_CLIENT_MEM_FRACTION=0.65 -e TF_FORCE_GPU_ALLOW_GROWTH=true --shm-size=2g --runtime=nvidia --gpus all -v /home/runner/actions-runner/_work/maxtext/maxtext:/app --rm --privileged maxtext_base_image bash -c \
152
+ 'python3 MaxText/train.py MaxText/configs/base.yml run_name=runner_$(date +%Y-%m-%d-%H-%M)-${RANDOM} base_output_directory=gs://runner-maxtext-logs dataset_path=gs://maxtext-dataset steps=2 enable_checkpointing=false attention=dot_product'
153
+ - name: Test train.py with per_device_batch_size < 1
154
+ run: |
155
+ docker run -e XLA_PYTHON_CLIENT_MEM_FRACTION=0.65 -e TF_FORCE_GPU_ALLOW_GROWTH=true --shm-size=2g --runtime=nvidia --gpus all -v /home/runner/actions-runner/_work/maxtext/maxtext:/app --rm --privileged maxtext_base_image bash -c \
156
+ 'python3 MaxText/train.py MaxText/configs/base.yml run_name=runner_$(date +%Y-%m-%d-%H-%M)-${RANDOM} base_output_directory=gs://runner-maxtext-logs dataset_path=gs://maxtext-dataset steps=2 per_device_batch_size=0.25 ici_tensor_parallelism=4 enable_checkpointing=false attention=dot_product'
157
+ - name: Test int8_training
158
+ run: |
159
+ docker run -e XLA_PYTHON_CLIENT_MEM_FRACTION=0.65 -e TF_FORCE_GPU_ALLOW_GROWTH=true --shm-size=2g --runtime=nvidia --gpus all -v /home/runner/actions-runner/_work/maxtext/maxtext:/app --rm --privileged maxtext_base_image bash -c \
160
+ 'python3 MaxText/train.py MaxText/configs/base.yml run_name=runner_$(date +%Y-%m-%d-%H-%M)-${RANDOM} base_output_directory=gs://runner-maxtext-logs dataset_path=gs://maxtext-dataset quantization=int8 steps=2 enable_checkpointing=false attention=dot_product'
161
+ - name: Test decode.py
162
+ run: |
163
+ docker run -e XLA_PYTHON_CLIENT_MEM_FRACTION=0.65 -e TF_FORCE_GPU_ALLOW_GROWTH=true --shm-size=2g --runtime=nvidia --gpus all -v /home/runner/actions-runner/_work/maxtext/maxtext:/app --rm --privileged maxtext_base_image bash -c \
164
+ 'python3 MaxText/decode.py MaxText/configs/base.yml run_name=runner_$(date +%Y-%m-%d-%H-%M)-${RANDOM} base_output_directory=gs://runner-maxtext-logs dataset_path=gs://maxtext-dataset steps=2 ici_tensor_parallelism=4 attention=dot_product enable_checkpointing=false max_target_length=128 per_device_batch_size=1'
165
+ - name: Test decode.py with per_device_batch_size < 1
166
+ run: |
167
+ docker run -e XLA_PYTHON_CLIENT_MEM_FRACTION=0.65 -e TF_FORCE_GPU_ALLOW_GROWTH=true --shm-size=2g --runtime=nvidia --gpus all -v /home/runner/actions-runner/_work/maxtext/maxtext:/app --rm --privileged maxtext_base_image bash -c \
168
+ 'python3 MaxText/decode.py MaxText/configs/base.yml run_name=runner_$(date +%Y-%m-%d-%H-%M)-${RANDOM} base_output_directory=gs://runner-maxtext-logs dataset_path=gs://maxtext-dataset steps=2 ici_tensor_parallelism=4 attention=dot_product enable_checkpointing=false max_target_length=128 per_device_batch_size=.25'
maxtext-setup/maxtext/.github/workflows/UploadDockerImages.yml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2023 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions
16
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
17
+
18
+ name: Build Images
19
+
20
+ on:
21
+ schedule:
22
+ # Run the job daily at 7PM PST (3AM UTC)
23
+ - cron: '0 3 * * *'
24
+
25
+ jobs:
26
+ tpu:
27
+ strategy:
28
+ fail-fast: false
29
+ matrix:
30
+ device-type: ["v4-8"]
31
+ runs-on: ["self-hosted", "tpu", "${{ matrix.device-type }}"]
32
+ steps:
33
+ - uses: actions/checkout@v3
34
+ - name: build jax stable image
35
+ run : |
36
+ bash .github/workflows/build_and_upload_images.sh CLOUD_IMAGE_NAME=maxtext_jax_stable MODE=stable DEVICE=tpu PROJECT=tpu-prod-env-multipod LOCAL_IMAGE_NAME=maxtext_jax_stable
37
+ - name: build jax nightly image
38
+ run : |
39
+ bash .github/workflows/build_and_upload_images.sh CLOUD_IMAGE_NAME=maxtext_jax_nightly MODE=nightly DEVICE=tpu PROJECT=tpu-prod-env-multipod LOCAL_IMAGE_NAME=maxtext_jax_nightly
40
+ gpu:
41
+ strategy:
42
+ fail-fast: false
43
+ matrix:
44
+ device-type: ["a100-40gb-4"]
45
+ runs-on: ["self-hosted", "gpu", "${{ matrix.device-type }}"]
46
+ steps:
47
+ - uses: actions/checkout@v3
48
+ - name: build jax stable image
49
+ run : |
50
+ bash .github/workflows/build_and_upload_images.sh CLOUD_IMAGE_NAME=maxtext_gpu_jax_stable MODE=stable DEVICE=gpu PROJECT=tpu-prod-env-multipod LOCAL_IMAGE_NAME=maxtext_gpu_local_jax_stable
51
+ - name: build jax nightly image
52
+ run : |
53
+ bash .github/workflows/build_and_upload_images.sh CLOUD_IMAGE_NAME=maxtext_gpu_jax_nightly MODE=nightly DEVICE=gpu PROJECT=tpu-prod-env-multipod LOCAL_IMAGE_NAME=maxtext_gpu_local_jax_nightly
maxtext-setup/maxtext/.github/workflows/build_and_upload_images.sh ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Copyright 2023 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # This script builds and uploads two images - one with only dependencies, the other also has a code snapshot.
18
+ # These images are tagged in GCR with both "latest" and date in format YYYY-MM-DD via $(date +%Y-%m-%d)
19
+
20
+ # This script wraps several steps meant for the github runners to push nightly images.
21
+ # If you want to create and push your own images you should instead use docker_build_dependency_image and
22
+ # docker_upload_runner in the maxtext root directory.
23
+
24
+ # Example command:
25
+ # bash build_and_upload_images.sh PROJECT=<project> MODE=stable DEVICE=tpu CLOUD_IMAGE_NAME=${USER}_runner
26
+
27
+
28
+ export LOCAL_IMAGE_NAME=maxtext_base_image
29
+
30
+ # Set environment variables
31
+ for ARGUMENT in "$@"; do
32
+ IFS='=' read -r KEY VALUE <<< "$ARGUMENT"
33
+ export "$KEY"="$VALUE"
34
+ echo "$KEY"="$VALUE"
35
+ done
36
+
37
+ if [[ ! -v CLOUD_IMAGE_NAME ]] || [[ ! -v PROJECT ]] || [[ ! -v MODE ]] || [[ ! -v DEVICE ]]; then
38
+ echo "You must set CLOUD_IMAGE_NAME, PROJECT, MODE, and DEVICE"
39
+ exit 1
40
+ fi
41
+
42
+ bash docker_build_dependency_image.sh LOCAL_IMAGE_NAME=$LOCAL_IMAGE_NAME MODE=$MODE DEVICE=$DEVICE
43
+ gcloud auth configure-docker --quiet
44
+ image_date=$(date +%Y-%m-%d)
45
+
46
+ # Upload only dependencies image
47
+ dependency_image_name=${CLOUD_IMAGE_NAME}_dependencies
48
+ docker tag ${LOCAL_IMAGE_NAME} gcr.io/$PROJECT/${dependency_image_name}:latest
49
+ docker push gcr.io/$PROJECT/${dependency_image_name}:latest
50
+ docker tag ${LOCAL_IMAGE_NAME} gcr.io/$PROJECT/${dependency_image_name}:${image_date}
51
+ docker push gcr.io/$PROJECT/${dependency_image_name}:${image_date}
52
+
53
+ # Build then upload "dependencies + code" image
54
+ docker build --build-arg BASEIMAGE=${LOCAL_IMAGE_NAME} -f ./maxtext_runner.Dockerfile -t ${LOCAL_IMAGE_NAME}_runner .
55
+ docker tag ${LOCAL_IMAGE_NAME}_runner gcr.io/$PROJECT/${CLOUD_IMAGE_NAME}:latest
56
+ docker push gcr.io/$PROJECT/${CLOUD_IMAGE_NAME}:latest
57
+ docker tag ${LOCAL_IMAGE_NAME}_runner gcr.io/$PROJECT/${CLOUD_IMAGE_NAME}:${image_date}
58
+ docker push gcr.io/$PROJECT/${CLOUD_IMAGE_NAME}:${image_date}
maxtext-setup/maxtext/.github/workflows/utils/setup_runner.sh ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Copyright 2022 The JAX Authors.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Heavily influenced by
18
+ # https://github.com/openxla/iree/tree/main/build_tools/github_actions/runner/config
19
+
20
+ # This file sets up a tpu vm to be used as a github runner for testing.
21
+ # It creates a user runner without sudo permissions to
22
+ # run the config file and authenticate to github
23
+
24
+
25
+ set -eux
26
+
27
+ if [ "$#" -ne 4 ]; then
28
+ echo "Usage: setup_runner.sh <runner name> <tags> <github token> <repo_url>"
29
+ fi
30
+
31
+ runner_name="$1"
32
+ runner_tags="$2"
33
+ runner_token="$3"
34
+ repo_url="$4"
35
+
36
+
37
+ # Create `runner` user. This user won't have sudo access unless you ssh into the
38
+ # GCP VM as `runner` using gcloud. Don't do that!
39
+ sudo useradd runner -m
40
+ ORIGIN_USER=${USER}
41
+ # Find the latest actions-runner download. The runner will automatically update
42
+ # itself when new versions are released. Github requires that all self-hosted
43
+ # runners are updated to the latest version within 30 days of release
44
+ # (https://docs.github.com/en/actions/hosting-your-own-runners/autoscaling-with-self-hosted-runners#controlling-runner-software-updates-on-self-hosted-runners).
45
+ # Example URL:
46
+ # https://github.com/actions/runner/releases/download/v2.298.2/actions-runner-linux-x64-2.298.2.tar.gz
47
+ actions_runner_download_regexp='https://github.com/actions/runner/releases/'\
48
+ 'download/v[0-9.]\+/actions-runner-linux-x64-[0-9.]\+\.tar\.gz'
49
+ # Use `head -n 1` because there are multiple instances of the same URL
50
+ actions_runner_download=$(
51
+ curl -s -X GET 'https://api.github.com/repos/actions/runner/releases/latest' |
52
+ grep -o "${actions_runner_download_regexp}" |
53
+ head -n 1)
54
+ echo "actions_runner_download: ${actions_runner_download}"
55
+
56
+ # Run the rest of the setup as `runner`.
57
+ #
58
+ # Note that env vars in the heredoc will be expanded according to the _calling_
59
+ # environment, not the `runner` environment we're creating -- it acts like a
60
+ # double-quoted string. This is how variables like $runner_name are inserted
61
+ # without using sudo -E (which would cause the current environment to be
62
+ # inherited). This also means we must be careful to escape any variables that
63
+ # we'd like to evaluate in the `runner` environment, e.g. $HOME.
64
+ sudo -i -u runner bash -ex <<EOF
65
+ cd ~/
66
+
67
+ mkdir actions-runner && cd actions-runner
68
+ curl -o actions-runner-linux-x64.tar.gz -L ${actions_runner_download}
69
+ tar xzf ./actions-runner-linux-x64.tar.gz
70
+ # Register the runner with Github
71
+ ./config.sh --unattended \
72
+ --url ${repo_url} \
73
+ --labels ${runner_tags} \
74
+ --token ${runner_token} \
75
+ --name ${runner_name}
76
+
77
+ EOF
maxtext-setup/maxtext/.gitignore ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *__pycache__*
2
+ tmp/
3
+
4
+ # Byte-compiled / optimized / DLL files
5
+ __pycache__/
6
+ *.py[cod]
7
+ *$py.class
8
+
9
+ # C extensions
10
+ *.so
11
+
12
+ # Distribution / packaging
13
+ .Python
14
+ build/
15
+ develop-eggs/
16
+ dist/
17
+ downloads/
18
+ eggs/
19
+ .eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ wheels/
26
+ pip-wheel-metadata/
27
+ share/python-wheels/
28
+ *.egg-info/
29
+ .installed.cfg
30
+ *.egg
31
+ MANIFEST
32
+
33
+ # PyInstaller
34
+ # Usually these files are written by a python script from a template
35
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
36
+ *.manifest
37
+ *.spec
38
+
39
+ # Installer logs
40
+ pip-log.txt
41
+ pip-delete-this-directory.txt
42
+
43
+ # Unit test / coverage reports
44
+ htmlcov/
45
+ .tox/
46
+ .nox/
47
+ .coverage
48
+ .coverage.*
49
+ .cache
50
+ nosetests.xml
51
+ coverage.xml
52
+ *.cover
53
+ *.py,cover
54
+ .hypothesis/
55
+ .pytest_cache/
56
+
57
+ # Translations
58
+ *.mo
59
+ *.pot
60
+
61
+ # Django stuff:
62
+ *.log
63
+ local_settings.py
64
+ db.sqlite3
65
+ db.sqlite3-journal
66
+
67
+ # Flask stuff:
68
+ instance/
69
+ .webassets-cache
70
+
71
+ # Scrapy stuff:
72
+ .scrapy
73
+
74
+ # Sphinx documentation
75
+ docs/_build/
76
+
77
+ # PyBuilder
78
+ target/
79
+
80
+ # Jupyter Notebook
81
+ .ipynb_checkpoints
82
+
83
+ # IPython
84
+ profile_default/
85
+ ipython_config.py
86
+
87
+ # pyenv
88
+ .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
98
+ __pypackages__/
99
+
100
+ # Celery stuff
101
+ celerybeat-schedule
102
+ celerybeat.pid
103
+
104
+ # SageMath parsed files
105
+ *.sage.py
106
+
107
+ # Environments
108
+ .env
109
+ .venv
110
+ env/
111
+ venv/
112
+ ENV/
113
+ env.bak/
114
+ venv.bak/
115
+
116
+ # Spyder project settings
117
+ .spyderproject
118
+ .spyproject
119
+
120
+ # Rope project settings
121
+ .ropeproject
122
+
123
+ # mkdocs documentation
124
+ /site
125
+
126
+ # mypy
127
+ .mypy_cache/
128
+ .dmypy.json
129
+ dmypy.json
130
+
131
+ # Pyre type checker
132
+ .pyre/
133
+
134
+ # DS_Store files
135
+ **/.DS_Store
maxtext-setup/maxtext/.vscode/launch.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "version": "0.2.0",
3
+ "configurations": [
4
+ {
5
+ "name": "Debug MaxText Decode",
6
+ "type": "python",
7
+ "request": "launch",
8
+ "console": "integratedTerminal",
9
+ "justMyCode": false,
10
+ "python": "python3",
11
+ "program": "${workspaceFolder}/MaxText/decode.py",
12
+ "args": ["MaxText/configs/base.yml",
13
+ "run_name=runner_$(date +%Y-%m-%d-%H-%M)",
14
+ "base_output_directory=gs://test-maxtext-output",
15
+ "dataset_path=gs://test-maxtext-dataset",
16
+ "steps=2",
17
+ "attention=dot_product",
18
+ "enable_checkpointing=false"]
19
+ },
20
+ {
21
+ "name": "Debug MaxText Train",
22
+ "type": "python",
23
+ "request": "launch",
24
+ "console": "integratedTerminal",
25
+ "justMyCode": false,
26
+ "python": "python3",
27
+ "program": "${workspaceFolder}/MaxText/train.py",
28
+ "args": ["MaxText/configs/base.yml",
29
+ "run_name=runner_$(date +%Y-%m-%d-%H-%M)",
30
+ "base_output_directory=gs://test-maxtext-output",
31
+ "dataset_path=gs://test-maxtext-dataset",
32
+ "steps=2",
33
+ "enable_checkpointing=false"]
34
+ }
35
+ ]
36
+ }
maxtext-setup/maxtext/AUTHORS ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ Google LLC
2
+
maxtext-setup/maxtext/CONTRIBUTING.md ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # How to Contribute
2
+
3
+ We'd love to accept your patches and contributions to this project.
4
+
5
+ ## Before you begin
6
+
7
+ ### Sign our Contributor License Agreement
8
+
9
+ Contributions to this project must be accompanied by a
10
+ [Contributor License Agreement](https://cla.developers.google.com/about) (CLA).
11
+ You (or your employer) retain the copyright to your contribution; this simply
12
+ gives us permission to use and redistribute your contributions as part of the
13
+ project.
14
+
15
+ If you or your current employer have already signed the Google CLA (even if it
16
+ was for a different project), you probably don't need to do it again.
17
+
18
+ Visit <https://cla.developers.google.com/> to see your current agreements or to
19
+ sign a new one.
20
+
21
+ ### Review our Community Guidelines
22
+
23
+ This project follows
24
+ [Google's Open Source Community Guidelines](https://opensource.google/conduct/).
25
+
26
+ ## Contribution process
27
+
28
+ ### Code Reviews
29
+
30
+ All submissions, including submissions by project members, require review. We
31
+ use GitHub pull requests for this purpose. Consult
32
+ [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
33
+ information on using pull requests.
maxtext-setup/maxtext/LICENSE ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
maxtext-setup/maxtext/MaxText/__init__.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Copyright 2023 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ """
maxtext-setup/maxtext/MaxText/__pycache__/accelerator_to_spec_map.cpython-310.pyc ADDED
Binary file (7.61 kB). View file
 
maxtext-setup/maxtext/MaxText/__pycache__/checkpointing.cpython-310.pyc ADDED
Binary file (6.23 kB). View file
 
maxtext-setup/maxtext/MaxText/__pycache__/common_types.cpython-310.pyc ADDED
Binary file (778 Bytes). View file
 
maxtext-setup/maxtext/MaxText/__pycache__/max_logging.cpython-310.pyc ADDED
Binary file (848 Bytes). View file
 
maxtext-setup/maxtext/MaxText/__pycache__/max_utils.cpython-310.pyc ADDED
Binary file (22.4 kB). View file
 
maxtext-setup/maxtext/MaxText/__pycache__/maxtext_utils.cpython-310.pyc ADDED
Binary file (5.05 kB). View file
 
maxtext-setup/maxtext/MaxText/__pycache__/multihost_dataloading.cpython-310.pyc ADDED
Binary file (4.17 kB). View file
 
maxtext-setup/maxtext/MaxText/__pycache__/optimizers.cpython-310.pyc ADDED
Binary file (5.32 kB). View file
 
maxtext-setup/maxtext/MaxText/__pycache__/pyconfig.cpython-310.pyc ADDED
Binary file (13.9 kB). View file
 
maxtext-setup/maxtext/MaxText/__pycache__/sequence_packing.cpython-310.pyc ADDED
Binary file (8.22 kB). View file
 
maxtext-setup/maxtext/MaxText/__pycache__/tokenizer.cpython-310.pyc ADDED
Binary file (2.42 kB). View file
 
maxtext-setup/maxtext/MaxText/__pycache__/train.cpython-310.pyc ADDED
Binary file (15.1 kB). View file
 
maxtext-setup/maxtext/MaxText/accelerator_to_spec_map.py ADDED
@@ -0,0 +1,379 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Copyright 2023 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ """
16
+
17
+ """ Static map of TPU names such as v4-8 to properties such as chip layout."""
18
+
19
+ """ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
20
+ IF YOU MODIFY THIS FILE YOU SHOULD ALSO ADD CORRESPONDING MODICATIONS TO
21
+ UserFacingNameToSystemCharacteristics in xpk/xpk.py !!!!! """
22
+
23
+ from dataclasses import dataclass
24
+
25
+ @dataclass
26
+ class SystemCharacteristics:
27
+ platform: str
28
+ topology_name: str
29
+ chip_config_name: str # 'megacore' or 'default'
30
+ chips_per_host_bounds: tuple
31
+ devices_per_slice: int
32
+
33
+ UserFacingNameToSystemCharacteristics = {
34
+ # v5e
35
+ 'v5e-16': SystemCharacteristics(
36
+ 'tpu', 'v5e:4x4', 'default', (2, 2, 1), 16
37
+ ),
38
+ 'v5e-32': SystemCharacteristics(
39
+ 'tpu', 'v5e:4x8', 'default', (2, 2, 1), 32
40
+ ),
41
+ 'v5e-64': SystemCharacteristics(
42
+ 'tpu', 'v5e:8x8', 'default', (2, 2, 1), 64
43
+ ),
44
+ 'v5e-128': SystemCharacteristics(
45
+ 'tpu', 'v5e:8x16', 'default', (2, 2, 1), 128
46
+ ),
47
+ 'v5e-256': SystemCharacteristics(
48
+ 'tpu', 'v5e:16x16', 'default', (2, 2, 1), 256
49
+ ),
50
+ # v4
51
+ 'v4-8': SystemCharacteristics(
52
+ 'tpu', 'v4:2x2x1', 'megacore', (2, 2, 1), 4
53
+ ),
54
+ 'v4-16': SystemCharacteristics(
55
+ 'tpu', 'v4:2x2x2', 'megacore', (2, 2, 1), 8
56
+ ),
57
+ 'v4-32': SystemCharacteristics(
58
+ 'tpu', 'v4:2x2x4', 'megacore', (2, 2, 1), 16
59
+ ),
60
+ 'v4-64': SystemCharacteristics(
61
+ 'tpu', 'v4:2x4x4', 'megacore', (2, 2, 1), 32
62
+ ),
63
+ 'v4-128': SystemCharacteristics(
64
+ 'tpu', 'v4:4x4x4', 'megacore', (2, 2, 1), 64
65
+ ),
66
+ 'v4-256': SystemCharacteristics(
67
+ 'tpu', 'v4:4x4x8', 'megacore', (2, 2, 1), 128
68
+ ),
69
+ 'v4-384': SystemCharacteristics(
70
+ 'tpu', 'v4:4x4x12', 'megacore', (2, 2, 1), 192
71
+ ),
72
+ 'v4-512': SystemCharacteristics(
73
+ 'tpu', 'v4:4x8x8', 'megacore', (2, 2, 1), 256
74
+ ),
75
+ 'v4-1024': SystemCharacteristics(
76
+ 'tpu', 'v4:8x8x8', 'megacore', (2, 2, 1), 512
77
+ ),
78
+ 'v4-1536': SystemCharacteristics(
79
+ 'tpu', 'v4:8x8x12','megacore', (2, 2, 1), 768
80
+ ),
81
+ 'v4-2048': SystemCharacteristics(
82
+ 'tpu', 'v4:8x8x16','megacore', (2, 2, 1), 1024
83
+ ),
84
+ 'v4-4096': SystemCharacteristics(
85
+ 'tpu', 'v4:8x16x16', 'megacore', (2, 2, 1), 2048
86
+ ),
87
+ # v5p
88
+ 'v5p-8': SystemCharacteristics(
89
+ 'tpu', 'v5:2x2x1', 'megacore', (2, 2, 1), 4
90
+ ),
91
+ 'v5p-16': SystemCharacteristics(
92
+ 'tpu', 'v5:2x2x2', 'megacore', (2, 2, 1), 8
93
+ ),
94
+ 'v5p-32': SystemCharacteristics(
95
+ 'tpu', 'v5:2x2x4', 'megacore', (2, 2, 1), 16
96
+ ),
97
+ 'v5p-64': SystemCharacteristics(
98
+ 'tpu', 'v5:2x4x4', 'megacore', (2, 2, 1), 32
99
+ ),
100
+ 'v5p-128': SystemCharacteristics(
101
+ 'tpu', 'v5:4x4x4', 'megacore', (2, 2, 1), 64
102
+ ),
103
+ 'v5p-256': SystemCharacteristics(
104
+ 'tpu', 'v5:4x4x8', 'megacore', (2, 2, 1), 128
105
+ ),
106
+ 'v5p-384': SystemCharacteristics(
107
+ 'tpu', 'v5:4x4x12', 'megacore', (2, 2, 1), 192
108
+ ),
109
+ 'v5p-512': SystemCharacteristics(
110
+ 'tpu', 'v5:4x8x8', 'megacore', (2, 2, 1), 256
111
+ ),
112
+ 'v5p-640': SystemCharacteristics(
113
+ 'tpu', 'v5:4x4x20', 'megacore', (2, 2, 1), 320
114
+ ),
115
+ 'v5p-768': SystemCharacteristics(
116
+ 'tpu', 'v5:4x8x12', 'megacore', (2, 2, 1), 384
117
+ ),
118
+ 'v5p-896': SystemCharacteristics(
119
+ 'tpu', 'v5:4x4x28', 'megacore', (2, 2, 1), 448
120
+ ),
121
+ 'v5p-1024': SystemCharacteristics(
122
+ 'tpu', 'v5:8x8x8', 'megacore', (2, 2, 1), 512
123
+ ),
124
+ 'v5p-1152': SystemCharacteristics(
125
+ 'tpu', 'v5:4x12x12', 'megacore', (2, 2, 1), 576
126
+ ),
127
+ 'v5p-1280': SystemCharacteristics(
128
+ 'tpu', 'v5:4x8x20', 'megacore', (2, 2, 1), 640
129
+ ),
130
+ 'v5p-1408': SystemCharacteristics(
131
+ 'tpu', 'v5:4x4x44', 'megacore', (2, 2, 1), 704
132
+ ),
133
+ 'v5p-1536': SystemCharacteristics(
134
+ 'tpu', 'v5:8x8x12', 'megacore', (2, 2, 1), 768
135
+ ),
136
+ 'v5p-1664': SystemCharacteristics(
137
+ 'tpu', 'v5:4x4x52', 'megacore', (2, 2, 1), 832
138
+ ),
139
+ 'v5p-1792': SystemCharacteristics(
140
+ 'tpu', 'v5:4x8x28', 'megacore', (2, 2, 1), 896
141
+ ),
142
+ 'v5p-1920': SystemCharacteristics(
143
+ 'tpu', 'v5:4x12x20', 'megacore', (2, 2, 1), 960
144
+ ),
145
+ 'v5p-2048': SystemCharacteristics(
146
+ 'tpu', 'v5:8x8x16', 'megacore', (2, 2, 1), 1024
147
+ ),
148
+ 'v5p-2176': SystemCharacteristics(
149
+ 'tpu', 'v5:4x4x68', 'megacore', (2, 2, 1), 1088
150
+ ),
151
+ 'v5p-2304': SystemCharacteristics(
152
+ 'tpu', 'v5:8x12x12', 'megacore', (2, 2, 1), 1152
153
+ ),
154
+ 'v5p-2432': SystemCharacteristics(
155
+ 'tpu', 'v5:4x4x76', 'megacore', (2, 2, 1), 1216
156
+ ),
157
+ 'v5p-2560': SystemCharacteristics(
158
+ 'tpu', 'v5:8x8x20', 'megacore', (2, 2, 1), 1280
159
+ ),
160
+ 'v5p-2688': SystemCharacteristics(
161
+ 'tpu', 'v5:4x12x28', 'megacore', (2, 2, 1), 1344
162
+ ),
163
+ 'v5p-2816': SystemCharacteristics(
164
+ 'tpu', 'v5:4x8x44', 'megacore', (2, 2, 1), 1408
165
+ ),
166
+ 'v5p-2944': SystemCharacteristics(
167
+ 'tpu', 'v5:4x4x92', 'megacore', (2, 2, 1), 1472
168
+ ),
169
+ 'v5p-3072': SystemCharacteristics(
170
+ 'tpu', 'v5:8x12x16', 'megacore', (2, 2, 1), 1536
171
+ ),
172
+ 'v5p-3200': SystemCharacteristics(
173
+ 'tpu', 'v5:4x20x20', 'megacore', (2, 2, 1), 1600
174
+ ),
175
+ 'v5p-3328': SystemCharacteristics(
176
+ 'tpu', 'v5:4x8x52', 'megacore', (2, 2, 1), 1664
177
+ ),
178
+ 'v5p-3456': SystemCharacteristics(
179
+ 'tpu', 'v5:12x12x12', 'megacore', (2, 2, 1), 1728
180
+ ),
181
+ 'v5p-3584': SystemCharacteristics(
182
+ 'tpu', 'v5:8x8x28', 'megacore', (2, 2, 1), 1792
183
+ ),
184
+ 'v5p-3712': SystemCharacteristics(
185
+ 'tpu', 'v5:4x4x116', 'megacore', (2, 2, 1), 1856
186
+ ),
187
+ 'v5p-3840': SystemCharacteristics(
188
+ 'tpu', 'v5:8x12x20', 'megacore', (2, 2, 1), 1920
189
+ ),
190
+ 'v5p-3968': SystemCharacteristics(
191
+ 'tpu', 'v5:4x4x124', 'megacore', (2, 2, 1), 1984
192
+ ),
193
+ 'v5p-4096': SystemCharacteristics(
194
+ 'tpu', 'v5:8x16x16', 'megacore', (2, 2, 1), 2048
195
+ ),
196
+ 'v5p-4224': SystemCharacteristics(
197
+ 'tpu', 'v5:4x12x44', 'megacore', (2, 2, 1), 2112
198
+ ),
199
+ 'v5p-4352': SystemCharacteristics(
200
+ 'tpu', 'v5:4x8x68', 'megacore', (2, 2, 1), 2176
201
+ ),
202
+ 'v5p-4480': SystemCharacteristics(
203
+ 'tpu', 'v5:4x20x28', 'megacore', (2, 2, 1), 2240
204
+ ),
205
+ 'v5p-4608': SystemCharacteristics(
206
+ 'tpu', 'v5:12x12x16', 'megacore', (2, 2, 1), 2304
207
+ ),
208
+ 'v5p-4736': SystemCharacteristics(
209
+ 'tpu', 'v5:4x4x148', 'megacore', (2, 2, 1), 2368
210
+ ),
211
+ 'v5p-4864': SystemCharacteristics(
212
+ 'tpu', 'v5:4x8x76', 'megacore', (2, 2, 1), 2432
213
+ ),
214
+ 'v5p-4992': SystemCharacteristics(
215
+ 'tpu', 'v5:4x12x52', 'megacore', (2, 2, 1), 2496
216
+ ),
217
+ 'v5p-5120': SystemCharacteristics(
218
+ 'tpu', 'v5:8x16x20', 'megacore', (2, 2, 1), 2560
219
+ ),
220
+ 'v5p-5248': SystemCharacteristics(
221
+ 'tpu', 'v5:4x4x164', 'megacore', (2, 2, 1), 2624
222
+ ),
223
+ 'v5p-5376': SystemCharacteristics(
224
+ 'tpu', 'v5:8x12x28', 'megacore', (2, 2, 1), 2688
225
+ ),
226
+ 'v5p-5504': SystemCharacteristics(
227
+ 'tpu', 'v5:4x4x172', 'megacore', (2, 2, 1), 2752
228
+ ),
229
+ 'v5p-5632': SystemCharacteristics(
230
+ 'tpu', 'v5:8x8x44', 'megacore', (2, 2, 1), 2816
231
+ ),
232
+ 'v5p-5760': SystemCharacteristics(
233
+ 'tpu', 'v5:12x12x20', 'megacore', (2, 2, 1), 2880
234
+ ),
235
+ 'v5p-5888': SystemCharacteristics(
236
+ 'tpu', 'v5:4x8x92', 'megacore', (2, 2, 1), 2944
237
+ ),
238
+ 'v5p-6016': SystemCharacteristics(
239
+ 'tpu', 'v5:4x4x188', 'megacore', (2, 2, 1), 3008
240
+ ),
241
+ 'v5p-6144': SystemCharacteristics(
242
+ 'tpu', 'v5:12x16x16', 'megacore', (2, 2, 1), 3072
243
+ ),
244
+ 'v5p-6272': SystemCharacteristics(
245
+ 'tpu', 'v5:4x28x28', 'megacore', (2, 2, 1), 3136
246
+ ),
247
+ 'v5p-6400': SystemCharacteristics(
248
+ 'tpu', 'v5:8x20x20', 'megacore', (2, 2, 1), 3200
249
+ ),
250
+ 'v5p-6528': SystemCharacteristics(
251
+ 'tpu', 'v5:4x12x68', 'megacore', (2, 2, 1), 3264
252
+ ),
253
+ 'v5p-6656': SystemCharacteristics(
254
+ 'tpu', 'v5:8x8x52', 'megacore', (2, 2, 1), 3328
255
+ ),
256
+ 'v5p-6784': SystemCharacteristics(
257
+ 'tpu', 'v5:4x4x212', 'megacore', (2, 2, 1), 3392
258
+ ),
259
+ 'v5p-6912': SystemCharacteristics(
260
+ 'tpu', 'v5:12x12x24', 'megacore', (2, 2, 1), 3456
261
+ ),
262
+ 'v5p-7040': SystemCharacteristics(
263
+ 'tpu', 'v5:4x20x44', 'megacore', (2, 2, 1), 3520
264
+ ),
265
+ 'v5p-7168': SystemCharacteristics(
266
+ 'tpu', 'v5:8x16x28', 'megacore', (2, 2, 1), 3584
267
+ ),
268
+ 'v5p-7296': SystemCharacteristics(
269
+ 'tpu', 'v5:4x12x76', 'megacore', (2, 2, 1), 3648
270
+ ),
271
+ 'v5p-7424': SystemCharacteristics(
272
+ 'tpu', 'v5:4x8x116', 'megacore', (2, 2, 1), 3712
273
+ ),
274
+ 'v5p-7552': SystemCharacteristics(
275
+ 'tpu', 'v5:4x4x236', 'megacore', (2, 2, 1), 3776
276
+ ),
277
+ 'v5p-7680': SystemCharacteristics(
278
+ 'tpu', 'v5:12x16x20', 'megacore', (2, 2, 1), 3840
279
+ ),
280
+ 'v5p-7808': SystemCharacteristics(
281
+ 'tpu', 'v5:4x4x244', 'megacore', (2, 2, 1), 3904
282
+ ),
283
+ 'v5p-7936': SystemCharacteristics(
284
+ 'tpu', 'v5:4x8x124', 'megacore', (2, 2, 1), 3968
285
+ ),
286
+ 'v5p-8064': SystemCharacteristics(
287
+ 'tpu', 'v5:12x12x28', 'megacore', (2, 2, 1), 4032
288
+ ),
289
+ 'v5p-8192': SystemCharacteristics(
290
+ 'tpu', 'v5:16x16x16', 'megacore', (2, 2, 1), 4096
291
+ ),
292
+ 'v5p-8320': SystemCharacteristics(
293
+ 'tpu', 'v5:4x20x52', 'megacore', (2, 2, 1), 4160
294
+ ),
295
+ 'v5p-8448': SystemCharacteristics(
296
+ 'tpu', 'v5:8x12x44', 'megacore', (2, 2, 1), 4224
297
+ ),
298
+ 'v5p-8704': SystemCharacteristics(
299
+ 'tpu', 'v5:8x8x68', 'megacore', (2, 2, 1), 4352
300
+ ),
301
+ 'v5p-8832': SystemCharacteristics(
302
+ 'tpu', 'v5:4x12x92', 'megacore', (2, 2, 1), 4416
303
+ ),
304
+ 'v5p-8960': SystemCharacteristics(
305
+ 'tpu', 'v5:8x20x28', 'megacore', (2, 2, 1), 4480
306
+ ),
307
+ 'v5p-9216': SystemCharacteristics(
308
+ 'tpu', 'v5:12x16x24', 'megacore', (2, 2, 1), 4608
309
+ ),
310
+ 'v5p-9472': SystemCharacteristics(
311
+ 'tpu', 'v5:4x8x148', 'megacore', (2, 2, 1), 4736
312
+ ),
313
+ 'v5p-9600': SystemCharacteristics(
314
+ 'tpu', 'v5:12x20x20', 'megacore', (2, 2, 1), 4800
315
+ ),
316
+ 'v5p-9728': SystemCharacteristics(
317
+ 'tpu', 'v5:8x8x76', 'megacore', (2, 2, 1), 4864
318
+ ),
319
+ 'v5p-9856': SystemCharacteristics(
320
+ 'tpu', 'v5:4x28x44', 'megacore', (2, 2, 1), 4928
321
+ ),
322
+ 'v5p-9984': SystemCharacteristics(
323
+ 'tpu', 'v5:8x12x52', 'megacore', (2, 2, 1), 4992
324
+ ),
325
+ 'v5p-10240': SystemCharacteristics(
326
+ 'tpu', 'v5:16x16x20', 'megacore', (2, 2, 1), 5120
327
+ ),
328
+ 'v5p-10368': SystemCharacteristics(
329
+ 'tpu', 'v5:12x12x36', 'megacore', (2, 2, 1), 5184
330
+ ),
331
+ 'v5p-10496': SystemCharacteristics(
332
+ 'tpu', 'v5:4x8x164', 'megacore', (2, 2, 1), 5248
333
+ ),
334
+ 'v5p-10752': SystemCharacteristics(
335
+ 'tpu', 'v5:12x16x28', 'megacore', (2, 2, 1), 5376
336
+ ),
337
+ 'v5p-10880': SystemCharacteristics(
338
+ 'tpu', 'v5:4x20x68', 'megacore', (2, 2, 1), 5440
339
+ ),
340
+ 'v5p-11008': SystemCharacteristics(
341
+ 'tpu', 'v5:4x8x172', 'megacore', (2, 2, 1), 5504
342
+ ),
343
+ 'v5p-11136': SystemCharacteristics(
344
+ 'tpu', 'v5:4x12x116', 'megacore', (2, 2, 1), 5568
345
+ ),
346
+ 'v5p-11264': SystemCharacteristics(
347
+ 'tpu', 'v5:8x16x44', 'megacore', (2, 2, 1), 5632
348
+ ),
349
+ 'v5p-11520': SystemCharacteristics(
350
+ 'tpu', 'v5:12x20x24', 'megacore', (2, 2, 1), 5760
351
+ ),
352
+ 'v5p-11648': SystemCharacteristics(
353
+ 'tpu', 'v5:4x28x52', 'megacore', (2, 2, 1), 5824
354
+ ),
355
+ 'v5p-11776': SystemCharacteristics(
356
+ 'tpu', 'v5:8x8x92', 'megacore', (2, 2, 1), 5888
357
+ ),
358
+ 'v5p-11904': SystemCharacteristics(
359
+ 'tpu', 'v5:4x12x124', 'megacore', (2, 2, 1), 5952
360
+ ),
361
+ 'v5p-12032': SystemCharacteristics(
362
+ 'tpu', 'v5:4x8x188', 'megacore', (2, 2, 1), 6016
363
+ ),
364
+ 'v5p-12160': SystemCharacteristics(
365
+ 'tpu', 'v5:4x20x76', 'megacore', (2, 2, 1), 6080
366
+ ),
367
+ 'v5p-12288': SystemCharacteristics(
368
+ 'tpu', 'v5:16x16x24', 'megacore', (2, 2, 1), 6144
369
+ ),
370
+ 'v5p-13824': SystemCharacteristics(
371
+ 'tpu', 'v5:12x24x24', 'megacore', (2, 2, 1), 6912
372
+ ),
373
+ 'v5p-17920': SystemCharacteristics(
374
+ 'tpu', 'v5:16x20x28', 'megacore', (2, 2, 1), 8960
375
+ ),
376
+ }
377
+
378
+ def get_system_characteristics(user_facing_name):
379
+ return UserFacingNameToSystemCharacteristics.get(user_facing_name)
maxtext-setup/maxtext/MaxText/checkpointing.py ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Copyright 2023 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ """
16
+
17
+ """Create an Orbax CheckpointManager with specified (Async or not) Checkpointer."""
18
+
19
+ from typing import Optional, Union
20
+ from etils import epath
21
+ from orbax.checkpoint.checkpoint_manager import CheckpointManager, CheckpointManagerOptions
22
+ import jax
23
+ import numpy as np
24
+ import orbax.checkpoint
25
+ import grain.python as grain
26
+
27
+ import max_logging
28
+ from multihost_dataloading import MultiHostDataLoadIterator
29
+ from flax.training import train_state
30
+
31
+ def create_orbax_checkpoint_manager(
32
+ checkpoint_dir: str,
33
+ enable_checkpointing: bool,
34
+ use_async: bool,
35
+ save_interval_steps: int,
36
+ dataset_type: Optional[str] = 'c4'
37
+ ):
38
+ """Returns specified Orbax (async or not) CheckpointManager or None if checkpointing is disabled."""
39
+ if not enable_checkpointing:
40
+ max_logging.log("Checkpointing disabled, not creating checkpoint manager.")
41
+ return None
42
+ max_logging.log("Creating checkpoint manager...")
43
+ p = epath.Path(checkpoint_dir)
44
+
45
+ if dataset_type=='c4-array_record':
46
+ item_names = ('items', 'iter')
47
+ else:
48
+ item_names = ('items',)
49
+
50
+ mngr = CheckpointManager(
51
+ p,
52
+ item_names = item_names,
53
+ options = CheckpointManagerOptions(
54
+ create=True,
55
+ save_interval_steps=save_interval_steps,
56
+ enable_async_checkpointing=use_async,
57
+ )
58
+ )
59
+ max_logging.log("Checkpoint manager created!")
60
+ return mngr
61
+
62
+
63
+ def _find_idx(array: np.ndarray, replica_axis_idx: int):
64
+ """Returns the index along given dimension that the current host belongs to."""
65
+ idx = None
66
+ for idx, val in np.ndenumerate(array):
67
+ if val.process_index == jax.process_index():
68
+ break
69
+ return idx[replica_axis_idx]
70
+
71
+
72
+ def _replica_devices(device_array: np.ndarray, replica_axis_idx: int):
73
+ """Returns the devices from the replica that current host belongs to.
74
+
75
+ Replicas are assumed to be restricted to the first axis.
76
+
77
+ Args:
78
+ device_array: devices of the mesh that can be obtained by mesh.devices()
79
+ replica_axis_idx: axis dimension along which replica is taken
80
+
81
+ Returns:
82
+ devices inside the replica that current host is in
83
+ """
84
+ idx = _find_idx(device_array, replica_axis_idx)
85
+ replica_result = np.take(device_array,
86
+ idx,
87
+ axis=replica_axis_idx)
88
+ return np.expand_dims(replica_result, axis=replica_axis_idx)
89
+
90
+
91
+ def load_state_if_possible(checkpoint_manager: CheckpointManager,
92
+ data_iterator: Union[MultiHostDataLoadIterator, None],
93
+ load_parameters_from_path: str,
94
+ load_full_state_from_path: str,
95
+ abstract_unboxed_pre_state: train_state.TrainState,
96
+ enable_single_replica_ckpt_restoring: Optional[bool] = False,
97
+ dataset_type: Optional[str] = 'c4'):
98
+ """Loads TrainState as possible from the inputs.
99
+
100
+ Args:
101
+ checkpoint_manager: if the checkpoint_manager has a valid checkpoint, return
102
+ that TrainState. This enables a full reload of a run in progress.
103
+ load_parameters_from_path: if there is no checkpoint in the checkpoint manager,
104
+ load parameters from a parameter only checkpoint at this path.
105
+ load_full_state_from_path: if there is no checkpoint in the checkpoint manager,
106
+ load full state from a full state checkpoint at this path.
107
+ abstract_unboxed_pre_state: an unboxed, abstract TrainState that Orbax
108
+ matches type against.
109
+ enable_single_replica_ckpt_restoring: bool flag for restoring checkpoitn
110
+ with SingleReplicaArrayHandler
111
+
112
+ Returns:
113
+ A tuple of (train_state, train_state_params) where full_train_state captures
114
+ a full reload and train_state_params just the params for a partial reload.
115
+ At most one will be non-None. Both can be None if neither checkpoint is
116
+ set.
117
+ """
118
+
119
+ if checkpoint_manager is not None:
120
+ max_logging.log("checkpoint manager exists so trying to load this run's existing checkpoint")
121
+
122
+ latest_step = checkpoint_manager.latest_step()
123
+ if latest_step is not None:
124
+ max_logging.log(f"restoring from this run's directory latest step \
125
+ {latest_step}")
126
+
127
+ def map_to_pspec(data):
128
+ pspec = data.sharding.spec
129
+ mesh = data.sharding.mesh
130
+ if not enable_single_replica_ckpt_restoring:
131
+ return orbax.checkpoint.type_handlers.ArrayRestoreArgs(mesh=mesh, mesh_axes=pspec)
132
+ orbax.checkpoint.type_handlers.register_type_handler(
133
+ jax.Array,
134
+ orbax.checkpoint.type_handlers.SingleReplicaArrayHandler(),
135
+ override=True)
136
+ orbax.checkpoint.type_handlers.register_type_handler(
137
+ jax.Array,
138
+ orbax.checkpoint.type_handlers.SingleReplicaArrayHandler(),
139
+ override=True)
140
+ replica_axis_index = 0 # for maxtext data is the first dimension
141
+ replica_devices = _replica_devices(mesh.devices, replica_axis_index)
142
+ replica_mesh = jax.sharding.Mesh(replica_devices, mesh.axis_names)
143
+ single_replica_sharding = jax.sharding.NamedSharding(replica_mesh, pspec)
144
+ return orbax.checkpoint.type_handlers.SingleReplicaArrayRestoreArgs(
145
+ sharding=jax.sharding.NamedSharding(mesh, pspec),
146
+ single_replica_sharding=single_replica_sharding,
147
+ replica_axis_index=replica_axis_index,
148
+ global_shape=data.shape,
149
+ dtype=data.dtype,
150
+ )
151
+
152
+ restore_args = jax.tree_util.tree_map(map_to_pspec,
153
+ abstract_unboxed_pre_state,
154
+ )
155
+ if dataset_type == 'c4-array_record' and data_iterator is not None:
156
+ return checkpoint_manager.restore(
157
+ latest_step,
158
+ args=orbax.checkpoint.args.Composite(
159
+ items=orbax.checkpoint.args.PyTreeRestore(
160
+ item=abstract_unboxed_pre_state,
161
+ restore_args=restore_args),
162
+ iter=grain.PyGrainCheckpointRestore(data_iterator.local_iterator))
163
+ ), None
164
+ else:
165
+ return (
166
+ checkpoint_manager.restore(
167
+ latest_step,
168
+ args=orbax.checkpoint.args.Composite(
169
+ items=orbax.checkpoint.args.PyTreeRestore(
170
+ item=abstract_unboxed_pre_state,
171
+ restore_args=restore_args)
172
+ ),
173
+ ),
174
+ None)
175
+
176
+ if load_parameters_from_path != "":
177
+ max_logging.log(f"restoring params from {load_parameters_from_path=}")
178
+ p = epath.Path(load_parameters_from_path)
179
+ ckptr = orbax.checkpoint.PyTreeCheckpointer()
180
+ restore_args = orbax.checkpoint.checkpoint_utils.construct_restore_args(abstract_unboxed_pre_state.params)
181
+ restored = ckptr.restore(p, item = {'params': abstract_unboxed_pre_state.params}, transforms={},
182
+ restore_args = {'params': restore_args})
183
+
184
+ return None, restored['params']
185
+
186
+ elif load_full_state_from_path != "":
187
+ max_logging.log(f"restoring full state from {load_full_state_from_path=}")
188
+ p = epath.Path(load_full_state_from_path)
189
+ ckptr = orbax.checkpoint.StandardCheckpointer()
190
+ restored = ckptr.restore(p, args=orbax.checkpoint.args.StandardRestore(abstract_unboxed_pre_state))
191
+ return {'items': restored}, None
192
+
193
+ else:
194
+ max_logging.log("No existing checkpoints found, not restoring checkpoint.")
195
+ return None, None
maxtext-setup/maxtext/MaxText/common_types.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2023 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """Common types."""
16
+
17
+ from typing import Any, Sequence
18
+
19
+ from flax.linen import partitioning
20
+ import jax
21
+ import jax.numpy as jnp
22
+
23
+ Config = Any
24
+
25
+ Array = jnp.ndarray
26
+ PRNGKey = jnp.ndarray
27
+ DType = jnp.dtype
28
+ Shape = Sequence[int]
29
+
30
+ Mesh = jax.sharding.Mesh
31
+ ScanIn = partitioning.ScanIn
32
+
33
+ AxisNames = tuple[str, ...]
34
+
35
+ BATCH = 'activation_batch'
36
+ LENGTH = 'activation_length'
37
+ HEAD = 'activation_heads'
38
+ D_KV = 'activation_kv'
39
+
40
+ MODEL_MODE_AUTOREGRESSIVE = 'autoregressive'
41
+ MODEL_MODE_PREFILL = 'prefill'
42
+ MODEL_MODE_TRAIN = 'train'
43
+
44
+ DECODING_ACTIVE_SEQUENCE_INDICATOR = 1
maxtext-setup/maxtext/MaxText/configs/README.md ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ Copyright 2023 Google LLC
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ https://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ -->
16
+
17
+ # High Performance Model Configs
18
+ This directory contains high performance model configurations for different generations of TPU hardware.
19
+
20
+ These configurations do 3 things:
21
+ * Sets various XLA compiler flags as `LIBTPU_INIT_ARGS` to optimize runtime performance.
22
+ * Runs [rto_setup.sh](https://github.com/google/maxtext/blob/main/rto_setup.sh) to optimize communication protocols for network performance.
23
+ (This only needs to be run once on each worker)
24
+ * Runs [train.py](https://github.com/google/maxtext/blob/main/MaxText/train.py) with specific hyper-parameters (batch size, etc.)
25
+
26
+
27
+ ## Reproduction Instructions
28
+
29
+ ### Create a custom MTU network
30
+ 1. Create a custom MTU network to optimize network performance and give it firewall rules. If you are unable to complete this step, you may skip it. This step is not necessary, and is only for improving performance when running on a Multislice setup.
31
+
32
+ Create a network with an MTU of 8896 bytes and set up firewall rules. (Creating a network requires `compute.networks.create` permission in your project)
33
+ ```
34
+ gcloud compute networks create mtu9k --mtu=8896 --project=${PROJECT} --subnet-mode=auto --bgp-routing-mode=regional
35
+ ```
36
+ ```
37
+ gcloud compute firewall-rules create mtu9kfw --network mtu9k --allow tcp,icmp,udp --project=${PROJECT}
38
+ ```
39
+
40
+ When you create your TPUs, you need to indicate they should be part of this network.
41
+
42
+ Here is an example of a queued-resources request on GCE using the `--network` flag (`--network=mtu9k`).
43
+ ```
44
+ gcloud alpha compute tpus queued-resources create ${QR_ID} --node-prefix=${TPU_NAME} --node-count=${NUM_SLICES} --accelerator_type=${ACCELERATOR_TYPE} --runtime_version=${RUNTIME_VERSION} --network=mtu9k --project=${PROJECT} --zone=${ZONE}
45
+ ```
46
+ Note: If you want to use only one slice, you need to replace node-prefix with node-id, and remove node-count.
47
+
48
+ Here is an example of creating a GKE cluster with XPK using the `--network` and `--subnetwork` flags (`--network=mtu9k --subnetwork=mtu9k`).
49
+ ```
50
+ export CLUSTER_ARGUMENTS="--network=mtu9k --subnetwork=mtu9k"
51
+
52
+ python3 xpk/xpk.py cluster create --cluster ${YOUR_CLUSTER_NAME} --tpu-type ${ACCELERATOR_TYPE} --num-slices ${NUM_SLICES} --custom-cluster-arguments="${CLUSTER_ARGUMENTS}"
53
+ ```
54
+
55
+ ### Run model config scripts on TPUs
56
+ 1. You can run these model configs on the GCE platform using `multihost_runner.py` or `multihost_job.py`, or on the GKE platform using [XPK](https://github.com/google/xpk). Take a look at the [getting_started](https://github.com/google/maxtext/tree/main/getting_started) directory for directions on how to set up your TPUs and use these tools.
57
+
58
+ 2. Here are some example commands to run the model configs:
59
+
60
+ Running with `multihost_runner.py` on GCE:
61
+ ```
62
+ python3 multihost_runner.py --TPU_PREFIX=${TPU_PREFIX} --COMMAND="bash setup.sh && bash MaxText/configs/v5p/128b.sh RUN_NAME=${YOUR_RUN_NAME} OUTPUT_PATH=${MAXTEXT_OUTPUT_PATH} DATASET_PATH=${MAXTEXT_DATASET_PATH} PLATFORM=gce"
63
+ ```
64
+
65
+ Running with `multihost_job.py` on GCE:
66
+ ```
67
+ python3 multihost_job.py --NUM_SLICES=${NUM_SLICES} --TPU_TYPE=${ACCELERATOR_TYPE} --VERSION=${RUNTIME_VERSION} --RUN_NAME=${RUN_NAME} --BUCKET_NAME=${GCS_BUCKET_NAME} --COMMAND="bash setup.sh && bash MaxText/configs/v5p/128b.sh RUN_NAME=${YOUR_RUN_NAME} OUTPUT_PATH=${MAXTEXT_OUTPUT_PATH} DATASET_PATH=${MAXTEXT_DATASET_PATH} PLATFORM=gce"
68
+
69
+ # Add --CQR_EXTRA_ARGS="--network=mtu9k" to the command if you would like to use the custom MTU network.
70
+ ```
71
+
72
+ Running with `XPK` on GKE:
73
+ ```
74
+ xpk workload create --cluster ${YOUR_CLUSTER_NAME} --docker-image gcr.io/${PROJECT}/${YOUR_IMAGE_NAME} --workload ${YOUR_RUN_NAME} --tpu-type=${ACCELERATOR_TYPE} --num-slices=${NUM_SLICES} --command "bash MaxText/configs/v5p/128b.sh OUTPUT_PATH=${MAXTEXT_OUTPUT_PATH} DATASET_PATH=${MAXTEXT_DATASET_PATH} PLATFORM=gke"
75
+ ```
76
+
77
+ Note: When running these scripts, be sure to specify the `PLATFORM` flag with the correct platform you are running on `"gce"` or `"gke"`.
maxtext-setup/maxtext/MaxText/configs/base.yml ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2023 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # This sentinel is a reminder to choose a real run name.
16
+ # If there is already a checkpoint under this run, that checkpoint will auto-resume.
17
+ run_name: ""
18
+
19
+ model_name: "default" # override config settings to match a specific model. other than the override, nothing should use this!
20
+ normalization_layer_epsilon: 1.e-05
21
+
22
+ ################################## CHECKPOINTING ##################################
23
+ # Checkpointing makes the following choices in the following order, starting with (1):
24
+ # (1) If there is already a checkpoint for this run_name, we load the latest entire checkpoint.
25
+ # This ensures if we're resuming a run after preemption or hardware failure we lose minimum state.
26
+ # (2) Same priority and mutually exclusive -- you can't set both!
27
+ # * If load_parameters_path is set, we load a parameter only checkpoint from that path.
28
+ # * If load_full_state_path is set, we load a full state checkpoint from that path.
29
+ # (3) We don't load a checkpoint and initialize state instead!
30
+
31
+ # Loads a just parameters from a specific directory
32
+ # e.g. gs://my-base-output-directory/my-previous-run-name/checkpoints/items/NUMBER or NUMBER/items
33
+ load_parameters_path: ""
34
+ # Loads a full checkpoint including optimizer state and step count from a specific directory
35
+ # e.g. gs://my-base-output-directory/my-previous-run-name/checkpoints/items/NUMBER or NUMBER/items
36
+ load_full_state_path: ""
37
+
38
+ # If enable_checkpointing is true, an asynchronous checkpointer will be used if
39
+ # async_checkpointing is true, else a synchronous one is used. If you have
40
+ # problems with the checkpointer we recommend trying the synchronous one.
41
+ enable_checkpointing: True
42
+ async_checkpointing: True
43
+ checkpoint_period: 10_000
44
+ # enables one replica to read the ckpt then broadcast to the rest
45
+ enable_single_replica_ckpt_restoring: False
46
+
47
+ force_unroll: False # during generate_param_only_checkpoint should we unroll the loop?
48
+ ############################### END CHECKPOINTING ##################################
49
+
50
+
51
+ reuse_example_batch: 0 # for testing TPU performance, this options repeated uses the same batch.
52
+
53
+ metrics_file: "" # for testing, local file that stores scalar metrics. If empty, no metrics are written.
54
+ # If true save metrics such as loss and TFLOPS to GCS in {base_output_directory}/{run_name}/metrics/
55
+ gcs_metrics: False
56
+
57
+ # If true save config to GCS in {base_output_directory}/{run_name}/
58
+ save_config_to_gcs: False
59
+
60
+ # Activation dtypes.
61
+ dtype: "bfloat16"
62
+ quantization: "" #defaults to no quantization, i.e. bf16. possible alternative setting is 'int8'
63
+ quantize_kvcache: False
64
+
65
+ # Shard the range finding operation for quantization. By default this is set to number of slices.
66
+ quantization_local_shard_count: -1
67
+
68
+ decoder_block: "llama2" # which style of DecoderBlock to use.
69
+ # Global parameter scale needs to be a power of 2. If you want finer grained control of the model sizes
70
+ # then you should explicitly set base_embed_dim, base_num_query_heads, base_num_kv_heads,
71
+ # base_mlp_dim, base_num_decoder_layers and/or head_dim.
72
+ weight_dtype: float32
73
+ global_parameter_scale: 1
74
+ base_emb_dim: 2048
75
+ base_num_query_heads: 16
76
+ base_num_kv_heads: 16
77
+ base_mlp_dim: 7168
78
+ base_num_decoder_layers: 16
79
+ head_dim: 128
80
+ # mixture of experts (moe)
81
+ num_experts: 1
82
+ num_experts_per_tok: 1
83
+ mlp_activations: ["silu", "linear"]
84
+ dropout_rate: 0
85
+ logits_via_embedding: False
86
+ normalize_embedding_logits: True # whether to normlize pre-softmax logits if logits_via_embedding is true
87
+ logits_dot_in_fp32: True # whether to use fp32 in logits_dense or shared_embedding dot product for stability
88
+
89
+ # Choose 'remat_policy' between 'minimal', 'save_dot_except_mlpwi', 'save_dot_except_mlp', 'save_qkv_proj', 'minimal_offloaded' and 'full'.
90
+ # These options offer a trade-off between speed (fastest to slowest) and HBM usage (highest to lowest)
91
+ remat_policy: 'full'
92
+ scan_layers: True
93
+ param_scan_axis: 1
94
+ attention: 'autoselected' # Supported attention: autoselected, dot_product, flash, cudnn_flash_te
95
+
96
+ # Combine matmuls for QKV and MLP
97
+ fused_qkv: False
98
+ fused_mlp: False
99
+
100
+ record_internal_nn_metrics: 0
101
+
102
+ # Output directory
103
+ # Create a GCS bucket, e.g. my-maxtext-outputs and set this to "gs://my-maxtext-outputs/"
104
+ base_output_directory: ""
105
+
106
+ # Jax cache directory
107
+ jax_cache_dir: "~/jax_cache"
108
+
109
+ # Hardware
110
+ hardware: 'tpu' # Supported hardware types are 'tpu', 'gpu', 'gpu_multiprocess' and 'cpu'
111
+
112
+ # Parallelism
113
+ mesh_axes: ['data', 'fsdp', 'fsdp_transpose', 'sequence', 'tensor', 'autoregressive']
114
+ logical_axis_rules: [
115
+ ['activation_batch', ['data', 'fsdp', 'fsdp_transpose',]],
116
+ ['activation_heads', ['tensor','sequence']],
117
+ ['activation_length', 'sequence'],
118
+ ['activation_embed', 'tensor'],
119
+ ['activation_mlp', 'tensor'],
120
+ ['activation_kv', 'tensor'],
121
+ ['activation_vocab', ['tensor', 'sequence']],
122
+ ['activation_vocab', 'tensor'],
123
+ ['activation_vocab', 'sequence'],
124
+ ['mlp', ['fsdp_transpose', 'tensor', 'autoregressive']],
125
+ ['vocab', ['tensor', 'autoregressive']],
126
+ ['embed', ['fsdp', 'fsdp_transpose', 'sequence']],
127
+ ['embed', ['fsdp', 'sequence']],
128
+ ['heads', ['tensor', 'autoregressive']],
129
+ ['kv', []],
130
+ ['cache_batch', []],
131
+ ['cache_heads', ['autoregressive', 'tensor']],
132
+ ['cache_kv', []],
133
+ ['cache_sequence', []],
134
+ ]
135
+ data_sharding: [['data', 'fsdp', 'fsdp_transpose', 'sequence', 'tensor', 'autoregressive']]
136
+
137
+ # One axis for each parallelism type may hold a placeholder (-1)
138
+ # value to auto-shard based on available slices and devices.
139
+ # By default, product of the DCN axes should equal number of slices
140
+ # and product of the ICI axes should equal number of devices per slice.
141
+ dcn_data_parallelism: -1 # recommended DCN axis to be auto-sharded
142
+ dcn_fsdp_parallelism: 1
143
+ dcn_fsdp_transpose_parallelism: 1
144
+ dcn_sequence_parallelism: 1 # never recommended
145
+ dcn_tensor_parallelism: 1 # never recommeneded
146
+ dcn_autoregressive_parallelism: 1 # never recommended
147
+ ici_data_parallelism: 1
148
+ ici_fsdp_parallelism: -1 # recommended ICI axis to be auto-sharded
149
+ ici_fsdp_transpose_parallelism: 1
150
+ ici_sequence_parallelism: 1
151
+ ici_tensor_parallelism: 1
152
+ ici_autoregressive_parallelism: 1
153
+
154
+ # The number of TPU slices is automatically determined, you should not set this explicitly. For ahead of time compilation,
155
+ # you should set compile_toplogy_num_slices, which will in turn set this value. For non-TPU environments this is set to 1.
156
+ num_slices: -1
157
+
158
+ # Dataset
159
+ # Replace with your path given as argument in download_dataset.sh, e.g. "gs://my-maxtext-dataset/"
160
+ dataset_path: ""
161
+ vocab_size: 32_000 # powers of 2 for sharding
162
+ tokenizer_path: "assets/tokenizer.llama2"
163
+ dataset_name: 'c4/en:3.0.1'
164
+ eval_dataset_name: 'c4/en:3.0.1'
165
+ eval_split: 'validation'
166
+ per_device_batch_size: 12.0
167
+ eval_per_device_batch_size: 0
168
+ max_corpus_chars: 10_000_000
169
+ dataset_type: c4 # must be c4 or synthetic
170
+
171
+ # Setting for grain
172
+ grain_worker_count: 4
173
+
174
+ # Training loop
175
+ steps: 150_001 # If set to -1 then will inherit value from learning_rate_schedule_steps
176
+ log_period: 100 # Flushes Tensorboard
177
+
178
+ # We take inspiration from Llama2's learning rate (LR) schedule, see https://arxiv.org/pdf/2307.09288.pdf section 2.2
179
+ # Learning rate schedule has either two or three parts:
180
+ # 1) Linear warmup from 0 to [learning_rate] over steps 0 to [learning_rate_schedule_steps * warmup_steps_fraction]
181
+ # 2) Cosine decay from [learning_rate] to [learning_rate * cosine_learning_rate_final_fraction] from warmup to learning_rate_schedule_steps
182
+ # 3) Constant learning rate of 0 from learning_rate_schedule_steps to steps.
183
+ # The zero learning rate section can be used to more accurately measure the fully trained model's performance.
184
+ learning_rate: 3.e-5
185
+ cosine_learning_rate_final_fraction: 0.1
186
+ warmup_steps_fraction: 0.1
187
+ learning_rate_schedule_steps: -1 # By default the length of the schedule is set to the number of steps.
188
+ # However you may choose a longer schedule (learning_rate_schedule_steps > steps), in which case the training will end before
189
+ # dropping fully down. Or you may choose a shorter schedule, where the unspecified steps will have a learning rate of 0.
190
+
191
+ max_target_length: 2048 # Maximum sequence length
192
+ max_prefill_predict_length: 64 # Maximum length for the prefill when doing autoregression
193
+ prompt: "I love to" # Prompt for language model sampling.
194
+ load_from_prefill_dir: False # If true, decode.py doesn't "prefill" but just reads from directory
195
+ prefill_cache_dir: "" # If set and load_from_prefill_dir, decode.py reads from directory. If set, decode.py writes to directory
196
+ autoregressive_decode_assert: ""
197
+
198
+ enable_profiler: False
199
+ # If set to true, upload all profiler xplane results from all hosts. Otherwise, only upload the xplane reuslt from the first host.
200
+ upload_all_profiler_results: False
201
+ # Skip first n steps for profiling, to omit things like compilation and to give
202
+ # the iteration time a chance to stabilize.
203
+ skip_first_n_steps_for_profiler: 1
204
+ # Profile for a small number of steps to avoid a large profile file size.
205
+ profiler_steps: 5
206
+
207
+ # When dropout is false the model is a deterministic function of the
208
+ # data_shuffle_seed and init_weights_seed (i.e. reproducible losses)
209
+ enable_dropout: True
210
+ enable_data_shuffling: True
211
+ data_shuffle_seed: 0
212
+ init_weights_seed: 0
213
+
214
+ # You may disable clipping by setting gradient_clipping_threshold to zero.
215
+ gradient_clipping_threshold: 1.0
216
+
217
+ # AdamW optimizer parameters
218
+ # We use AdamW following Llama2's training details, see https://arxiv.org/pdf/2307.09288.pdf section 2.2
219
+ opt_type: "adamw" # one of "adam_pax" or "adamw"
220
+ adam_b1: 0.9 # Exponential decay rate to track the first moment of past gradients.
221
+ adam_b2: 0.95 # Exponential decay rate to track the second moment of past gradients.
222
+ adam_eps: 1.e-8 # A small constant applied to denominator outside of the square root.
223
+ adam_eps_root: 0. # A small constant applied to denominator inside the square root.
224
+ adam_weight_decay: 0.1 # AdamW Weight decay
225
+
226
+ # Stack trace parameters
227
+ collect_stack_trace: False
228
+ stack_trace_to_cloud: False # Uploads to cloud logging if True, else to the console if False.
229
+ stack_trace_interval_seconds: 600 # Stack trace collection frequency in seconds.
230
+
231
+ # Use iota operator in Embed
232
+ use_iota_embed: False
233
+ # use positional embedding
234
+ use_untrainable_positional_embedding: False
235
+ trainable_position_size: -1 # enable gpt3 position embedding with a positive trainable_position_size
236
+
237
+ # Ahead of time Compilation (aka AOT)
238
+ # Only set these arguments if you are running train_compile or loading a compiled train step.
239
+ compiled_trainstep_file: "" # Name of saved serialized compiled train_step, e.g. compiled_train_v5e-256.pickle
240
+ compile_topology: '' # Target hardware version, e.g. 'v5e-256'
241
+ compile_topology_num_slices: -1 # Number of target slices, set to a positive integer.
242
+
243
+ decode_sampling_strategy: "greedy" # decode_sampling_strategy should be one of greedy, weighted, nucleus, or topk
244
+ decode_sampling_nucleus_p: -1 # set if you're doing nucleus / top-p
245
+ decode_sampling_top_k: 0 # set if you're doing top-k
246
+ decode_sampling_temperature: 1.
247
+
248
+ eval_interval: -1 # the specific number of train step between eval_step
249
+ target_eval_loss: 0. # early stop once reaching target eval_loss
maxtext-setup/maxtext/MaxText/configs/experimental/1024b.sh ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ echo "Running 1024b.sh"
2
+ # Example command to invoke this script
3
+ # bash MaxText/configs/experimental/1024b.sh
4
+
5
+ # Stop execution if any command exits with error
6
+ set -e
7
+
8
+ export OUTPUT_PATH="gs://maxtext-experiments-multipod"
9
+ export DATASET_PATH="gs://maxtext-dataset/"
10
+
11
+ # Set environment variables
12
+ for ARGUMENT in "$@"; do
13
+ IFS='=' read -r KEY VALUE <<< "$ARGUMENT"
14
+ export "$KEY"="$VALUE"
15
+ done
16
+
17
+ # Use preflight.sh to set up env based on platform
18
+ bash preflight.sh PLATFORM=$PLATFORM
19
+
20
+ # Train
21
+ export LIBTPU_INIT_ARGS="--xla_tpu_megacore_fusion_allow_ags=false --xla_enable_async_collective_permute=true --xla_tpu_enable_ag_backward_pipelining=true --xla_tpu_enable_data_parallel_all_reduce_opt=true --xla_tpu_data_parallel_opt_different_sized_ops=true --xla_tpu_enable_async_collective_fusion=true --xla_tpu_enable_async_collective_fusion_multiple_steps=true --xla_tpu_overlap_compute_collective_tc=true --xla_enable_async_all_gather=true"
22
+ python3 MaxText/train.py MaxText/configs/base.yml run_name=$RUN_NAME\
23
+ steps=20 per_device_batch_size=2 enable_checkpointing=false\
24
+ enable_profiler=false remat_policy=full global_parameter_scale=1024\
25
+ ici_fsdp_parallelism=-1 ici_tensor_parallelism=16\
26
+ max_target_length=2048 base_output_directory=$OUTPUT_PATH\
27
+ dataset_path=$DATASET_PATH use_iota_embed=true reuse_example_batch=1\
28
+ dataset_type=synthetic gcs_metrics=true attention='flash' quantization=""
maxtext-setup/maxtext/MaxText/configs/experimental/128b.sh ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ echo "Running 128b.sh"
2
+ # Example command to invoke this script
3
+ # bash MaxText/configs/experimental/128b.sh
4
+
5
+ # Stop execution if any command exits with error
6
+ set -e
7
+
8
+ export OUTPUT_PATH="gs://maxtext-experiments-multipod"
9
+ export DATASET_PATH="gs://maxtext-dataset/"
10
+
11
+ # Set environment variables
12
+ for ARGUMENT in "$@"; do
13
+ IFS='=' read -r KEY VALUE <<< "$ARGUMENT"
14
+ export "$KEY"="$VALUE"
15
+ done
16
+
17
+ # Use preflight.sh to set up env based on platform
18
+ bash preflight.sh PLATFORM=$PLATFORM
19
+
20
+ # Train
21
+ export LIBTPU_INIT_ARGS="--xla_tpu_megacore_fusion_allow_ags=false --xla_enable_async_collective_permute=true --xla_tpu_enable_ag_backward_pipelining=true --xla_tpu_enable_data_parallel_all_reduce_opt=true --xla_tpu_data_parallel_opt_different_sized_ops=true --xla_tpu_enable_async_collective_fusion=true --xla_tpu_enable_async_collective_fusion_multiple_steps=true --xla_tpu_overlap_compute_collective_tc=true --xla_enable_async_all_gather=true"
22
+ python3 MaxText/train.py MaxText/configs/base.yml run_name=$RUN_NAME\
23
+ steps=30 per_device_batch_size=2 enable_checkpointing=false\
24
+ enable_profiler=false remat_policy=minimal global_parameter_scale=128\
25
+ ici_fsdp_parallelism=-1 ici_tensor_parallelism=8\
26
+ max_target_length=2048 base_output_directory=$OUTPUT_PATH\
27
+ dataset_path=$DATASET_PATH use_iota_embed=true reuse_example_batch=1\
28
+ dataset_type=synthetic gcs_metrics=true attention='flash' quantization=""\
maxtext-setup/maxtext/MaxText/configs/experimental/256b.sh ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ echo "Running 256b.sh"
2
+ # Example command to invoke this script
3
+ # bash MaxText/configs/experimental/256b.sh
4
+
5
+ # Stop execution if any command exits with error
6
+ set -e
7
+
8
+ export OUTPUT_PATH="gs://maxtext-experiments-multipod"
9
+ export DATASET_PATH="gs://maxtext-dataset/"
10
+
11
+ # Set environment variables
12
+ for ARGUMENT in "$@"; do
13
+ IFS='=' read -r KEY VALUE <<< "$ARGUMENT"
14
+ export "$KEY"="$VALUE"
15
+ done
16
+
17
+ # Use preflight.sh to set up env based on platform
18
+ bash preflight.sh PLATFORM=$PLATFORM
19
+
20
+ # Train
21
+ export LIBTPU_INIT_ARGS="--xla_tpu_megacore_fusion_allow_ags=false --xla_enable_async_collective_permute=true --xla_tpu_enable_ag_backward_pipelining=true --xla_tpu_enable_data_parallel_all_reduce_opt=true --xla_tpu_data_parallel_opt_different_sized_ops=true --xla_tpu_enable_async_collective_fusion=true --xla_tpu_enable_async_collective_fusion_multiple_steps=true --xla_tpu_overlap_compute_collective_tc=true --xla_enable_async_all_gather=true"
22
+ python3 MaxText/train.py MaxText/configs/base.yml run_name=$RUN_NAME\
23
+ steps=20 per_device_batch_size=2 enable_checkpointing=false\
24
+ enable_profiler=false remat_policy=minimal global_parameter_scale=256\
25
+ ici_fsdp_parallelism=-1 ici_tensor_parallelism=8\
26
+ max_target_length=2048 base_output_directory=$OUTPUT_PATH\
27
+ dataset_path=$DATASET_PATH use_iota_embed=true reuse_example_batch=1\
28
+ dataset_type=synthetic gcs_metrics=true attention='flash' quantization=""
maxtext-setup/maxtext/MaxText/configs/experimental/32b.sh ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ echo "Running 32b.sh"
2
+ # Example command to invoke this script
3
+ # bash MaxText/configs/experimental/32b.sh
4
+
5
+ # Stop execution if any command exits with error
6
+ set -e
7
+
8
+ export OUTPUT_PATH="gs://maxtext-experiments-multipod"
9
+ export DATASET_PATH="gs://maxtext-dataset/"
10
+
11
+ # Set environment variables
12
+ for ARGUMENT in "$@"; do
13
+ IFS='=' read -r KEY VALUE <<< "$ARGUMENT"
14
+ export "$KEY"="$VALUE"
15
+ done
16
+
17
+ # Use preflight.sh to set up env based on platform
18
+ bash preflight.sh PLATFORM=$PLATFORM
19
+
20
+ # Train
21
+ export LIBTPU_INIT_ARGS="--xla_tpu_megacore_fusion_allow_ags=false --xla_enable_async_collective_permute=true --xla_tpu_enable_ag_backward_pipelining=true --xla_tpu_enable_data_parallel_all_reduce_opt=true --xla_tpu_data_parallel_opt_different_sized_ops=true --xla_tpu_enable_async_collective_fusion=true --xla_tpu_enable_async_collective_fusion_multiple_steps=true --xla_tpu_overlap_compute_collective_tc=true --xla_enable_async_all_gather=true"
22
+ python3 MaxText/train.py MaxText/configs/base.yml run_name=$RUN_NAME\
23
+ steps=30 per_device_batch_size=8 enable_checkpointing=false\
24
+ enable_profiler=false remat_policy=minimal global_parameter_scale=32\
25
+ ici_fsdp_parallelism=-1 ici_tensor_parallelism=4\
26
+ max_target_length=2048 base_output_directory=$OUTPUT_PATH\
27
+ dataset_path=$DATASET_PATH use_iota_embed=true reuse_example_batch=1\
28
+ dataset_type=synthetic gcs_metrics=true attention='flash' quantization=""\
maxtext-setup/maxtext/MaxText/configs/experimental/512b.sh ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ echo "Running 512b.sh"
2
+ # Example command to invoke this script
3
+ # bash MaxText/configs/experimental/512b.sh
4
+
5
+ # Stop execution if any command exits with error
6
+ set -e
7
+
8
+ export OUTPUT_PATH="gs://maxtext-experiments-multipod"
9
+ export DATASET_PATH="gs://maxtext-dataset/"
10
+
11
+ # Set environment variables
12
+ for ARGUMENT in "$@"; do
13
+ IFS='=' read -r KEY VALUE <<< "$ARGUMENT"
14
+ export "$KEY"="$VALUE"
15
+ done
16
+
17
+ # Use preflight.sh to set up env based on platform
18
+ bash preflight.sh PLATFORM=$PLATFORM
19
+
20
+ # Train
21
+ export LIBTPU_INIT_ARGS="--xla_tpu_megacore_fusion_allow_ags=false --xla_enable_async_collective_permute=true --xla_tpu_enable_ag_backward_pipelining=true --xla_tpu_enable_data_parallel_all_reduce_opt=true --xla_tpu_data_parallel_opt_different_sized_ops=true --xla_tpu_enable_async_collective_fusion=true --xla_tpu_enable_async_collective_fusion_multiple_steps=true --xla_tpu_overlap_compute_collective_tc=true --xla_enable_async_all_gather=true"
22
+ python3 MaxText/train.py MaxText/configs/base.yml run_name=$RUN_NAME\
23
+ steps=20 per_device_batch_size=2 enable_checkpointing=false\
24
+ enable_profiler=false remat_policy=full global_parameter_scale=512\
25
+ ici_fsdp_parallelism=-1 ici_tensor_parallelism=16\
26
+ max_target_length=2048 base_output_directory=$OUTPUT_PATH\
27
+ dataset_path=$DATASET_PATH use_iota_embed=true reuse_example_batch=1\
28
+ dataset_type=synthetic gcs_metrics=true attention='flash' quantization=""
maxtext-setup/maxtext/MaxText/configs/experimental/64b.sh ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ echo "Running 64b.sh"
2
+ # Example command to invoke this script
3
+ # bash MaxText/configs/experimental/64b.sh
4
+
5
+ # Stop execution if any command exits with error
6
+ set -e
7
+
8
+ export OUTPUT_PATH="gs://maxtext-experiments-multipod"
9
+ export DATASET_PATH="gs://maxtext-dataset/"
10
+
11
+ # Set environment variables
12
+ for ARGUMENT in "$@"; do
13
+ IFS='=' read -r KEY VALUE <<< "$ARGUMENT"
14
+ export "$KEY"="$VALUE"
15
+ done
16
+
17
+ # Use preflight.sh to set up env based on platform
18
+ bash preflight.sh PLATFORM=$PLATFORM
19
+
20
+ # Train
21
+ export LIBTPU_INIT_ARGS="--xla_tpu_megacore_fusion_allow_ags=false --xla_enable_async_collective_permute=true --xla_tpu_enable_ag_backward_pipelining=true --xla_tpu_enable_data_parallel_all_reduce_opt=true --xla_tpu_data_parallel_opt_different_sized_ops=true --xla_tpu_enable_async_collective_fusion=true --xla_tpu_enable_async_collective_fusion_multiple_steps=true --xla_tpu_overlap_compute_collective_tc=true --xla_enable_async_all_gather=true"
22
+ python3 MaxText/train.py MaxText/configs/base.yml run_name=$RUN_NAME\
23
+ steps=30 per_device_batch_size=4 enable_checkpointing=false\
24
+ enable_profiler=false remat_policy=minimal global_parameter_scale=64\
25
+ ici_fsdp_parallelism=-1 ici_tensor_parallelism=4\
26
+ max_target_length=2048 base_output_directory=$OUTPUT_PATH\
27
+ dataset_path=$DATASET_PATH use_iota_embed=true reuse_example_batch=1\
28
+ dataset_type=synthetic gcs_metrics=true attention='flash' quantization=""\
maxtext-setup/maxtext/MaxText/configs/gpu_smoke_test.yml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ base_config: "base.yml"
2
+
3
+ hardware: "gpu"
4
+ attention: "dot_product"
5
+ base_emb_dim: 8
6
+ base_emb_dim: 8
7
+ base_num_query_heads: 4
8
+ base_num_kv_heads: 4
9
+ base_mlp_dim: 32
10
+ base_num_decoder_layers: 8
11
+ head_dim: 16
12
+ per_device_batch_size: 2
13
+ max_target_length: 1024
14
+ dataset_type: "synthetic"
15
+ steps: 10
maxtext-setup/maxtext/MaxText/configs/llama2_7b_single_host_gpu.yml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ base_config: "base.yml"
2
+
3
+ hardware: "gpu"
4
+ attention: "cudnn_flash_te"
5
+
6
+ learning_rate_schedule_steps: 150001
7
+
8
+ model_name: llama2-7b
9
+
10
+ max_target_length: 1024
11
+ dataset_type: "synthetic"
12
+ steps: 10
13
+
14
+ vocab_relative_path: tokenizer.llama2
15
+ rms_norm_epsilon: 1e-05
16
+
17
+ prompt: "I love to"
maxtext-setup/maxtext/MaxText/configs/models/gemma-2b.yml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2023 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # model config for gemma-2b
16
+
17
+ base_emb_dim: 2048
18
+ base_num_query_heads: 8
19
+ base_num_kv_heads: 1
20
+ base_mlp_dim: 16384
21
+ base_num_decoder_layers: 18
22
+ head_dim: 256
23
+ mlp_activations: ["gelu","linear"]
24
+ vocab_size: 256128
25
+ decoder_block: "gemma"
26
+ normalization_layer_epsilon: 1.e-06
27
+ logits_via_embedding: True
maxtext-setup/maxtext/MaxText/configs/models/gemma-7b.yml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2023 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # model config for gemma-7b
16
+
17
+ base_emb_dim: 3072
18
+ base_num_query_heads: 16
19
+ base_num_kv_heads: 16
20
+ base_mlp_dim: 24576
21
+ base_num_decoder_layers: 28
22
+ head_dim: 256
23
+ mlp_activations: ["gelu","linear"]
24
+ vocab_size: 256128
25
+ decoder_block: "gemma"
26
+ normalization_layer_epsilon: 1.e-06
27
+ logits_via_embedding: True
maxtext-setup/maxtext/MaxText/configs/models/gpt3-175b.yml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2023 Google LLC
2
+ #
3
+ # Licensed under the Apache License Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing software
10
+ # distributed under the License is distributed on an "AS IS" BASIS
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # model config for gpt3-175b
16
+
17
+ base_emb_dim: 12288
18
+ base_num_query_heads: 96
19
+ base_num_kv_heads: 96
20
+ base_mlp_dim: 49152
21
+ base_num_decoder_layers: 96
22
+ head_dim: 128
23
+ trainable_position_size: 16384
24
+ mlp_activations: ["gelu"]
25
+ vocab_size: 50304
26
+ enable_dropout: False
27
+ logits_via_embedding: True
28
+ normalize_embedding_logits: False
29
+ logits_dot_in_fp32: False
30
+ normalization_layer_epsilon: 1.e-05
31
+ use_iota_embed: True
32
+ fused_qkv: True
33
+ opt_type: "adam_pax"
34
+ decoder_block: "gpt3"
35
+ dataset_path: "gs://mlperf-llm-public2"
36
+ dataset_name: "c4/en:3.0.4"
37
+ eval_dataset_name: "c4/en:3.0.5"
38
+ gradient_clipping_threshold: 1.
39
+ adam_b1: 0.9
40
+ adam_b2: 0.95
41
+ adam_eps: 1.e-8
42
+ adam_weight_decay: 0.1
43
+ checkpoint_period: 10_000
44
+ target_eval_loss: 2.69
maxtext-setup/maxtext/MaxText/configs/models/gpt3-22b.yml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2023 Google LLC
2
+ #
3
+ # Licensed under the Apache License Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing software
10
+ # distributed under the License is distributed on an "AS IS" BASIS
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # model config for gpt3-22b
16
+
17
+ base_emb_dim: 6144
18
+ base_num_query_heads: 24
19
+ base_num_kv_heads: 24
20
+ base_mlp_dim: 24576
21
+ base_num_decoder_layers: 48
22
+ head_dim: 256
23
+ max_target_length: 1024
24
+ trainable_position_size: 16384
25
+ mlp_activations: ["gelu"]
26
+ vocab_size: 32768
27
+ enable_dropout: False
28
+ logits_via_embedding: True
29
+ normalize_embedding_logits: False
30
+ logits_dot_in_fp32: False
31
+ normalization_layer_epsilon: 1.e-05
32
+ use_iota_embed: True
33
+ fused_qkv: True
34
+ opt_type: "adam_pax"
35
+ decoder_block: "gpt3"
36
+ gradient_clipping_threshold: 1.
37
+ adam_b1: 0.9
38
+ adam_b2: 0.95
39
+ adam_eps: 1.e-8
40
+ adam_weight_decay: 0.1
maxtext-setup/maxtext/MaxText/configs/models/gpt3-52k.yml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2023 Google LLC
2
+ #
3
+ # Licensed under the Apache License Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing software
10
+ # distributed under the License is distributed on an "AS IS" BASIS
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # model config for gpt3-52k, i.e. a fake and small model for testing purpose only
16
+
17
+ base_emb_dim: 16
18
+ base_num_query_heads: 2
19
+ base_num_kv_heads: 2
20
+ base_mlp_dim: 64
21
+ base_num_decoder_layers: 1
22
+ head_dim: 8
23
+ trainable_position_size: 2048
24
+ mlp_activations: ["gelu"]
25
+ vocab_size: 1024
26
+ enable_dropout: False
27
+ logits_via_embedding: True
28
+ normalize_embedding_logits: False
29
+ logits_dot_in_fp32: False
30
+ normalization_layer_epsilon: 1.e-05
31
+ use_iota_embed: True
32
+ fused_qkv: True
33
+ opt_type: "adam_pax"
34
+ decoder_block: "gpt3"
35
+ gradient_clipping_threshold: 1.
36
+ adam_b1: 0.9
37
+ adam_b2: 0.95
38
+ adam_eps: 1.e-8
39
+ adam_weight_decay: 0.1
40
+ attention: "dot_product" # head_dim 8 is too small for splash/flash attention
maxtext-setup/maxtext/MaxText/configs/models/gpt3-6b.yml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2023 Google LLC
2
+ #
3
+ # Licensed under the Apache License Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing software
10
+ # distributed under the License is distributed on an "AS IS" BASIS
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # model config for gpt3-6b
16
+
17
+ base_emb_dim: 3072
18
+ base_num_query_heads: 12
19
+ base_num_kv_heads: 12
20
+ base_mlp_dim: 12288
21
+ base_num_decoder_layers: 48
22
+ head_dim: 256
23
+ max_target_length: 1024
24
+ trainable_position_size: 16384
25
+ mlp_activations: ["gelu"]
26
+ vocab_size: 32768
27
+ enable_dropout: False
28
+ logits_via_embedding: True
29
+ normalize_embedding_logits: False
30
+ logits_dot_in_fp32: False
31
+ normalization_layer_epsilon: 1.e-05
32
+ use_iota_embed: True
33
+ fused_qkv: True
34
+ opt_type: "adam_pax"
35
+ decoder_block: "gpt3"
36
+ gradient_clipping_threshold: 1.
37
+ adam_b1: 0.9
38
+ adam_b2: 0.95
39
+ adam_eps: 1.e-8
40
+ adam_weight_decay: 0.1
maxtext-setup/maxtext/MaxText/configs/models/llama2-13b.yml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2024 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # model config for llama2-13b
16
+
17
+ base_emb_dim: 5120
18
+ base_num_query_heads: 40
19
+ base_num_kv_heads: 40
20
+ base_mlp_dim: 13824
21
+ base_num_decoder_layers: 40
22
+ head_dim: 128
23
+ mlp_activations: ["silu","linear"]
24
+ vocab_size: 32000
25
+ enable_dropout: False
26
+ logits_via_embedding: False
27
+ normalization_layer_epsilon: 1.0e-5
28
+ decoder_block: "llama2"
maxtext-setup/maxtext/MaxText/configs/models/llama2-70b.yml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2023 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # model config for llama2-7b
16
+
17
+ base_emb_dim: 8192
18
+ base_num_query_heads: 64
19
+ base_num_kv_heads: 8
20
+ base_mlp_dim: 28672
21
+ base_num_decoder_layers: 80
22
+ head_dim: 128
23
+ mlp_activations: ["silu","linear"]
24
+ vocab_size: 32000
25
+ logits_via_embedding: False
26
+ normalization_layer_epsilon: 1.0e-5
27
+ decoder_block: "llama2"
maxtext-setup/maxtext/MaxText/configs/models/llama2-7b.yml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2023 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # model config for llama2-7b
16
+
17
+ base_emb_dim: 4096
18
+ base_num_query_heads: 32
19
+ base_num_kv_heads: 32
20
+ base_mlp_dim: 11008
21
+ base_num_decoder_layers: 32
22
+ head_dim: 128
23
+ mlp_activations: ["silu","linear"]
24
+ vocab_size: 32000
25
+ enable_dropout: False
26
+ logits_via_embedding: False
27
+ normalization_layer_epsilon: 1.0e-5
28
+ decoder_block: "llama2"
maxtext-setup/maxtext/MaxText/configs/models/mistral-7b.yml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2023 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # model config for mistral-7b
16
+
17
+ base_emb_dim: 4096
18
+ base_num_query_heads: 32
19
+ base_num_kv_heads: 8
20
+ base_mlp_dim: 14336
21
+ base_num_decoder_layers: 32
22
+ head_dim: 128
23
+ mlp_activations: ["silu","linear"]
24
+ vocab_size: 32000
25
+ enable_dropout: False
26
+ logits_via_embedding: False
27
+ normalization_layer_epsilon: 1.0e-5
28
+ decoder_block: "mistral"
maxtext-setup/maxtext/MaxText/configs/models/mixtral-8x7b.yml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2024 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # https://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # model config for mixtral-8x7b
16
+
17
+ base_emb_dim: 4096
18
+ base_num_query_heads: 32
19
+ base_num_kv_heads: 8
20
+ base_mlp_dim: 14336
21
+ base_num_decoder_layers: 32
22
+ head_dim: 128
23
+ mlp_activations: ["silu","linear"]
24
+ vocab_size: 32000
25
+ enable_dropout: False
26
+ logits_via_embedding: False
27
+ normalization_layer_epsilon: 1.0e-5
28
+ num_experts: 8
29
+ num_experts_per_tok: 2
30
+ decoder_block: "mistral"
maxtext-setup/maxtext/MaxText/configs/tpu_smoke_test.yml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ base_config: "base.yml"
2
+
3
+ hardware: "tpu"
4
+ async_checkpointing: false
5
+ attention: autoselected
6
+ base_emb_dim: 32
7
+ base_num_query_heads: 8
8
+ base_num_kv_heads: 8
9
+ base_mlp_dim: 32
10
+ base_num_decoder_layers: 8
11
+ dataset_type: "synthetic"
12
+ head_dim: 128
13
+ per_device_batch_size: 1
14
+ steps: 10