Run selected tests in Decoupled mode on CPU in CI - #4642
Conversation
- Register decoupled_target marker in pytest.ini for tests to be additionally validated in decoupled mode on CPU in CI. - Mark targeted test modules in unit/ and integration/ with pytestmark = [pytest.mark.decoupled_target]. - Add step in .github/workflows/run_tests_against_package.yml to execute pytest -m decoupled_target -n auto on CPU runners.
- Register decoupled_target marker in pytest.ini for tests to be additionally validated in decoupled mode on CPU in CI. - Mark targeted test modules in unit/ and integration/ with pytestmark = [pytest.mark.decoupled_target]. - Add step in .github/workflows/run_tests_against_package.yml to execute pytest -m decoupled_target -n auto on CPU runners.
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
| tpu_backend: marks tests that require a TPU-enabled JAX install (TPU PJRT plugin), but not TPU hardware | ||
| gpu_only: marks tests to be run on GPUs only | ||
| cpu_only: marks tests to be run on CPUs only | ||
| decoupled: tests that validate offline / DECOUPLE_GCLOUD=TRUE mode. |
There was a problem hiding this comment.
How about we reuse this marker instead of creating a new one decoupled_target?
There was a problem hiding this comment.
The goal is different -- decoupled says which tests are able to execute without GCP dependencies. I believe its also applied automatically for tests not explicitly excluded. Decoupled_target says which tests should we run in decoupled mode as part of CI testing (currently none of them run). If you see a way to clarify this please let me know
There was a problem hiding this comment.
I updated the comment for decoupled_target
- Register decoupled_target marker in pytest.ini for tests to be additionally validated in decoupled mode on CPU in CI. - Mark targeted test modules in unit/ and integration/ with pytestmark = [pytest.mark.decoupled_target]. - Add step in .github/workflows/run_tests_against_package.yml to execute pytest -m decoupled_target -n auto on CPU runners.
- Register decoupled_target marker in pytest.ini for tests to be additionally validated in decoupled mode on CPU in CI. - Mark targeted test modules in unit/ and integration/ with pytestmark = [pytest.mark.decoupled_target]. - Add step in .github/workflows/run_tests_against_package.yml to execute pytest -m decoupled_target -n auto on CPU runners.
- Register decoupled_target marker in pytest.ini for tests to be additionally validated in decoupled mode on CPU in CI. - Mark targeted test modules in unit/ and integration/ with pytestmark = [pytest.mark.decoupled_target]. - Add step in .github/workflows/run_tests_against_package.yml to execute pytest -m decoupled_target -n auto on CPU runners.
- Register decoupled_target marker in pytest.ini for tests to be additionally validated in decoupled mode on CPU in CI. - Mark targeted test modules in unit/ and integration/ with pytestmark = [pytest.mark.decoupled_target]. - Add step in .github/workflows/run_tests_against_package.yml to execute pytest -m decoupled_target -n auto on CPU runners.
| --junitxml=test-results-decoupled-targeted.xml | ||
| env: |
There was a problem hiding this comment.
This step landed between the previous step's run: and its env:, so that env: now belongs to this step. Run Tests loses all ten INPUTS_* vars for every flavor, it would run -m "", unsharded, with no --ignore=tests/post_training. I think this step should be moved below the env: block.
| fi | ||
| - name: Run Targeted Decoupled Tests | ||
| if: inputs.flavor == 'cpu-unit' |
There was a problem hiding this comment.
cpu-unit is a 4-way matrix (CPU_UNIT_TOTAL_WORKERS=4), so this runs in all four shards with no --splits/--group, the same 48 tests four times per PR.
| if: inputs.flavor == 'cpu-unit' | ||
| run: | | ||
| echo "Running targeted tests in decoupled mode (DECOUPLE_GCLOUD=TRUE)..." | ||
| export DECOUPLE_GCLOUD=TRUE |
There was a problem hiding this comment.
This doesn't reproduce decoupled mode here: cpu-unit installs the tpu extra, which pins google-cloud-storage>=3.13.0, and DECOUPLE_GCLOUD only changes what gcloud_stub returns, no meta_path hook exists.
a module-scope from google.cloud import storage still resolves, so #4003, #4180 and #4637 would all have passed this gate, as would today's main.
I strongly believe here decoupled requirements should be installed.
| echo "Running targeted tests in decoupled mode (DECOUPLE_GCLOUD=TRUE)..." | ||
| export DECOUPLE_GCLOUD=TRUE | ||
| $PYTHON_EXE -m pytest -v -n auto -m "decoupled_target" \ |
There was a problem hiding this comment.
Is $PYTHON_EXE empty here? since it's a shell variable from the previous step's run: body and it doesn't cross steps. So this becomes -m pytest ...
and can cause the bash: -m: command not found error. we may also see this behavior for source .venv/bin/activate, PYTHONPATH, and the cd /deps branch.
| export DECOUPLE_GCLOUD=TRUE | ||
| $PYTHON_EXE -m pytest -v -n auto -m "decoupled_target" \ | ||
| --junitxml=test-results-decoupled-targeted.xml |
There was a problem hiding this comment.
I see arg issues here: no paths, so addopts --ignores apply and 4 of the 9 tagged files never collect (48 tests from 5 files); no --ignore=tests/post_training, and -m filters after collection, so there are 14 errors during collection; -n auto only works since when there are more than one worker xdist is installed
| decoupled: tests that validate offline / DECOUPLE_GCLOUD=TRUE mode. | ||
| NOTE: this marker is not to be used manually, it is auto- | ||
| applied to tests with external_* or tpu_only marker. | ||
| applied to tests without external_* or tpu_only marker. |
There was a problem hiding this comment.
tpu_only tests do get the decoupled marker
| applied to tests without external_* or tpu_only marker. | |
| all tests except external_serving / external_training. |
| with DECOUPLE_GCLOUD=TRUE, conftest.py automatically | ||
| selects at runtime only those tests that can run in |
There was a problem hiding this comment.
conftest.py only deselects external_serving / external_training; it doesn't judge whether a test can run decoupled. this PR selects -m "decoupled_target", not decoupled and decoupled_target, so that marker isn't involved at all.
| import pytest | ||
| import safetensors.numpy | ||
|
|
||
| pytestmark = [pytest.mark.decoupled_target] |
There was a problem hiding this comment.
#4637 is a prerequisite for this to run without failures.
| from maxtext.checkpoint_conversion import to_maxtext | ||
|
|
||
| pytestmark = [pytest.mark.integration_test] | ||
| pytestmark = [pytest.mark.integration_test, pytest.mark.decoupled_target] |
There was a problem hiding this comment.
cpu-unit's marker deliberately excludes integration tests so we don't need this.
This PR adds a targeted decoupled test suite executed with
DECOUPLE_GCLOUD=TRUEon CPU in CI to validate fragile offline components (checkpointing, quantization, GRPO NNX loss dispatch).Changes:
pytest.ini: Registereddecoupled_targetmarker ("tests to be additionally validated in decoupled mode (DECOUPLE_GCLOUD=TRUE) on CPU in CI.").tests/unit/andtests/integration/withpytestmark = [pytest.mark.decoupled_target].inputs.flavor == 'cpu-unit'executing$PYTHON_EXE -m pytest -v -n auto -m "decoupled_target".Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.