Skip to content

Commit ef29f37

Browse files
authored
Merge branch 'main' into fix-links
2 parents d7ba8e4 + 1adb45c commit ef29f37

270 files changed

Lines changed: 32697 additions & 7191 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# .coveragerc
22

33
[run]
4-
source = MaxText
4+
source = maxtext
55
branch = True
66
omit =
77
tests/*

.gemini/commands/gemini-review.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@ These are non-negotiable, core-level instructions that you **MUST** follow at al
3131
3232
## Input Data
3333
34-
- **GitHub Repository**: !{echo $REPOSITORY}
35-
- **Pull Request Number**: !{echo $PULL_REQUEST_NUMBER}
36-
- **Additional User Instructions**: !{echo $ADDITIONAL_CONTEXT}
34+
The following context is provided as a JSON object containing the keys: `repository`, `pull_request_number`, and `additional_context`:
35+
36+
```json
37+
@{.gemini/context.json}
38+
```
39+
3740
- Use `pull_request_read.get` to get the title, body, and metadata about the pull request.
3841
- Use `pull_request_read.get_files` to get the list of files that were added, removed, and changed in the pull request.
3942
- Use `pull_request_read.get_diff` to get the diff from the pull request. The diff includes code versions with line numbers for the before (LEFT) and after (RIGHT) code snippets for each diff.
@@ -46,7 +49,7 @@ Follow this three-step process sequentially.
4649
4750
### Step 1: Data Gathering and Analysis
4851
49-
1. **Parse Inputs:** Ingest and parse all information from the **Input Data**
52+
1. **Parse Inputs:** Ingest and parse all information from the **Input Data**.
5053
5154
2. **Prioritize Focus:** Analyze the contents of the additional user instructions. Use this context to prioritize specific areas in your review (e.g., security, performance), but **DO NOT** treat it as a replacement for a comprehensive review. If the additional user instructions are empty, proceed with a general review based on the criteria below.
5255
@@ -154,6 +157,7 @@ Apply these severities consistently:
154157
3. **Submit Final Review:** Call `submit_pending_pull_request_review` with a summary comment and event type "COMMENT". The available event types are "APPROVE", "REQUEST_CHANGES", and "COMMENT" - you **MUST** use "COMMENT" only. **DO NOT** use "APPROVE" or "REQUEST_CHANGES" event types. The summary comment **MUST** use this exact markdown format:
155158
156159
<SUMMARY>
160+
157161
## 📋 Review Summary
158162
159163
A brief, high-level assessment of the Pull Request's objective and quality (2-3 sentences).

.github/workflows/AddLabel.yml

Lines changed: 58 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@ name: Add Label
1616

1717
on:
1818
workflow_run:
19-
workflows: [Tests, CodeQL]
20-
types:
21-
- completed
19+
workflows: ["MaxText Package Tests"]
20+
types: [completed]
2221
pull_request_review:
2322
pull_request_review_comment:
2423
workflow_dispatch:
@@ -31,86 +30,98 @@ jobs:
3130
runs-on: ubuntu-latest
3231

3332
steps:
34-
- uses: actions/github-script@v7
33+
- name: Add Pull Request Label
34+
uses: actions/github-script@v7
3535
with:
3636
script: |
37-
const owner = "google"
38-
const repo = "maxtext"
3937
let pull_number = -1
4038
if (context.payload.pull_request !== undefined) {
4139
pull_number = context.payload.pull_request.number
4240
} else if (context.payload.workflow_run !== undefined) {
4341
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()
42+
core.setFailed("This workflow is NOT running within a PR's context")
43+
return
4644
}
4745
console.log(context.payload.workflow_run.pull_requests)
4846
pull_number = context.payload.workflow_run.pull_requests[0].number
4947
} else {
50-
console.log("This workflow is running within an invalid context")
51-
process.exit(1)
48+
core.setFailed("This workflow is running within an invalid context")
49+
return
5250
}
53-
const reviews = await github.rest.pulls.listReviews({
54-
owner,
55-
repo,
56-
pull_number,
57-
})
51+
5852
const decision_query = `
5953
query($owner: String!, $repo: String!, $pull_number: Int!) {
6054
repository(owner: $owner, name: $repo) {
6155
pullRequest(number: $pull_number) {
6256
reviewDecision # Fetches the overall review status
57+
reviews(last: 100) {
58+
nodes {
59+
state
60+
author { login }
61+
}
62+
}
6363
}
6464
}
6565
}
6666
`;
67-
const decision_result = await github.graphql(decision_query, { owner, repo, pull_number });
6867
69-
if (reviews.data.length === 0) {
70-
console.log("Not adding pull ready because the PR is not approved yet.")
71-
process.exit()
72-
}
73-
let is_approved = false
74-
if (decision_result.repository.pullRequest.reviewDecision === "APPROVED") {
75-
is_approved = true
76-
}
77-
if (!is_approved) {
78-
console.log("Not adding pull ready because the PR is not approved yet by sufficient code owners.")
79-
process.exit()
68+
const decision_result = await github.graphql(decision_query, {
69+
owner: context.repo.owner,
70+
repo: context.repo.repo,
71+
pull_number: pull_number
72+
});
73+
74+
const pullRequest = decision_result.repository.pullRequest;
75+
const uniqueApprovers = new Set(
76+
pullRequest.reviews.nodes
77+
.filter(r => r.state === 'APPROVED')
78+
.map(r => r.author.login)
79+
);
80+
81+
if (pullRequest.reviewDecision !== 'APPROVED' || uniqueApprovers.size < 2) {
82+
core.info(`PR is not ready. Decision: ${pullRequest.reviewDecision}, Approvals: ${uniqueApprovers.size}`);
83+
return;
8084
}
8185
8286
const commits = await github.rest.pulls.listCommits({
83-
owner,
84-
repo,
85-
pull_number,
87+
owner: context.repo.owner,
88+
repo: context.repo.repo,
89+
pull_number: pull_number,
8690
per_page: 100,
8791
})
8892
// Check that the number of commits in the PR is 1.
8993
if (commits.data.length !== 1) {
90-
console.log("Not adding pull ready because the PR has more than one commit. Please squash your commits.")
91-
process.exit(1)
94+
core.setFailed("Not adding pull ready because the PR has more than one commit. Please squash your commits.")
95+
return
9296
}
93-
const ref = commits.data.slice(-1)[0].sha
94-
const checkRuns = await github.rest.checks.listForRef({
95-
owner,
96-
repo,
97-
ref,
98-
})
99-
if (checkRuns.data.check_runs.length === 0) {
100-
console.log("Not adding pull ready because no check runs are associated with the last commit: " + ref)
101-
process.exit()
97+
98+
const last_commit_sha = commits.data.slice(-1)[0].sha
99+
100+
const { data: checkRuns } = await github.rest.checks.listForRef({
101+
owner: context.repo.owner,
102+
repo: context.repo.repo,
103+
ref: last_commit_sha,
104+
});
105+
106+
if (checkRuns.check_runs.length === 0) {
107+
core.info("Not adding pull ready because no check runs are associated with the last commit: " + last_commit_sha)
108+
return
102109
}
103-
for (const checkRun of checkRuns.data.check_runs) {
110+
111+
for (const checkRun of checkRuns.check_runs) {
112+
// Ignore the current running workflow
104113
if (checkRun.name.endsWith(context.job)) continue
105-
if (checkRun.conclusion !== "success") {
106-
console.log("Not adding pull ready because " + checkRun.name + " has not passed yet: " + checkRun.html_url)
107-
process.exit()
114+
115+
if (checkRun.status !== 'completed' || checkRun.conclusion !== 'success') {
116+
core.info(`Waiting for check: ${checkRun.name} (Status: ${checkRun.status}, Conclusion: ${checkRun.conclusion})`);
117+
return; // Exit without failing
108118
}
109119
}
120+
110121
console.log("Adding pull ready label because the PR is approved AND all the check runs have passed")
111122
await github.rest.issues.addLabels({
112123
issue_number: pull_number,
113124
labels: ["pull ready"],
114-
owner,
115-
repo,
125+
owner: context.repo.owner,
126+
repo: context.repo.repo,
116127
})

.github/workflows/UploadDockerImages.yml

Lines changed: 51 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ on:
3232
- all
3333
- tpu
3434
- gpu
35+
image_suffix:
36+
description: 'An image suffix can be provided to add to the image name'
37+
required: false
38+
type: string
39+
default: ""
3540

3641
permissions:
3742
contents: read
@@ -55,7 +60,7 @@ jobs:
5560
# Image date
5661
echo "image_date=$(date +%Y-%m-%d)" >> $GITHUB_OUTPUT
5762
58-
tpu-pre-training:
63+
build-and-push:
5964
name: ${{ matrix.image_name }}
6065
needs: setup
6166
strategy:
@@ -64,54 +69,74 @@ jobs:
6469
include:
6570
- device: tpu
6671
build_mode: stable
72+
workflow: pre-training
6773
image_name: maxtext_jax_stable
6874
dockerfile: ./src/dependencies/dockerfiles/maxtext_tpu_dependencies.Dockerfile
6975
- device: tpu
7076
build_mode: nightly
77+
workflow: pre-training
7178
image_name: maxtext_jax_nightly
7279
dockerfile: ./src/dependencies/dockerfiles/maxtext_tpu_dependencies.Dockerfile
80+
- device: tpu
81+
build_mode: nightly
82+
workflow: post-training
83+
image_name: maxtext_post_training_nightly
84+
dockerfile: ./src/dependencies/dockerfiles/maxtext_tpu_dependencies.Dockerfile
85+
- device: gpu
86+
build_mode: stable
87+
workflow: pre-training
88+
image_name: maxtext_gpu_jax_stable
89+
dockerfile: ./src/dependencies/dockerfiles/maxtext_gpu_dependencies.Dockerfile
90+
- device: gpu
91+
build_mode: nightly
92+
workflow: pre-training
93+
image_name: maxtext_gpu_jax_nightly
94+
dockerfile: ./src/dependencies/dockerfiles/maxtext_gpu_dependencies.Dockerfile
7395
uses: ./.github/workflows/build_and_push_docker_image.yml
7496
with:
75-
image_name: ${{ matrix.image_name }}
97+
image_name: ${{ matrix.image_name }}${{ inputs.image_suffix }}
7698
device: ${{ matrix.device }}
7799
build_mode: ${{ matrix.build_mode }}
100+
workflow: ${{ matrix.workflow }}
78101
dockerfile: ${{ matrix.dockerfile }}
79102
maxtext_sha: ${{ needs.setup.outputs.maxtext_sha }}
80103
image_date: ${{ needs.setup.outputs.image_date }}
104+
secrets:
105+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
81106

82-
tpu-post-training-nightly:
83-
name: tpu-post-training-nightly
84-
needs: [setup]
85-
uses: ./.github/workflows/build_and_push_docker_image.yml
86-
with:
87-
image_name: maxtext_post_training_nightly
88-
device: tpu
89-
build_mode: nightly
90-
workflow: post-training
91-
dockerfile: ./src/dependencies/dockerfiles/maxtext_tpu_dependencies.Dockerfile
92-
maxtext_sha: ${{ needs.setup.outputs.maxtext_sha }}
93-
image_date: ${{ needs.setup.outputs.image_date }}
94-
95-
gpu-pre-training:
96-
name: ${{ matrix.image_name }}
97-
needs: setup
107+
promote:
108+
name: promote-${{ matrix.image_name }}
109+
needs: build-and-push
98110
strategy:
99111
fail-fast: false
100112
matrix:
101113
include:
114+
- device: tpu
115+
build_mode: stable
116+
workflow: pre-training
117+
image_name: maxtext_jax_stable
118+
- device: tpu
119+
build_mode: nightly
120+
workflow: pre-training
121+
image_name: maxtext_jax_nightly
122+
- device: tpu
123+
build_mode: nightly
124+
workflow: post-training
125+
image_name: maxtext_post_training_nightly
102126
- device: gpu
103127
build_mode: stable
128+
workflow: pre-training
104129
image_name: maxtext_gpu_jax_stable
105-
dockerfile: ./src/dependencies/dockerfiles/maxtext_gpu_dependencies.Dockerfile
106130
- device: gpu
107131
build_mode: nightly
132+
workflow: pre-training
108133
image_name: maxtext_gpu_jax_nightly
109-
dockerfile: ./src/dependencies/dockerfiles/maxtext_gpu_dependencies.Dockerfile
110-
uses: ./.github/workflows/build_and_push_docker_image.yml
134+
135+
uses: ./.github/workflows/promote_docker_image.yml
111136
with:
112-
image_name: ${{ matrix.image_name }}
137+
image_name: ${{ matrix.image_name }}${{ inputs.image_suffix }}
138+
image_tag: ${{ github.run_id }}
113139
device: ${{ matrix.device }}
114-
build_mode: ${{ matrix.build_mode }}
115-
dockerfile: ${{ matrix.dockerfile }}
116-
maxtext_sha: ${{ needs.setup.outputs.maxtext_sha }}
117-
image_date: ${{ needs.setup.outputs.image_date }}
140+
workflow: ${{ matrix.workflow }}
141+
secrets:
142+
HF_TOKEN: ${{ secrets.HF_TOKEN }}

.github/workflows/build_and_push_docker_image.yml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ on:
4545
required: false
4646
type: string
4747
default: ''
48+
secrets:
49+
HF_TOKEN:
50+
required: true
4851

4952
permissions:
5053
contents: read
@@ -80,6 +83,14 @@ jobs:
8083
INPUTS_IMAGE_NAME: ${{ inputs.image_name }}
8184
INPUTS_BUILD_MODE: ${{ inputs.build_mode }}
8285

86+
- name: Matrix Debugger
87+
run: |
88+
echo "device: ${{ inputs.device }}"
89+
echo "workflow: ${{ inputs.workflow }}"
90+
echo "build_mode: ${{ inputs.build_mode }}"
91+
echo "image_name: ${{ inputs.image_name }}"
92+
echo "dockerfile: ${{ inputs.dockerfile }}"
93+
8394
- name: Checkout MaxText
8495
uses: actions/checkout@v5
8596
if: steps.check.outputs.should_run == 'true'
@@ -126,27 +137,25 @@ jobs:
126137
shell: bash
127138
run: |
128139
SOURCE_IMAGE="gcr.io/tpu-prod-env-multipod/${INPUTS_IMAGE_NAME}"
140+
TEMP_IMG="${SOURCE_IMAGE}:${{ github.run_id }}"
129141
130142
if [[ $INPUTS_VERSION_NAME ]]; then
131143
echo "Tagging docker images corresponding to PyPI release..."
132-
gcloud container images add-tag "$SOURCE_IMAGE:${{ github.run_id }}" "$SOURCE_IMAGE:${INPUTS_VERSION_NAME}" --quiet
144+
gcloud container images add-tag "${TEMP_IMG}" "${SOURCE_IMAGE}:${INPUTS_VERSION_NAME}" --quiet
133145
else
134146
echo "Tagging docker images corresponding to nightly release..."
135147
136148
# Add date tag
137-
gcloud container images add-tag "$SOURCE_IMAGE:${{ github.run_id }}" "$SOURCE_IMAGE:${INPUTS_IMAGE_DATE}" --quiet
149+
gcloud container images add-tag "${TEMP_IMG}" "$SOURCE_IMAGE:${INPUTS_IMAGE_DATE}" --quiet
138150
139151
# Convert date to YYYYMMDD format
140152
clean_date=$(echo "${INPUTS_IMAGE_DATE}" | sed 's/[-:]//g' | cut -c1-8)
141153
142154
# Add MaxText tag
143-
maxtext_hash=$(git rev-parse --short HEAD)
144-
gcloud container images add-tag "$SOURCE_IMAGE:${{ github.run_id }}" "$SOURCE_IMAGE:maxtext_${maxtext_hash}_${clean_date}" --quiet
145-
146-
# Add latest tag (TODO: add this tag only after tests pass)
147-
gcloud container images add-tag "$SOURCE_IMAGE:${{ github.run_id }}" "$SOURCE_IMAGE:latest" --quiet
155+
gcloud container images add-tag "${TEMP_IMG}" "${SOURCE_IMAGE}:maxtext_${MAXTEXT_SHA}_${clean_date}" --quiet
148156
fi
149157
env:
150158
INPUTS_IMAGE_NAME: ${{ inputs.image_name }}
151159
INPUTS_IMAGE_DATE: ${{ inputs.image_date }}
152160
INPUTS_VERSION_NAME: ${{ inputs.version_name }}
161+
MAXTEXT_SHA: ${{ inputs.maxtext_sha }}

0 commit comments

Comments
 (0)