Skip to content

Shard CI tests across 4 parallel jobs per backend to reduce wall-clock time#2864

Open
laxmareddyp wants to merge 2 commits into
keras-team:masterfrom
laxmareddyp:shard-ci-tests
Open

Shard CI tests across 4 parallel jobs per backend to reduce wall-clock time#2864
laxmareddyp wants to merge 2 commits into
keras-team:masterfrom
laxmareddyp:shard-ci-tests

Conversation

@laxmareddyp

@laxmareddyp laxmareddyp commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

Description of the change

Following up on #2856 which brought CI test time from 6+ hours to ~20 min by switching to self-hosted runners and adding pytest-xdist parallelization, this PR adds test sharding to further reduce wall-clock time.

Changes

.github/workflows/actions.yml

Add shard: [0, 1, 2, 3] to the test matrix — each backend (TF, JAX, Torch) now spawns 4 parallel jobs, each running ~25% of the test suite using pytest-shard
Each shard still uses -n auto (pytest-xdist) internally for core-level parallelism within the job
Integration tests run only on shard 0 to avoid duplicate execution
Special version jobs (keras-3.15, keras-nightly, openvino) run as single un-sharded jobs (already fast enough)
requirements-common.txt

Add pytest-shard dependency for --shard-id / --num-shards support

Reference

Colab Notebook

Checklist

  • I have added all the necessary unit tests for my change.
  • I have verified that my change does not break existing code and works with all backends (TensorFlow, JAX, and PyTorch).
  • My PR is based on the latest changes of the main branch (if unsure, rebase the code).
  • I have followed the Keras Hub Model contribution guidelines in making these changes.
  • I have followed the Keras Hub API design guidelines in making these changes.
  • I have signed the Contributor License Agreement.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds the pytest-shard package to the common requirements. The review feedback correctly points out that pytest-shard is unmaintained and has compatibility issues with newer versions of pytest, suggesting pytest-split as a more modern and actively maintained alternative.

Comment thread requirements-common.txt Outdated
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.

1 participant