Skip to content

Run selected tests in Decoupled mode on CPU in CI - #4642

Open
shralex wants to merge 6 commits into
mainfrom
decoupled-mode-testing
Open

Run selected tests in Decoupled mode on CPU in CI#4642
shralex wants to merge 6 commits into
mainfrom
decoupled-mode-testing

Conversation

@shralex

@shralex shralex commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

This PR adds a targeted decoupled test suite executed with DECOUPLE_GCLOUD=TRUE on CPU in CI to validate fragile offline components (checkpointing, quantization, GRPO NNX loss dispatch).

Changes:

  1. pytest.ini: Registered decoupled_target marker ("tests to be additionally validated in decoupled mode (DECOUPLE_GCLOUD=TRUE) on CPU in CI.").
  2. Test Modules: Tagged 9 target test files across tests/unit/ and tests/integration/ with pytestmark = [pytest.mark.decoupled_target].
  3. CI Pipeline (.github/workflows/run_tests_against_package.yml): Added a step under 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):

  • I have performed a self-review of my code. For an optional AI review, add the gemini-review label.
  • I have necessary comments in my code, particularly in hard-to-understand areas.
  • I have run end-to-end tests tests and provided workload links above if applicable.
  • I have made or will make corresponding changes to the doc if needed, including adding new documentation pages to the relevant Table of Contents (toctree directive) as explained in our documentation.

shralex added 2 commits July 28, 2026 12:09
- 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.
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

Comment thread pytest.ini
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.

@SurbhiJainUSC SurbhiJainUSC Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we reuse this marker instead of creating a new one decoupled_target?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the comment for decoupled_target

shralex added 4 commits July 28, 2026 16:40
- 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:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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" \

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread pytest.ini
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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tpu_only tests do get the decoupled marker

Suggested change
applied to tests without external_* or tpu_only marker.
all tests except external_serving / external_training.

Comment thread pytest.ini
Comment on lines +51 to +52
with DECOUPLE_GCLOUD=TRUE, conftest.py automatically
selects at runtime only those tests that can run in

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#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]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cpu-unit's marker deliberately excludes integration tests so we don't need this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants