Add support for DistributedEmbedding for Ironwood and expose has_sparsecores.
#1046
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tests | |
| on: | |
| push: | |
| pull_request: | |
| workflow_call: | |
| release: | |
| types: [created] | |
| permissions: | |
| contents: read | |
| jobs: | |
| run_cpu_tests: | |
| name: Test the code on CPU | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| backend: [tensorflow, jax, torch] | |
| env: | |
| KERAS_BACKEND: ${{ matrix.backend }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.11" | |
| - name: Get pip cache dir | |
| id: pip-cache | |
| run: | | |
| python -m pip install --upgrade pip setuptools | |
| echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT | |
| - name: pip cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: ${{ steps.pip-cache.outputs.dir }} | |
| key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| pip install -r requirements.txt --progress-bar off | |
| pip install --no-deps -e "." --progress-bar off | |
| - name: Test with pytest | |
| run: pytest keras_rs/ | |
| run_gpu_tests: | |
| name: Test the code on GPU | |
| runs-on: linux-x86-g2-16-l4-1gpu | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| backend: [tensorflow, jax, torch] | |
| container: | |
| image: python:3.11-slim | |
| options: --privileged --network host | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Check CUDA Version | |
| run: nvidia-smi | |
| - name: Install Dependencies | |
| run: pip install --no-cache-dir -r requirements-${{ matrix.backend }}-cuda.txt | |
| - name: Set Keras Backend | |
| run: echo "KERAS_BACKEND=${{ matrix.backend }}" >> $GITHUB_ENV | |
| - name: Verify TF Installation | |
| if: ${{ matrix.backend == 'tensorflow'}} | |
| run: python3 -c "import tensorflow as tf; print('Tensorflow devices:', tf.config.list_logical_devices()); assert len(tf.config.list_physical_devices('GPU')) > 0" | |
| - name: Verify JAX Installation | |
| if: ${{ matrix.backend == 'jax'}} | |
| run: python3 -c "import jax; print('JAX devices:', jax.devices()); assert jax.default_backend() == 'gpu'" | |
| - name: Verify Torch Installation | |
| if: ${{ matrix.backend == 'torch'}} | |
| run: python3 -c "import torch; print('Torch devices:', [torch.cuda.get_device_name(i) for i in range(torch.cuda.device_count())]); assert torch.cuda.device_count() > 0" | |
| - name: Test with pytest | |
| run: pytest keras_rs/ --ignore=keras_rs/src/layers/embedding/jax | |
| run_tpu_tests: | |
| name: Test the code on TPU | |
| runs-on: linux-x86-ct6e-44-1tpu | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| backend: [tensorflow, jax] | |
| container: | |
| image: python:3.11-slim | |
| options: --privileged --network host | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| - name: Install Dependencies | |
| run: pip install --no-cache-dir -r requirements-${{ matrix.backend }}-tpu.txt | |
| - name: Set Keras Backend | |
| run: | | |
| echo "KERAS_BACKEND=${{ matrix.backend }}" >> $GITHUB_ENV | |
| echo "TPU_NAME=local" >> $GITHUB_ENV | |
| - name: Set TF Specific Environment Variables | |
| if: ${{ matrix.backend == 'tensorflow'}} | |
| run: | | |
| echo "PJRT_DEVICE=TPU" >> $GITHUB_ENV | |
| echo "NEXT_PLUGGABLE_DEVICE_USE_C_API=true" >> $GITHUB_ENV | |
| echo "TF_XLA_FLAGS=--tf_mlir_enable_mlir_bridge=true" >> $GITHUB_ENV | |
| pip show libtpu | grep "^Location: " | sed "s/^Location: \(.*\)$/TF_PLUGGABLE_DEVICE_LIBRARY_PATH=\1\/libtpu\/libtpu.so/1" >> $GITHUB_ENV | |
| - name: Verify TF Installation | |
| if: ${{ matrix.backend == 'tensorflow'}} | |
| run: python3 -c "import tensorflow as tf; print('Tensorflow devices:', tf.config.list_logical_devices()); assert len(tf.config.list_physical_devices('TPU')) > 0" | |
| - name: Verify JAX Installation | |
| if: ${{ matrix.backend == 'jax'}} | |
| run: python3 -c "import jax; print('JAX devices:', jax.devices()); assert jax.default_backend() == 'tpu'" | |
| - name: Test with pytest (TensorFlow) | |
| if: ${{ matrix.backend == 'tensorflow' }} | |
| run: pytest keras_rs/ --ignore=keras_rs/src/layers/embedding/jax | |
| - name: Test with pytest (JAX) | |
| if: ${{ matrix.backend == 'jax' }} | |
| run: pytest keras_rs/ --ignore=keras_rs/src/layers/embedding/jax/distributed_embedding_test.py | |
| check_format: | |
| name: Check the code format | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.11" | |
| - name: Get pip cache dir | |
| id: pip-cache | |
| run: | | |
| python -m pip install --upgrade pip setuptools | |
| echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT | |
| - name: pip cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: ${{ steps.pip-cache.outputs.dir }} | |
| key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| pip install -r requirements.txt --progress-bar off | |
| pip install --no-deps -e "." --progress-bar off | |
| - name: Install pre-commit | |
| run: pip install pre-commit && pre-commit install | |
| - name: Run pre-commit | |
| run: pre-commit run --all-files --hook-stage manual |