Skip to content

Commit cc196d3

Browse files
author
Charles Li
committed
Move AotJaxprIdenticalTest to sheduled_only due to long time consuming
Add unit tests best practice section in document
1 parent c9df820 commit cc196d3

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

.github/workflows/run_pathways_tests.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,21 @@ jobs:
9292
run : gcloud storage cp gs://maxtext-test-assets/* tests/assets
9393
- name: Run Tests
9494
run: |
95+
# TODO(b/454659463): Enable test_default_hlo_match after volume mount is supported.
96+
PYTEST_MATCHER="not AotHloIdenticalTest and not CompileThenLoad"
9597
if [ "${{ inputs.is_scheduled_run }}" = "true" ]; then
9698
FINAL_PYTEST_MARKER="${{ inputs.pytest_marker }}"
9799
else
98100
FINAL_PYTEST_MARKER="${{ inputs.pytest_marker }} and not scheduled_only"
101+
# TODO(b/496201097): AotJaxprIdenticalTest costs long time due to JAX API get_topology_desc
102+
PYTEST_MATCHER="${PYTEST_MATCHER} and not AotJaxprIdenticalTest"
99103
fi
100104
export MAXTEXT_REPO_ROOT=$(pwd)
101105
export MAXTEXT_ASSETS_ROOT=$(pwd)/src/maxtext/assets
102106
export MAXTEXT_TEST_ASSETS_ROOT=$(pwd)/tests/assets
103107
export MAXTEXT_PKG_DIR=$(pwd)/src/maxtext
104-
# TODO(b/454659463): Enable test_default_hlo_match after volume mount is supported.
105-
.venv/bin/python3 -m pytest ${{ inputs.pytest_addopts }} -v -m "${FINAL_PYTEST_MARKER}" -k "not AotHloIdenticalTest and not CompileThenLoad" --durations=0
108+
109+
.venv/bin/python3 -m pytest ${{ inputs.pytest_addopts }} -v -m "${FINAL_PYTEST_MARKER}" -k "${PYTEST_MATCHER}" --durations=0
106110
env:
107111
PYTHONPATH: "${{ github.workspace }}/src"
108112
services:

docs/guides/model_bringup.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@ Core Strategy:
7676
- **Forward Pass**: Run the input through both layers. Remember to set the PyTorch model to evaluation mode (`model_pt.eval()`) to disable dropout etc.
7777
- **Compare Outputs**: Convert the PyTorch output to a JAX array (or NumPy array) and use `numpy.testing.assert_allclose` to check if the outputs are numerically close within a specified tolerance (atol, rtol).
7878

79+
Unit Tests Best Practices (performance perspective):
80+
81+
As unit tests are part of CI/CD workflow, it is critical to keep the test running fast without impacting necessary code coverage. It is recommended to follow below best practices:
82+
83+
- **Prioritize Synthetic Data (`dataset_type=synthetic`)**: Use a synthetic dataset whenever possible. This is significantly faster than using other dataset types that require loading from network storage. Only use a specific dataset type when the test's focus strictly requires it.
84+
- **Minimize Training Steps**: Keep the number of training steps to the minimum necessary to cover the intended code logic.
85+
- **Select Smallest Viable Model**: Utilize the smallest model size in unit tests that still provides adequate code coverage.
86+
- **Prioritize CPU-Only Testing**: To reduce TPU consumption for train compile-related tests, favor using `cpu_only` with a `tpu_backend` over `tpu_only` configurations.
87+
- **Move Non-Critical Tests to Scheduled-Only**: As a last resort, if the test cannot be sped up using the methods above and is not critical enough to block a Pull Request (PR), move it to run only on a schedule (`scheduled_only`). This is a compromise to improve overall CI performance.
88+
7989
## 5. End-to-end correctness
8090

8191
This verification process can vary in duration. If you're working with a small model, you're fortunate as it allows for rapid iteration on your development machine. To verify a model's correctness, we could leverage two strategies below - comparing logits and evaluation.

0 commit comments

Comments
 (0)