Skip to content

Commit c3b8300

Browse files
tamaranormanTorax team
authored andcommitted
Increase number of shards
PiperOrigin-RevId: 955195322
1 parent da242b3 commit c3b8300

2 files changed

Lines changed: 21 additions & 5 deletions

File tree

.github/workflows/pytest.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ concurrency:
1919
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
2020

2121
# Set the correct env variables for all the unit tests
22+
permissions:
23+
contents: read
24+
2225
env:
2326
TORAX_ERRORS_ENABLED: 1
2427
TORAX_JAXTYPING: 1
25-
PYTEST_NUM_SHARDS: 8 # Controls tests sharding enabled by `pytest-shard`
28+
PYTEST_NUM_SHARDS: 12 # Controls tests sharding enabled by `pytest-shard`
29+
JAX_ENABLE_X64: 1
2630

2731
jobs:
2832
shards-job:
@@ -57,10 +61,12 @@ jobs:
5761
os-version: [ubuntu-latest]
5862

5963
steps:
60-
- uses: actions/checkout@v6
64+
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # refs/tags/v6.1.0
65+
with:
66+
persist-credentials: false
6167

6268
# Install deps
63-
- uses: actions/setup-python@v6
69+
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # refs/tags/v6.3.0
6470
with:
6571
python-version: ${{ matrix.python-version }}
6672

@@ -71,13 +77,17 @@ jobs:
7177

7278
# Run tests (in parallel)
7379
- name: Run core tests
80+
env:
81+
SHARD_ID: ${{ matrix.shard-id }}
82+
NUM_SHARDS: ${{ matrix.num-shards }}
7483
run: |
84+
SHARD_ZERO=$((SHARD_ID - 1))
7585
pytest \
7686
-vv -n auto \
7787
--ignore=torax/tests/sim_no_compile_test.py \
78-
--shard-id=$((${{ matrix.shard-id }} - 1)) --num-shards=${{ env.PYTEST_NUM_SHARDS }}
88+
--shard-id=$SHARD_ZERO --num-shards=$NUM_SHARDS
7989
# This test requires an extra environment variable, so we run it separately.
8090
- name: Run sim_no_compile
81-
if: ${{ matrix.shard-id == 2 }}
91+
if: matrix['shard-id'] == 2
8292
run: |
8393
JAX_DISABLE_JIT=True pytest -vv -n auto torax/tests/sim_no_compile_test.py

torax/_src/tests/jax_utils_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ def setUp(self):
3030
jax_utils.get_dtype.cache_clear()
3131
jax_utils.get_int_dtype.cache_clear()
3232

33+
def tearDown(self):
34+
"""Clear the get_dtype and get_int_dtype caches after each test."""
35+
super().tearDown()
36+
jax_utils.get_dtype.cache_clear()
37+
jax_utils.get_int_dtype.cache_clear()
38+
3339
def _should_error(self):
3440
"""Assert that errors are on."""
3541
x = jnp.array(0)

0 commit comments

Comments
 (0)