From 6c0dbdded167ba5dcbe91ea60cd67ed57470c8fe Mon Sep 17 00:00:00 2001 From: lanctot Date: Mon, 13 Nov 2023 17:35:40 -0330 Subject: [PATCH 01/25] Enable universal2 binary wheels, take 2 - Cross-compile both `x86_64` and `arm64` into the universal2 wheels - Add CIBW_TEST_SKIP command to skip and silence the arm64 tests until they are available --- .github/workflows/wheels.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 177126ec4c..478d35d7a7 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -37,7 +37,7 @@ jobs: OS_TYPE: "Darwin" CI_PYBIN: python3.9 CIBW_ENVIRONMENT: "OPEN_SPIEL_BUILDING_WHEEL='ON' OPEN_SPIEL_BUILD_WITH_ACPC='ON' OPEN_SPIEL_BUILD_WITH_HANABI='ON' OPEN_SPIEL_BUILD_WITH_ROSHAMBO='ON'" - CIBW_BUILD: cp38-macosx_universal2 cp39-macosx_universal2 cp310-macosx_universal2 cp310-macosx_universal2 cp311-macosx_universal2 cp312-macosx_universal2 + CIBW_BUILD: cp38-macosx_x86_64 cp39-macosx_universal2 cp310-macosx_universal2 cp310-macosx_universal2 cp311-macosx_universal2 cp312-macosx_universal2 env: OPEN_SPIEL_BUILDING_WHEEL: ON OPEN_SPIEL_BUILD_WITH_ACPC: ON @@ -47,12 +47,13 @@ jobs: OS_PYTHON_VERSION: "3.9" CI_PYBIN: ${{ matrix.CI_PYBIN }} CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 - CIBW_ARCHS_MACOS: universal2 + CIBW_ARCHS_MACOS: x86_64 arm64 universal2 CIBW_BUILD: ${{ matrix.CIBW_BUILD }} CIBW_SKIP: pp* CIBW_BEFORE_BUILD: python -m pip install --upgrade cmake CIBW_BEFORE_TEST: python -m pip install --upgrade pip CIBW_TEST_COMMAND: /bin/bash {project}/open_spiel/scripts/test_wheel.sh basic {project} + CIBW_TEST_SKIP: "*_arm64 *_universal2:arm64" CIBW_ENVIRONMENT: ${{ matrix.CIBW_ENVIRONMENT }} steps: From 7bd97e76523ba56f53f2eebf3ea57acffd2db6c9 Mon Sep 17 00:00:00 2001 From: lanctot Date: Mon, 13 Nov 2023 20:18:25 -0330 Subject: [PATCH 02/25] Built x86_64 and arm64 wheels separately --- .github/workflows/wheels.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 478d35d7a7..50177cb63e 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -37,7 +37,7 @@ jobs: OS_TYPE: "Darwin" CI_PYBIN: python3.9 CIBW_ENVIRONMENT: "OPEN_SPIEL_BUILDING_WHEEL='ON' OPEN_SPIEL_BUILD_WITH_ACPC='ON' OPEN_SPIEL_BUILD_WITH_HANABI='ON' OPEN_SPIEL_BUILD_WITH_ROSHAMBO='ON'" - CIBW_BUILD: cp38-macosx_x86_64 cp39-macosx_universal2 cp310-macosx_universal2 cp310-macosx_universal2 cp311-macosx_universal2 cp312-macosx_universal2 + CIBW_BUILD: cp38-macosx_x86_64 cp39-macosx_x86_64 cp39-macosx_arm64 cp310-macosx_x86_64 cp310-macosx_arm64 cp311-macosx_x86_64 cp311-macosx_arm64 cp312-macosx_x86_64 cp312-macosx_arm64 env: OPEN_SPIEL_BUILDING_WHEEL: ON OPEN_SPIEL_BUILD_WITH_ACPC: ON @@ -47,7 +47,6 @@ jobs: OS_PYTHON_VERSION: "3.9" CI_PYBIN: ${{ matrix.CI_PYBIN }} CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 - CIBW_ARCHS_MACOS: x86_64 arm64 universal2 CIBW_BUILD: ${{ matrix.CIBW_BUILD }} CIBW_SKIP: pp* CIBW_BEFORE_BUILD: python -m pip install --upgrade cmake From 2cae6caa510473455c1023b503aacca9c524a43b Mon Sep 17 00:00:00 2001 From: Marc Lanctot Date: Mon, 13 Nov 2023 21:05:50 -0330 Subject: [PATCH 03/25] Fix name and add back CIBW_ARCHS_MACOS --- .github/workflows/wheels.yml | 1 + open_spiel/scripts/test_wheel.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 50177cb63e..1f4946b603 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -49,6 +49,7 @@ jobs: CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 CIBW_BUILD: ${{ matrix.CIBW_BUILD }} CIBW_SKIP: pp* + CIBW_ARCHS_MACOS: x86_64 arm64 CIBW_BEFORE_BUILD: python -m pip install --upgrade cmake CIBW_BEFORE_TEST: python -m pip install --upgrade pip CIBW_TEST_COMMAND: /bin/bash {project}/open_spiel/scripts/test_wheel.sh basic {project} diff --git a/open_spiel/scripts/test_wheel.sh b/open_spiel/scripts/test_wheel.sh index 28360706d7..eee2e40f68 100755 --- a/open_spiel/scripts/test_wheel.sh +++ b/open_spiel/scripts/test_wheel.sh @@ -65,7 +65,7 @@ if [[ "$MODE" = "full" ]]; then if [[ "$OS" = "Linux" ]]; then ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl else - ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp39-cp39-macosx_10_9_universal2.whl + ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp39-cp39-macosx_10_9_x86_64.whl fi fi From 0b2606d6d0b7e290680ca69f632a7ae97bea1b7a Mon Sep 17 00:00:00 2001 From: Marc Lanctot Date: Mon, 13 Nov 2023 21:12:28 -0330 Subject: [PATCH 04/25] Add archs flag to cibuildwheel call --- .github/workflows/wheels.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 1f4946b603..0144589c09 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -31,11 +31,13 @@ jobs: - os: ubuntu-20.04 OS_TYPE: "Linux" CI_PYBIN: python3 + ARCHS: x86_64 CIBW_ENVIRONMENT: "CXX=$(which g++) OPEN_SPIEL_BUILDING_WHEEL='ON' OPEN_SPIEL_BUILD_WITH_ACPC='ON' OPEN_SPIEL_BUILD_WITH_HANABI='ON' OPEN_SPIEL_BUILD_WITH_ROSHAMBO='ON'" CIBW_BUILD: cp38-manylinux_x86_64 cp39-manylinux_x86_64 cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64 - os: macOS-12 OS_TYPE: "Darwin" CI_PYBIN: python3.9 + ARCHS: "x86_64,arm64" CIBW_ENVIRONMENT: "OPEN_SPIEL_BUILDING_WHEEL='ON' OPEN_SPIEL_BUILD_WITH_ACPC='ON' OPEN_SPIEL_BUILD_WITH_HANABI='ON' OPEN_SPIEL_BUILD_WITH_ROSHAMBO='ON'" CIBW_BUILD: cp38-macosx_x86_64 cp39-macosx_x86_64 cp39-macosx_arm64 cp310-macosx_x86_64 cp310-macosx_arm64 cp311-macosx_x86_64 cp311-macosx_arm64 cp312-macosx_x86_64 cp312-macosx_arm64 env: @@ -46,6 +48,7 @@ jobs: OS_TYPE: ${{ matrix.OS_TYPE }} OS_PYTHON_VERSION: "3.9" CI_PYBIN: ${{ matrix.CI_PYBIN }} + ARCHS: ${{ matrix.ARCHS }} CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 CIBW_BUILD: ${{ matrix.CIBW_BUILD }} CIBW_SKIP: pp* @@ -92,7 +95,7 @@ jobs: # Basic tests are run via the CIBW_TEST_COMMAND environment variable. - name: Build bdist_wheel and run tests run: | - ${CI_PYBIN} -m cibuildwheel --output-dir wheelhouse + ${CI_PYBIN} -m cibuildwheel --archs ${ARCHS} --output-dir wheelhouse ls -l wheelhouse # Install the built wheel and run the full tests on this host. The full From 9723c9fc7b5b29ef21fb31fbabb7fa36f7c18793 Mon Sep 17 00:00:00 2001 From: lanctot Date: Tue, 14 Nov 2023 06:49:13 -0330 Subject: [PATCH 05/25] Update wheels.yml --- .github/workflows/wheels.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 0144589c09..5a670d7c46 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -95,6 +95,7 @@ jobs: # Basic tests are run via the CIBW_TEST_COMMAND environment variable. - name: Build bdist_wheel and run tests run: | + xcodebuild -version ${CI_PYBIN} -m cibuildwheel --archs ${ARCHS} --output-dir wheelhouse ls -l wheelhouse From 70bbde35861badf1e6dd8fd9366fc1f1b05aaf2e Mon Sep 17 00:00:00 2001 From: lanctot Date: Tue, 14 Nov 2023 06:56:07 -0330 Subject: [PATCH 06/25] Update wheels.yml --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 5a670d7c46..a32eb62208 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -95,7 +95,7 @@ jobs: # Basic tests are run via the CIBW_TEST_COMMAND environment variable. - name: Build bdist_wheel and run tests run: | - xcodebuild -version + [[ "${OS_TYPE}" = "Darwin" ]] && xcodebuild -version ${CI_PYBIN} -m cibuildwheel --archs ${ARCHS} --output-dir wheelhouse ls -l wheelhouse From ddb78943d65825171fb3ac351a2116ea225090cf Mon Sep 17 00:00:00 2001 From: lanctot Date: Tue, 14 Nov 2023 10:52:39 -0330 Subject: [PATCH 07/25] Use new MacOS-13 runner to build arm64 wheels --- .github/workflows/wheels.yml | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index a32eb62208..06523c95f4 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -31,32 +31,37 @@ jobs: - os: ubuntu-20.04 OS_TYPE: "Linux" CI_PYBIN: python3 - ARCHS: x86_64 CIBW_ENVIRONMENT: "CXX=$(which g++) OPEN_SPIEL_BUILDING_WHEEL='ON' OPEN_SPIEL_BUILD_WITH_ACPC='ON' OPEN_SPIEL_BUILD_WITH_HANABI='ON' OPEN_SPIEL_BUILD_WITH_ROSHAMBO='ON'" CIBW_BUILD: cp38-manylinux_x86_64 cp39-manylinux_x86_64 cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64 - os: macOS-12 OS_TYPE: "Darwin" CI_PYBIN: python3.9 - ARCHS: "x86_64,arm64" + OS_PYTHON_VERSION: 3.9 CIBW_ENVIRONMENT: "OPEN_SPIEL_BUILDING_WHEEL='ON' OPEN_SPIEL_BUILD_WITH_ACPC='ON' OPEN_SPIEL_BUILD_WITH_HANABI='ON' OPEN_SPIEL_BUILD_WITH_ROSHAMBO='ON'" - CIBW_BUILD: cp38-macosx_x86_64 cp39-macosx_x86_64 cp39-macosx_arm64 cp310-macosx_x86_64 cp310-macosx_arm64 cp311-macosx_x86_64 cp311-macosx_arm64 cp312-macosx_x86_64 cp312-macosx_arm64 + CIBW_BUILD: cp38-macosx_x86_64 cp39-macosx_x86_64 cp310-macosx_x86_64 cp311-macosx_x86_64 cp312-macosx_x86_64 + # Setting to the new M1 runners to build the _arm64 wheels + # https://github.blog/2023-10-02-introducing-the-new-apple-silicon-powered-m1-macos-larger-runner-for-github-actions/ + # TODO(lanctot): Set this to macos-13 once these runnings are no longer in beta + - os: macos-13-arm64 + OS_TYPE: "Darwin" + CI_PYBIN: python3.11 + OS_PYTHON_VERSION: 3.11 + CIBW_ENVIRONMENT: "OPEN_SPIEL_BUILDING_WHEEL='ON' OPEN_SPIEL_BUILD_WITH_ACPC='ON' OPEN_SPIEL_BUILD_WITH_HANABI='ON' OPEN_SPIEL_BUILD_WITH_ROSHAMBO='ON'" + CIBW_BUILD: cp39-macosx_arm64 cp310-macosx_arm64 cp311-macosx_arm64 cp312-macosx_arm64 env: OPEN_SPIEL_BUILDING_WHEEL: ON OPEN_SPIEL_BUILD_WITH_ACPC: ON OPEN_SPIEL_BUILD_WITH_HANABI: ON OPEN_SPIEL_BUILD_WITH_ROSHAMBO: ON OS_TYPE: ${{ matrix.OS_TYPE }} - OS_PYTHON_VERSION: "3.9" + OS_PYTHON_VERSION: ${{ matrix.OS_PYTHON_VERSION }} CI_PYBIN: ${{ matrix.CI_PYBIN }} - ARCHS: ${{ matrix.ARCHS }} CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 CIBW_BUILD: ${{ matrix.CIBW_BUILD }} CIBW_SKIP: pp* - CIBW_ARCHS_MACOS: x86_64 arm64 CIBW_BEFORE_BUILD: python -m pip install --upgrade cmake CIBW_BEFORE_TEST: python -m pip install --upgrade pip CIBW_TEST_COMMAND: /bin/bash {project}/open_spiel/scripts/test_wheel.sh basic {project} - CIBW_TEST_SKIP: "*_arm64 *_universal2:arm64" CIBW_ENVIRONMENT: ${{ matrix.CIBW_ENVIRONMENT }} steps: @@ -96,7 +101,7 @@ jobs: - name: Build bdist_wheel and run tests run: | [[ "${OS_TYPE}" = "Darwin" ]] && xcodebuild -version - ${CI_PYBIN} -m cibuildwheel --archs ${ARCHS} --output-dir wheelhouse + ${CI_PYBIN} -m cibuildwheel --output-dir wheelhouse ls -l wheelhouse # Install the built wheel and run the full tests on this host. The full From ba2ab3b47c86412273205ae881534d09be808f3e Mon Sep 17 00:00:00 2001 From: lanctot Date: Tue, 14 Nov 2023 10:54:22 -0330 Subject: [PATCH 08/25] Update test_wheel.sh to install correct wheel --- open_spiel/scripts/test_wheel.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/open_spiel/scripts/test_wheel.sh b/open_spiel/scripts/test_wheel.sh index eee2e40f68..e82928051d 100755 --- a/open_spiel/scripts/test_wheel.sh +++ b/open_spiel/scripts/test_wheel.sh @@ -64,8 +64,10 @@ fi if [[ "$MODE" = "full" ]]; then if [[ "$OS" = "Linux" ]]; then ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl - else + elif [[ "$OS" = "Darwn" && "$OS_PYTHON_VERSION" = "3.9" ]]; then ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp39-cp39-macosx_10_9_x86_64.whl + else + ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp311-cp311-macosx_13_6_arm64.whl fi fi From fafb388956bfa0623e0e2bf86a166543281a0b00 Mon Sep 17 00:00:00 2001 From: lanctot Date: Tue, 14 Nov 2023 10:56:50 -0330 Subject: [PATCH 09/25] Update wheels.yml --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 06523c95f4..e8566646fa 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -42,7 +42,7 @@ jobs: # Setting to the new M1 runners to build the _arm64 wheels # https://github.blog/2023-10-02-introducing-the-new-apple-silicon-powered-m1-macos-larger-runner-for-github-actions/ # TODO(lanctot): Set this to macos-13 once these runnings are no longer in beta - - os: macos-13-arm64 + - os: macos-13-xlarge OS_TYPE: "Darwin" CI_PYBIN: python3.11 OS_PYTHON_VERSION: 3.11 From c0eeb0bda80a3b3e8e8c28414bce89918dac9390 Mon Sep 17 00:00:00 2001 From: lanctot Date: Tue, 14 Nov 2023 11:01:46 -0330 Subject: [PATCH 10/25] Try increasing torch to 2.1.0... --- open_spiel/scripts/python_extra_deps.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/open_spiel/scripts/python_extra_deps.sh b/open_spiel/scripts/python_extra_deps.sh index 744922b736..d0448669cd 100644 --- a/open_spiel/scripts/python_extra_deps.sh +++ b/open_spiel/scripts/python_extra_deps.sh @@ -45,12 +45,6 @@ verlt() { [ "$1" = "$2" ] && return 1 || verlte $1 $2 } -# -# Python extra deps that work across all supported versions -# -export OPEN_SPIEL_PYTHON_PYTORCH_DEPS="torch==1.13.1" - - # # Python-version dependent versions # @@ -58,11 +52,13 @@ export OPEN_SPIEL_PYTHON_PYTORCH_DEPS="torch==1.13.1" echo "Set Python version: $PY_VER" if verlt $PY_VER 3.10; then echo "Python < 3.10 detected" + export OPEN_SPIEL_PYTHON_PYTORCH_DEPS="torch==1.13.1" export OPEN_SPIEL_PYTHON_JAX_DEPS="jax==0.4.6 jaxlib==0.4.6 dm-haiku==0.0.10 optax==0.1.7 chex==0.1.7 rlax==0.1.5 distrax==0.1.3" export OPEN_SPIEL_PYTHON_TENSORFLOW_DEPS="numpy==1.23.5 tensorflow==2.13.1 tensorflow-probability==0.19.0 tensorflow_datasets==4.9.2 keras==2.13.1" export OPEN_SPIEL_PYTHON_MISC_DEPS="IPython==5.8.0 networkx==2.4 matplotlib==3.5.2 mock==4.0.2 nashpy==0.0.19 scipy==1.10.1 testresources==2.0.1 cvxopt==1.3.1 cvxpy==1.2.0 ecos==2.0.10 osqp==0.6.2.post5 clu==0.0.6 flax==0.5.3" else echo "Python >= 3.10 detected" + export OPEN_SPIEL_PYTHON_PYTORCH_DEPS="torch==2.1.0" export OPEN_SPIEL_PYTHON_JAX_DEPS="jax==0.4.20 jaxlib==0.4.20 dm-haiku==0.0.10 optax==0.1.7 chex==0.1.84 rlax==0.1.6 distrax==0.1.4" export OPEN_SPIEL_PYTHON_TENSORFLOW_DEPS="numpy==1.26.1 tensorflow==2.14.0 tensorflow-probability==0.22.1 tensorflow_datasets==4.9.2 keras==2.14.0" export OPEN_SPIEL_PYTHON_MISC_DEPS="IPython==5.8.0 networkx==3.2 matplotlib==3.5.2 mock==4.0.2 nashpy==0.0.19 scipy==1.11.3 testresources==2.0.1 cvxopt==1.3.1 cvxpy==1.4.1 ecos==2.0.10 osqp==0.6.2.post5 clu==0.0.6 flax==0.5.3" From a0c06f23ed5d318c9de3d1477acadf732eed13f9 Mon Sep 17 00:00:00 2001 From: lanctot Date: Tue, 14 Nov 2023 11:06:33 -0330 Subject: [PATCH 11/25] Install pipx on MacOS --- .github/workflows/wheels.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index e8566646fa..eebdc568fd 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -93,6 +93,7 @@ jobs: ${CI_PYBIN} -m pip install cibuildwheel==2.16.2 - name: Build sdist run: | + [[ "{OS_TYPE}" = "Darwin" ]] && brew install pipx pipx run build --sdist twine check dist/*.tar.gz From fc6b154cfca048963829db5e915c978d0035ab4b Mon Sep 17 00:00:00 2001 From: lanctot Date: Tue, 14 Nov 2023 11:16:28 -0330 Subject: [PATCH 12/25] Update wheels.yml --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index eebdc568fd..eebefc3df1 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -73,6 +73,7 @@ jobs: uname -a [[ "${OS_TYPE}" = "Darwin" ]] && brew install python@${OS_PYTHON_VERSION} [[ "${OS_TYPE}" = "Darwin" ]] && brew link --force python@${OS_PYTHON_VERSION} + [[ "${OS_TYPE}" = "Darwin" ]] && brew install pipx which g++ g++ --version chmod +x install.sh @@ -93,7 +94,6 @@ jobs: ${CI_PYBIN} -m pip install cibuildwheel==2.16.2 - name: Build sdist run: | - [[ "{OS_TYPE}" = "Darwin" ]] && brew install pipx pipx run build --sdist twine check dist/*.tar.gz From f41c7254733808849c96f2442f34a509761819c4 Mon Sep 17 00:00:00 2001 From: lanctot Date: Tue, 14 Nov 2023 11:18:50 -0330 Subject: [PATCH 13/25] Update wheels.yml --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index eebefc3df1..2a0bd9b05e 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -73,7 +73,6 @@ jobs: uname -a [[ "${OS_TYPE}" = "Darwin" ]] && brew install python@${OS_PYTHON_VERSION} [[ "${OS_TYPE}" = "Darwin" ]] && brew link --force python@${OS_PYTHON_VERSION} - [[ "${OS_TYPE}" = "Darwin" ]] && brew install pipx which g++ g++ --version chmod +x install.sh @@ -94,6 +93,7 @@ jobs: ${CI_PYBIN} -m pip install cibuildwheel==2.16.2 - name: Build sdist run: | + [[ "${OS_TYPE}" = "Darwin" ]] && brew install pipx pipx run build --sdist twine check dist/*.tar.gz From bfb7a9c118341457d6ec20dc29b7b7ea18b821d2 Mon Sep 17 00:00:00 2001 From: Marc Lanctot Date: Tue, 14 Nov 2023 11:26:19 -0330 Subject: [PATCH 14/25] Move to Python 3.12 on macos-13-xlarge --- .github/workflows/wheels.yml | 4 ++-- open_spiel/scripts/test_wheel.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 2a0bd9b05e..6f9c62a91d 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -44,8 +44,8 @@ jobs: # TODO(lanctot): Set this to macos-13 once these runnings are no longer in beta - os: macos-13-xlarge OS_TYPE: "Darwin" - CI_PYBIN: python3.11 - OS_PYTHON_VERSION: 3.11 + CI_PYBIN: python3.12 + OS_PYTHON_VERSION: 3.12 CIBW_ENVIRONMENT: "OPEN_SPIEL_BUILDING_WHEEL='ON' OPEN_SPIEL_BUILD_WITH_ACPC='ON' OPEN_SPIEL_BUILD_WITH_HANABI='ON' OPEN_SPIEL_BUILD_WITH_ROSHAMBO='ON'" CIBW_BUILD: cp39-macosx_arm64 cp310-macosx_arm64 cp311-macosx_arm64 cp312-macosx_arm64 env: diff --git a/open_spiel/scripts/test_wheel.sh b/open_spiel/scripts/test_wheel.sh index e82928051d..9ef65804bb 100755 --- a/open_spiel/scripts/test_wheel.sh +++ b/open_spiel/scripts/test_wheel.sh @@ -67,7 +67,7 @@ if [[ "$MODE" = "full" ]]; then elif [[ "$OS" = "Darwn" && "$OS_PYTHON_VERSION" = "3.9" ]]; then ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp39-cp39-macosx_10_9_x86_64.whl else - ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp311-cp311-macosx_13_6_arm64.whl + ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp312-cp312-macosx_13_6_arm64.whl fi fi From 6244b424e1235b40d09448c9ec00fa561a1c09f8 Mon Sep 17 00:00:00 2001 From: Marc Lanctot Date: Tue, 14 Nov 2023 11:31:33 -0330 Subject: [PATCH 15/25] Back down to Python 3.11 and run pipx with a flag --- .github/workflows/wheels.yml | 8 ++++---- open_spiel/scripts/test_wheel.sh | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 6f9c62a91d..e41e059ae1 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -44,8 +44,8 @@ jobs: # TODO(lanctot): Set this to macos-13 once these runnings are no longer in beta - os: macos-13-xlarge OS_TYPE: "Darwin" - CI_PYBIN: python3.12 - OS_PYTHON_VERSION: 3.12 + CI_PYBIN: python3.11 + OS_PYTHON_VERSION: 3.11 CIBW_ENVIRONMENT: "OPEN_SPIEL_BUILDING_WHEEL='ON' OPEN_SPIEL_BUILD_WITH_ACPC='ON' OPEN_SPIEL_BUILD_WITH_HANABI='ON' OPEN_SPIEL_BUILD_WITH_ROSHAMBO='ON'" CIBW_BUILD: cp39-macosx_arm64 cp310-macosx_arm64 cp311-macosx_arm64 cp312-macosx_arm64 env: @@ -71,6 +71,7 @@ jobs: run: | pwd uname -a + [[ "${OS_TYPE}" = "Darwin" ]] && brew install pipx [[ "${OS_TYPE}" = "Darwin" ]] && brew install python@${OS_PYTHON_VERSION} [[ "${OS_TYPE}" = "Darwin" ]] && brew link --force python@${OS_PYTHON_VERSION} which g++ @@ -93,8 +94,7 @@ jobs: ${CI_PYBIN} -m pip install cibuildwheel==2.16.2 - name: Build sdist run: | - [[ "${OS_TYPE}" = "Darwin" ]] && brew install pipx - pipx run build --sdist + pipx run build --sdist --python python${OS_PYTHON_VERSION} twine check dist/*.tar.gz # Build all the wheels and run the basic tests (within the docker images) diff --git a/open_spiel/scripts/test_wheel.sh b/open_spiel/scripts/test_wheel.sh index 9ef65804bb..e82928051d 100755 --- a/open_spiel/scripts/test_wheel.sh +++ b/open_spiel/scripts/test_wheel.sh @@ -67,7 +67,7 @@ if [[ "$MODE" = "full" ]]; then elif [[ "$OS" = "Darwn" && "$OS_PYTHON_VERSION" = "3.9" ]]; then ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp39-cp39-macosx_10_9_x86_64.whl else - ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp312-cp312-macosx_13_6_arm64.whl + ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp311-cp311-macosx_13_6_arm64.whl fi fi From 577f7fa9da0fa6c42bd498f0abfc76f497a24379 Mon Sep 17 00:00:00 2001 From: Marc Lanctot Date: Tue, 14 Nov 2023 11:35:59 -0330 Subject: [PATCH 16/25] Install pipx via pip --- .github/workflows/wheels.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index e41e059ae1..0a8bbcecc6 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -71,9 +71,9 @@ jobs: run: | pwd uname -a - [[ "${OS_TYPE}" = "Darwin" ]] && brew install pipx [[ "${OS_TYPE}" = "Darwin" ]] && brew install python@${OS_PYTHON_VERSION} [[ "${OS_TYPE}" = "Darwin" ]] && brew link --force python@${OS_PYTHON_VERSION} + [[ "${OS_TYPE}" = "Darwin" ]] && ${CI_BIN} -m pip install pipx which g++ g++ --version chmod +x install.sh @@ -94,7 +94,7 @@ jobs: ${CI_PYBIN} -m pip install cibuildwheel==2.16.2 - name: Build sdist run: | - pipx run build --sdist --python python${OS_PYTHON_VERSION} + pipx run build --sdist twine check dist/*.tar.gz # Build all the wheels and run the basic tests (within the docker images) From 986da437d4d051b138e9abd35bce630d2b4eb19a Mon Sep 17 00:00:00 2001 From: Marc Lanctot Date: Tue, 14 Nov 2023 11:38:03 -0330 Subject: [PATCH 17/25] Move command --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 0a8bbcecc6..438107416b 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -73,7 +73,6 @@ jobs: uname -a [[ "${OS_TYPE}" = "Darwin" ]] && brew install python@${OS_PYTHON_VERSION} [[ "${OS_TYPE}" = "Darwin" ]] && brew link --force python@${OS_PYTHON_VERSION} - [[ "${OS_TYPE}" = "Darwin" ]] && ${CI_BIN} -m pip install pipx which g++ g++ --version chmod +x install.sh @@ -83,6 +82,7 @@ jobs: # These are necessary to install what is necessary for the build and for the full tests below. ${CI_PYBIN} -m pip install --upgrade pip ${CI_PYBIN} -m pip --version + [[ "${OS_TYPE}" = "Darwin" ]] && ${CI_PYBIN} -m pip install pipx ${CI_PYBIN} -m pip install --upgrade setuptools ${CI_PYBIN} -m pip install --upgrade -r requirements.txt -q source ./open_spiel/scripts/python_extra_deps.sh ${CI_PYBIN} From 4fc4d164d3ace6417bf97529a1bde60f95b0f3bd Mon Sep 17 00:00:00 2001 From: Marc Lanctot Date: Tue, 14 Nov 2023 11:48:49 -0330 Subject: [PATCH 18/25] Update test_wheel.sh --- open_spiel/scripts/test_wheel.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/open_spiel/scripts/test_wheel.sh b/open_spiel/scripts/test_wheel.sh index e82928051d..15096269c1 100755 --- a/open_spiel/scripts/test_wheel.sh +++ b/open_spiel/scripts/test_wheel.sh @@ -67,7 +67,7 @@ if [[ "$MODE" = "full" ]]; then elif [[ "$OS" = "Darwn" && "$OS_PYTHON_VERSION" = "3.9" ]]; then ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp39-cp39-macosx_10_9_x86_64.whl else - ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp311-cp311-macosx_13_6_arm64.whl + ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp311-cp311-macosx_11_0_arm64.whl fi fi @@ -79,7 +79,7 @@ rm -rf build && mkdir build && cd build cmake -DPython3_EXECUTABLE=${PYBIN} $PROJDIR/open_spiel NPROC="nproc" -if [[ "$OS" == "darwin"* ]]; then +if [[ "$OS" == "darwin"* || "$OS" == "Darwin"* ]]; then NPROC="sysctl -n hw.physicalcpu" fi From 43492626ecd22e7e003cbb613ca57752268915d9 Mon Sep 17 00:00:00 2001 From: Marc Lanctot Date: Tue, 14 Nov 2023 12:13:23 -0330 Subject: [PATCH 19/25] Change cfr_br python test to use AlmostEqual --- open_spiel/python/algorithms/cfr_br_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/open_spiel/python/algorithms/cfr_br_test.py b/open_spiel/python/algorithms/cfr_br_test.py index 34ca457271..77ed42d091 100644 --- a/open_spiel/python/algorithms/cfr_br_test.py +++ b/open_spiel/python/algorithms/cfr_br_test.py @@ -94,7 +94,7 @@ def test_cpp_and_python_cfr_br(self, game, solver_cls, else: exploitability_ = exploitability.nash_conv(game, avg_policy) - self.assertEqual(expected_exploitability[step], exploitability_) + self.assertAlmostEqual(expected_exploitability[step], exploitability_, places=10) if __name__ == "__main__": From 9368cb6b7c3ab34f76e782a7f8d5b4ddcd6dcd1d Mon Sep 17 00:00:00 2001 From: Marc Lanctot Date: Tue, 14 Nov 2023 12:15:44 -0330 Subject: [PATCH 20/25] Use AlmostEqual to compare doubles --- open_spiel/python/algorithms/cfr_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/open_spiel/python/algorithms/cfr_test.py b/open_spiel/python/algorithms/cfr_test.py index 3ae6ebfe5b..e5c5da74bb 100644 --- a/open_spiel/python/algorithms/cfr_test.py +++ b/open_spiel/python/algorithms/cfr_test.py @@ -262,7 +262,7 @@ def test_cpp_algorithms_identical_to_python_algorithm(self, game, cpp_class, # convert one to the other, so we use the exploitability as a proxy. cpp_expl = pyspiel.nash_conv(game, cpp_avg_policy) python_expl = exploitability.nash_conv(game, python_avg_policy) - self.assertEqual(cpp_expl, python_expl) + self.assertAlmostEqual(cpp_expl, python_expl, places=10) # Then we also check the CurrentPolicy, just to check it is giving the same # results too cpp_current_policy = cpp_solver.current_policy() From e42f7e2e370923e0c52bc7b9c4c5471a3e55e8fe Mon Sep 17 00:00:00 2001 From: Marc Lanctot Date: Tue, 14 Nov 2023 12:25:08 -0330 Subject: [PATCH 21/25] One more test change for AlmostEqual --- open_spiel/python/algorithms/cfr_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/open_spiel/python/algorithms/cfr_test.py b/open_spiel/python/algorithms/cfr_test.py index e5c5da74bb..5d881f12dc 100644 --- a/open_spiel/python/algorithms/cfr_test.py +++ b/open_spiel/python/algorithms/cfr_test.py @@ -269,7 +269,7 @@ def test_cpp_algorithms_identical_to_python_algorithm(self, game, cpp_class, python_current_policy = python_solver.current_policy() cpp_expl = pyspiel.nash_conv(game, cpp_current_policy) python_expl = exploitability.nash_conv(game, python_current_policy) - self.assertEqual(cpp_expl, python_expl) + self.assertAlmostEqual(cpp_expl, python_expl, places=10) class CorrDistTest(absltest.TestCase): From 987e4dcd1f123b116a61aa83e2ef88097013aa38 Mon Sep 17 00:00:00 2001 From: Marc Lanctot Date: Tue, 14 Nov 2023 13:23:31 -0330 Subject: [PATCH 22/25] Modify PyTorch DQN to use boolean masks --- open_spiel/python/pytorch/dqn.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/open_spiel/python/pytorch/dqn.py b/open_spiel/python/pytorch/dqn.py index 487f3ffcbf..a9d0fd04ee 100644 --- a/open_spiel/python/pytorch/dqn.py +++ b/open_spiel/python/pytorch/dqn.py @@ -318,8 +318,8 @@ def learn(self): rewards = torch.Tensor([t.reward for t in transitions]) next_info_states = torch.Tensor([t.next_info_state for t in transitions]) are_final_steps = torch.Tensor([t.is_final_step for t in transitions]) - legal_actions_mask = torch.Tensor( - np.array([t.legal_actions_mask for t in transitions])) + legal_actions_mask = torch.BoolTensor( + np.array([t.legal_actions_mask for t in transitions], dtype=bool)) self._q_values = self._q_network(info_states) self._target_q_values = self._target_q_network(next_info_states).detach() From c0de1e5164b04e5fba73025ec0b5d7e3d6fc1869 Mon Sep 17 00:00:00 2001 From: Marc Lanctot Date: Tue, 14 Nov 2023 13:27:22 -0330 Subject: [PATCH 23/25] Pytorch DQN: keep original mask, then just convert it to bool when applying it --- open_spiel/python/pytorch/dqn.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/open_spiel/python/pytorch/dqn.py b/open_spiel/python/pytorch/dqn.py index a9d0fd04ee..393b88aaa5 100644 --- a/open_spiel/python/pytorch/dqn.py +++ b/open_spiel/python/pytorch/dqn.py @@ -318,15 +318,15 @@ def learn(self): rewards = torch.Tensor([t.reward for t in transitions]) next_info_states = torch.Tensor([t.next_info_state for t in transitions]) are_final_steps = torch.Tensor([t.is_final_step for t in transitions]) - legal_actions_mask = torch.BoolTensor( - np.array([t.legal_actions_mask for t in transitions], dtype=bool)) + legal_actions_mask = torch.Tensor( + np.array([t.legal_actions_mask for t in transitions])) self._q_values = self._q_network(info_states) self._target_q_values = self._target_q_network(next_info_states).detach() illegal_actions_mask = 1 - legal_actions_mask legal_target_q_values = self._target_q_values.masked_fill( - illegal_actions_mask, ILLEGAL_ACTION_LOGITS_PENALTY) + illegal_actions_mask.bool(), ILLEGAL_ACTION_LOGITS_PENALTY) max_next_q = torch.max(legal_target_q_values, dim=1)[0] target = ( From 3f48428868ee86e9367f5eec4f9c68576b95acee Mon Sep 17 00:00:00 2001 From: Marc Lanctot Date: Tue, 14 Nov 2023 14:18:29 -0330 Subject: [PATCH 24/25] Upgrade Linux wheels to Ubuntu-22.04 / Python 3.10 --- .github/workflows/wheels.yml | 3 ++- open_spiel/scripts/test_wheel.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 438107416b..8ec20c0ab6 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -28,9 +28,10 @@ jobs: strategy: matrix: include: - - os: ubuntu-20.04 + - os: ubuntu-22.04 OS_TYPE: "Linux" CI_PYBIN: python3 + OS_PYTHON_VERSION: 3.10 CIBW_ENVIRONMENT: "CXX=$(which g++) OPEN_SPIEL_BUILDING_WHEEL='ON' OPEN_SPIEL_BUILD_WITH_ACPC='ON' OPEN_SPIEL_BUILD_WITH_HANABI='ON' OPEN_SPIEL_BUILD_WITH_ROSHAMBO='ON'" CIBW_BUILD: cp38-manylinux_x86_64 cp39-manylinux_x86_64 cp310-manylinux_x86_64 cp311-manylinux_x86_64 cp312-manylinux_x86_64 - os: macOS-12 diff --git a/open_spiel/scripts/test_wheel.sh b/open_spiel/scripts/test_wheel.sh index 15096269c1..ae20fec12d 100755 --- a/open_spiel/scripts/test_wheel.sh +++ b/open_spiel/scripts/test_wheel.sh @@ -63,7 +63,7 @@ fi if [[ "$MODE" = "full" ]]; then if [[ "$OS" = "Linux" ]]; then - ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl + ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl elif [[ "$OS" = "Darwn" && "$OS_PYTHON_VERSION" = "3.9" ]]; then ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp39-cp39-macosx_10_9_x86_64.whl else From e512092317ecfe27f621d13d5136808a3001f304 Mon Sep 17 00:00:00 2001 From: Marc Lanctot Date: Tue, 14 Nov 2023 16:11:05 -0330 Subject: [PATCH 25/25] Fix one-character typo :) We'll get there... --- open_spiel/scripts/test_wheel.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/open_spiel/scripts/test_wheel.sh b/open_spiel/scripts/test_wheel.sh index ae20fec12d..53a5f6492e 100755 --- a/open_spiel/scripts/test_wheel.sh +++ b/open_spiel/scripts/test_wheel.sh @@ -64,7 +64,7 @@ fi if [[ "$MODE" = "full" ]]; then if [[ "$OS" = "Linux" ]]; then ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl - elif [[ "$OS" = "Darwn" && "$OS_PYTHON_VERSION" = "3.9" ]]; then + elif [[ "$OS" = "Darwin" && "$OS_PYTHON_VERSION" = "3.9" ]]; then ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp39-cp39-macosx_10_9_x86_64.whl else ${PYBIN} -m pip install wheelhouse/open_spiel-*-cp311-cp311-macosx_11_0_arm64.whl