From 240bc05ee67d330e8a6947c9f0277e6629251a06 Mon Sep 17 00:00:00 2001 From: Ashwath V A Date: Sun, 3 Apr 2022 10:09:03 +0530 Subject: [PATCH 01/45] fix #351: Solution 1: enforce weights.shape = x.shape for tuple axis --- heat/core/statistics.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/heat/core/statistics.py b/heat/core/statistics.py index 2453cd74df..af1af0a120 100644 --- a/heat/core/statistics.py +++ b/heat/core/statistics.py @@ -204,14 +204,12 @@ def average( Axis or axes along which to average ``x``. The default, ``axis=None``, will average over all of the elements of the input array. If axis is negative it counts from the last to the first axis. - #TODO Issue #351: If axis is a tuple of ints, averaging is performed on all of the axes - specified in the tuple instead of a single axis or all the axes as - before. weights : DNDarray, optional An array of weights associated with the values in ``x``. Each value in ``x`` contributes to the average according to its associated weight. The weights array can either be 1D (in which case its length must be the size of ``x`` along the given axis) or of the same shape as ``x``. + Weighted average over tuple axis requires weights array to be of the same shape as ``x``. If ``weights=None``, then all data in ``x`` are assumed to have a weight equal to one, the result is equivalent to :func:`mean`. returned : bool, optional @@ -267,7 +265,9 @@ def average( if axis is None: raise TypeError("Axis must be specified when shapes of x and weights differ.") elif isinstance(axis, tuple): - raise NotImplementedError("Weighted average over tuple axis not implemented yet.") + raise ValueError( + "Weighted average over tuple axis requires weights to be of the same shape as x." + ) if weights.ndim != 1: raise TypeError("1D weights expected when shapes of x and weights differ.") if weights.gshape[0] != x.gshape[axis]: From 08d0dcb3192038074d3828edeec7f9bf59274655 Mon Sep 17 00:00:00 2001 From: Claudia Comito Date: Wed, 1 Jun 2022 06:06:18 +0200 Subject: [PATCH 02/45] Replace bug report MD template with form in view of further automation --- .github/ISSUE_TEMPLATE/bug_report.md | 30 ------------ .github/ISSUE_TEMPLATE/bug_report.yaml | 63 ++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 30 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yaml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 55c7334760..0000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -name: Bug report -about: Report a bug that was detected -title: '' -labels: '' -assignees: '' - ---- - -**Description** -A clear and concise description of the bug and the associated functionality. - -**To Reproduce** -Steps to reproduce the behavior: -1. Which module/class/function is affected? -2. What are the circumstances under which the bug appears? -3. What is the exact error message / erroneous behavior? - - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Illustrative** -If applicable, add screenshots or minimal examples to help explain your problem. - -**Version Info** - Which version are you using? - -**Additional comments** -Any other comments here. diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yaml new file mode 100644 index 0000000000..3a192f6f51 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yaml @@ -0,0 +1,63 @@ +name: Bug Report +description: File a bug report +title: "[Bug]: " +labels: ["bug"] + +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + - type: textarea + id: what-happened + attributes: + label: What happened? + description: Also tell us, what did you expect to happen? + placeholder: Tell us what you see! + value: "A bug happened!" + validations: + required: true + - type: textarea + id: code + attributes: + label: Code snippet triggering the error + description: Please copy and paste your lines of code. + render: shell + - type: textarea + id: logs + attributes: + label: Relevant error message + description: Please copy and paste your error message. + render: shell + - type: dropdown + id: version + attributes: + label: Version + description: What version of Heat are you running? + options: + - 1.2.x + - 1.1.x + - main (development branch) + validations: + required: true + - type: dropdown + id: python version + attributes: + label: Python version + description: What Python version? + options: + - 3.8 + - 3.9 + - 3.10 + - 3.7 + - type: dropdown + id: pytorch version + attributes: + label: PyTorch version + description: What PyTorch version? + options: + - 1.11 + - 1.10 + - 1.9 + - 1.8 + - 1.7 From 545a6944bada554f5cb7a478e18fd49a937f7ceb Mon Sep 17 00:00:00 2001 From: Claudia Comito Date: Wed, 1 Jun 2022 06:12:00 +0200 Subject: [PATCH 03/45] Fix bug report file name --- .github/ISSUE_TEMPLATE/{bug_report.yaml => bug_report.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/ISSUE_TEMPLATE/{bug_report.yaml => bug_report.yml} (100%) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yaml b/.github/ISSUE_TEMPLATE/bug_report.yml similarity index 100% rename from .github/ISSUE_TEMPLATE/bug_report.yaml rename to .github/ISSUE_TEMPLATE/bug_report.yml From 295351cb2ea778605dd065701a6eb57dd7fdf6a8 Mon Sep 17 00:00:00 2001 From: Claudia Comito <39374113+ClaudiaComito@users.noreply.github.com> Date: Wed, 1 Jun 2022 06:14:45 +0200 Subject: [PATCH 04/45] Update bug_report.yml --- .github/ISSUE_TEMPLATE/bug_report.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 3a192f6f51..2f74ba4ba6 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -41,7 +41,7 @@ body: validations: required: true - type: dropdown - id: python version + id: python-version attributes: label: Python version description: What Python version? @@ -51,7 +51,7 @@ body: - 3.10 - 3.7 - type: dropdown - id: pytorch version + id: pytorch-version attributes: label: PyTorch version description: What PyTorch version? From 91f8190c8f985bdc7109fd8f95286c9f2b667650 Mon Sep 17 00:00:00 2001 From: Claudia Comito <39374113+ClaudiaComito@users.noreply.github.com> Date: Wed, 1 Jun 2022 06:16:46 +0200 Subject: [PATCH 05/45] Update bug_report.yml --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 2f74ba4ba6..373fba6798 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -14,7 +14,7 @@ body: label: What happened? description: Also tell us, what did you expect to happen? placeholder: Tell us what you see! - value: "A bug happened!" + value: "" validations: required: true - type: textarea From ef94a9b5970fea091f9dded5d70b5a463c0ab7be Mon Sep 17 00:00:00 2001 From: Claudia Comito <39374113+ClaudiaComito@users.noreply.github.com> Date: Wed, 1 Jun 2022 06:17:14 +0200 Subject: [PATCH 06/45] Update bug_report.yml --- .github/ISSUE_TEMPLATE/bug_report.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 373fba6798..d5887ac19d 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -14,7 +14,6 @@ body: label: What happened? description: Also tell us, what did you expect to happen? placeholder: Tell us what you see! - value: "" validations: required: true - type: textarea From 4a1fc1a1003b52be5544a47a4b26cddb4a374d9a Mon Sep 17 00:00:00 2001 From: Claudia Comito <39374113+ClaudiaComito@users.noreply.github.com> Date: Wed, 1 Jun 2022 09:19:28 +0200 Subject: [PATCH 07/45] Update bug_report.yml --- .github/ISSUE_TEMPLATE/bug_report.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index d5887ac19d..e32a87a384 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -13,7 +13,6 @@ body: attributes: label: What happened? description: Also tell us, what did you expect to happen? - placeholder: Tell us what you see! validations: required: true - type: textarea @@ -25,8 +24,8 @@ body: - type: textarea id: logs attributes: - label: Relevant error message - description: Please copy and paste your error message. + label: Error message or erroneous outcome + description: Please copy and paste your error. render: shell - type: dropdown id: version From cb94ad1b7167386cc1cdab315eeab775b07c1245 Mon Sep 17 00:00:00 2001 From: JuanPedroGHM Date: Wed, 1 Jun 2022 09:49:05 +0200 Subject: [PATCH 08/45] Auto generated release notes and changelog (#974) * wip: Initial release draft and changelog updater actions configuration * doc: pr title style guide in contibuting.md * ci: improved release draft templates * ci: extra release draft categories * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: Claudia Comito <39374113+ClaudiaComito@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- .github/release-drafter.yml | 43 +++++++++++++++++++++++++ .github/workflows/changelog-updater.yml | 27 ++++++++++++++++ .github/workflows/release-drafter.yml | 13 ++++++++ contributing.md | 2 ++ 5 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 .github/release-drafter.yml create mode 100644 .github/workflows/changelog-updater.yml create mode 100644 .github/workflows/release-drafter.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index e32a87a384..aef16d1152 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -25,7 +25,7 @@ body: id: logs attributes: label: Error message or erroneous outcome - description: Please copy and paste your error. + description: Please copy and paste your error. render: shell - type: dropdown id: version diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml new file mode 100644 index 0000000000..1791f1dd8f --- /dev/null +++ b/.github/release-drafter.yml @@ -0,0 +1,43 @@ +categories: + - title: '🔥 Features' + labels: + - 'enhancement' + - title: '🐛 Bug Fixes' + labels: + - 'bug :bug:' + - title: '🧹 Maintenance' + label: 'chore' + - title: '📜 Documentation' + label: 'documentation :book:' + - title: '🧪 Testing' + label: 'testing' + - title: '💯 Benchmarking' + label: 'benchmarking' + - title: 'Linear Algebra' + label: 'linalg' + - title: 'DNDarray' + label: 'dndarray' + - title: 'Arithmetic' + label: 'arithmetic' + - title: 'Random' + label: 'random' + - title: 'Logical' + label: 'logical' + - title: 'Manipulation' + label: 'manipulation' + - title: 'Communication' + labels: + - 'io' + - 'communication' +change-template: '- #$NUMBER $TITLE (by @$AUTHOR)' +categorie-template: '### $TITLE' +exclude-labels: +- 'workflow' +template: | + ## Changes + + $CHANGES + + ## Contributors + + $CONTRIBUTORS diff --git a/.github/workflows/changelog-updater.yml b/.github/workflows/changelog-updater.yml new file mode 100644 index 0000000000..15cef8c19e --- /dev/null +++ b/.github/workflows/changelog-updater.yml @@ -0,0 +1,27 @@ +name: 'Update Changelog' + +on: + release: + types: [released] + +jobs: + update: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: main + + - name: Update Changelog + uses: stefanzweifel/changelog-updater-action@v1 + with: + release-notes: ${{ github.event.release.body }} + latest-version: ${{ github.event.release.name }} + + - name: Commit updated CHANGELOG + uses: stefanzweifel/git-auto-commit-action@v4 + with: + branch: main + commit_message: Update CHANGELOG + file_pattern: CHANGELOG.md diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml new file mode 100644 index 0000000000..a7cf0406fd --- /dev/null +++ b/.github/workflows/release-drafter.yml @@ -0,0 +1,13 @@ +name: Release Drafter + +on: + pull_request_target: + types: [closed] + +jobs: + update_release_draft: + runs-on: ubuntu-latest + steps: + - uses: release-drafter/release-drafter@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/contributing.md b/contributing.md index 7147ad3438..b0ae45d0be 100644 --- a/contributing.md +++ b/contributing.md @@ -98,6 +98,8 @@ git push origin features/123-boolean-operators * If your commit introduces a new feature or changes functionality, **please explain your changes and the thinking behind them**. This greatly simplifies the review process. For bug fixes, documentation updates, etc., this is generally not necessary, though if you do not get any reaction, do feel free to ask for review. +* Phrase the PR title as a changelog message and make sure the PR is properly tagged ('enhancement', 'bug', 'ci/cd', 'chore', 'documentation'). + #### Review Process * Reviewers (the other developers and interested community members) will write inline and/or general comments on your Pull Request (PR) to help you improve its implementation, documentation and style. Every single developer working on the project has their code reviewed, and we’ve come to see it as friendly conversation from which we all learn and the overall code quality benefits. Therefore, please don’t let the review discourage you from contributing: its only aim is to improve the quality of project, not to criticize (we are, after all, very grateful for the time you’re donating!). From 231831e90eb1cd6d4db0a911682706f4680d137b Mon Sep 17 00:00:00 2001 From: JuanPedroGHM Date: Wed, 1 Jun 2022 09:58:41 +0200 Subject: [PATCH 09/45] Tutorial note about local and global printing (#972) * doc: parallel tutorial note metioning local and global printing * doc: extenden local print note with ``ht.local_printing()`` * Fix typo * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: Claudia Comito <39374113+ClaudiaComito@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- doc/source/tutorial_parallel_computation.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/source/tutorial_parallel_computation.rst b/doc/source/tutorial_parallel_computation.rst index 486cad2461..3dde428861 100644 --- a/doc/source/tutorial_parallel_computation.rst +++ b/doc/source/tutorial_parallel_computation.rst @@ -85,7 +85,10 @@ Data chunking in Heat is always done along a singular axis, i.e. a one-dimension .. note:: - If your running the following examples in a distributed computation environment, please modify your program invocation from ``python ./my_script.py`` to ``mpirun -p python ./my_script.py``. By the way, invoking a Heat program like this on your laptop or workstation also works. + If you're running the following examples in a distributed computation environment, please modify your program invocation from ``python ./my_script.py`` to ``mpirun -p python ./my_script.py``. By the way, invoking a Heat program like this on your laptop or workstation also works. + +.. note :: + Most of the examples throughout the documentation display the split ``DNDarrays``. This is not the default behavior when displaying a ``DNDarray``, and the full array will be printed multiple times (based on the number of processes). This behaviour can be changed using the ``ht.local_printing()`` option or by printing the local arrays for each process with the property `larray `_. .. code:: python From c1ef707ba8e514dd49b60712c6df44c6db5652cb Mon Sep 17 00:00:00 2001 From: SaiSuraj27 <87087741+SaiSuraj27@users.noreply.github.com> Date: Wed, 1 Jun 2022 13:34:40 +0530 Subject: [PATCH 10/45] Updated the tutorial document. (#977) * Updated the tutorial document. 1. Corrected the spelling mistake -> (sigular to single) 2. Corrected the statement -> the number of dimensions is the rank of the array. 3. Made 2 more small changes. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix typo Co-authored-by: Claudia Comito <39374113+ClaudiaComito@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- scripts/tutorial.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/tutorial.ipynb b/scripts/tutorial.ipynb index 8f09fafc01..0c64d7a565 100644 --- a/scripts/tutorial.ipynb +++ b/scripts/tutorial.ipynb @@ -154,7 +154,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Similar to a NumPy array, a Heat array is a grid of values of a sigular type. The number of dimensions is the rank of the array, while the shape of an array is a tuple of integers giving the number of elements of the array along each dimension. \n", + "Similar to a NumPy array, a Heat array is a grid of values of a single (one particular) type. The number of dimensions is the number of axes of the array, while the shape of an array is a tuple of integers giving the number of elements of the array along each dimension. \n", "\n", "Heat emulates NumPy's API as closely as possible, allowing for the use of well-known array creation functions." ] @@ -515,7 +515,7 @@ "source": [ "### Indexing\n", "\n", - "Heat allows the indexing of arrays, and thereby, the extraction of a partial view of the elements in an array. It is possible to get obtain single values as well as entire chunks, i.e. slices." + "Heat allows the indexing of arrays, and thereby, the extraction of a partial view of the elements in an array. It is possible to obtain single values as well as entire chunks, i.e. slices." ] }, { @@ -796,7 +796,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "When writing code for GPUs only, you might quickly find it tedious to explicitly place every on the GPU by specifying the `device=` parameter. Hence, it is possible to set a default backend on which Heat will work on." + "When writing code for GPUs only, you might quickly find it tedious to explicitly place everything on the GPU by specifying the `device=` parameter. Hence, it is possible to set a default backend on which Heat will work on." ] }, { From ee0ff4d0dccb7396c1cf533ea9563828a8e8b4f8 Mon Sep 17 00:00:00 2001 From: Claudia Comito Date: Sat, 2 Jul 2022 06:19:26 +0200 Subject: [PATCH 11/45] Set write permissions for workflow --- .github/workflows/pytorch-latest-release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pytorch-latest-release.yml b/.github/workflows/pytorch-latest-release.yml index 08ccb7dc21..593ddc393a 100644 --- a/.github/workflows/pytorch-latest-release.yml +++ b/.github/workflows/pytorch-latest-release.yml @@ -1,7 +1,9 @@ name: Get latest PyTorch release version on: schedule: - - cron: '0 5 * * 1-5' + - cron: '30 6 * * 1-6' +permissions: + contents: write jobs: get-version: runs-on: ubuntu-latest From a1f0b1b3025328d33bcc3b7345d0581b95f250b8 Mon Sep 17 00:00:00 2001 From: Claudia Comito <39374113+ClaudiaComito@users.noreply.github.com> Date: Sat, 2 Jul 2022 06:41:42 +0200 Subject: [PATCH 12/45] Update schedule --- .github/workflows/pytorch-latest-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytorch-latest-release.yml b/.github/workflows/pytorch-latest-release.yml index 593ddc393a..0a72b7af2e 100644 --- a/.github/workflows/pytorch-latest-release.yml +++ b/.github/workflows/pytorch-latest-release.yml @@ -1,7 +1,7 @@ name: Get latest PyTorch release version on: schedule: - - cron: '30 6 * * 1-6' + - cron: '45 5 * * 1-6' permissions: contents: write jobs: From 96506fa93df87ef4d879439f647a60d30d94f5ed Mon Sep 17 00:00:00 2001 From: Claudia Comito <39374113+ClaudiaComito@users.noreply.github.com> Date: Sat, 2 Jul 2022 06:42:13 +0200 Subject: [PATCH 13/45] Update schedule --- .github/workflows/pytorch-latest-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytorch-latest-release.yml b/.github/workflows/pytorch-latest-release.yml index 0a72b7af2e..3ef2bcc76f 100644 --- a/.github/workflows/pytorch-latest-release.yml +++ b/.github/workflows/pytorch-latest-release.yml @@ -1,7 +1,7 @@ name: Get latest PyTorch release version on: schedule: - - cron: '45 5 * * 1-6' + - cron: '45 4 * * 1-6' permissions: contents: write jobs: From 385374ad836ca3e1ef1354383fa630a18bed1928 Mon Sep 17 00:00:00 2001 From: Claudia Comito <39374113+ClaudiaComito@users.noreply.github.com> Date: Sat, 2 Jul 2022 06:49:30 +0200 Subject: [PATCH 14/45] Update schedule --- .github/workflows/pytorch-latest-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytorch-latest-release.yml b/.github/workflows/pytorch-latest-release.yml index 3ef2bcc76f..ed4abf5e40 100644 --- a/.github/workflows/pytorch-latest-release.yml +++ b/.github/workflows/pytorch-latest-release.yml @@ -1,7 +1,7 @@ name: Get latest PyTorch release version on: schedule: - - cron: '45 4 * * 1-6' + - cron: '0 5 * * 1-6' permissions: contents: write jobs: From bff6b2cc73b08ab8d3d0109ed1f118f17efa03b7 Mon Sep 17 00:00:00 2001 From: Claudia Comito Date: Mon, 4 Jul 2022 14:35:00 +0200 Subject: [PATCH 15/45] Move pytorch version file out of workflows dir --- .github/pytorch-release-versions/pytorch-latest.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/pytorch-release-versions/pytorch-latest.txt diff --git a/.github/pytorch-release-versions/pytorch-latest.txt b/.github/pytorch-release-versions/pytorch-latest.txt new file mode 100644 index 0000000000..1cac385c6c --- /dev/null +++ b/.github/pytorch-release-versions/pytorch-latest.txt @@ -0,0 +1 @@ +1.11.0 From 4f59d69902d344eee8d6be0f56b3281058e201c5 Mon Sep 17 00:00:00 2001 From: Claudia Comito Date: Mon, 4 Jul 2022 14:37:05 +0200 Subject: [PATCH 16/45] Update paths --- .github/workflows/latest-pytorch-support.yml | 8 ++++---- .github/workflows/pytorch-latest-release.yml | 6 +++--- .../workflows/pytorch-release-versions/pytorch-latest.txt | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) delete mode 100644 .github/workflows/pytorch-release-versions/pytorch-latest.txt diff --git a/.github/workflows/latest-pytorch-support.yml b/.github/workflows/latest-pytorch-support.yml index 0026d2872d..173ef3b4d3 100644 --- a/.github/workflows/latest-pytorch-support.yml +++ b/.github/workflows/latest-pytorch-support.yml @@ -3,10 +3,10 @@ name: Support latest PyTorch on: push: paths: - - '.github/workflows/pytorch-release-versions/*' + - '.github/pytorch-release-versions/*' env: previous_pytorch: $(grep 'torch>=' setup.py | awk -F '<=' '{print $2}' | tr -d '",') - new_pytorch: $(<.github/workflows/pytorch-release-versions/pytorch-latest.txt) + new_pytorch: $(<.github/pytorch-release-versions/pytorch-latest.txt) permissions: contents: write issues: write @@ -36,10 +36,10 @@ jobs: echo ${{ env.previous_pytorch }} echo ${{ env.new_pytorch }} sed -i '/torch>=/ s/'"${{ env.previous_pytorch }}"'/'"${{ env.new_pytorch }}"'/g' setup.py - sed -i 's/'"${{ env.previous_pytorch }}"'/'"${{ env.new_pytorch }}"'/g' .github/workflows/pytorch-release-versions/pytorch-latest.txt + sed -i 's/'"${{ env.previous_pytorch }}"'/'"${{ env.new_pytorch }}"'/g' .github/pytorch-release-versions/pytorch-latest.txt - name: Define env variable run: | - echo "new=$(<.github/workflows/pytorch-release-versions/pytorch-latest.txt)" >> $GITHUB_ENV + echo "new=$(<.github/pytorch-release-versions/pytorch-latest.txt)" >> $GITHUB_ENV - name: Create PR from branch uses: peter-evans/create-pull-request@v3 with: diff --git a/.github/workflows/pytorch-latest-release.yml b/.github/workflows/pytorch-latest-release.yml index ed4abf5e40..7ef6b93073 100644 --- a/.github/workflows/pytorch-latest-release.yml +++ b/.github/workflows/pytorch-latest-release.yml @@ -1,7 +1,7 @@ name: Get latest PyTorch release version on: schedule: - - cron: '0 5 * * 1-6' + - cron: '0 13 * * 1-5' permissions: contents: write jobs: @@ -15,14 +15,14 @@ jobs: - name: Fetch PyTorch release version run: | curl -sL https://api.github.com/repos/pytorch/pytorch/releases/latest | \ - jq -r ".tag_name" | tr -d 'v' > .github/workflows/pytorch-release-versions/pytorch-latest.txt + jq -r ".tag_name" | tr -d 'v' > .github/pytorch-release-versions/pytorch-latest.txt - name: Check for modified files id: git-check run: echo ::set-output name=modified::$([ -z "`git status --porcelain`" ] && echo "false" || echo "true") - name: Commit latest PyTorch release version if: steps.git-check.outputs.modified == 'true' run: | - echo "new=$(<.github/workflows/pytorch-release-versions/pytorch-latest.txt)" >> $GITHUB_ENV + echo "new=$(<.github/pytorch-release-versions/pytorch-latest.txt)" >> $GITHUB_ENV git config --global user.name 'ClaudiaComito' git config --global user.email 'c.comito@fz-juelich.de@users.noreply.github.com' git commit -am "New PyTorch release ${{ env.new }}" diff --git a/.github/workflows/pytorch-release-versions/pytorch-latest.txt b/.github/workflows/pytorch-release-versions/pytorch-latest.txt deleted file mode 100644 index 1cac385c6c..0000000000 --- a/.github/workflows/pytorch-release-versions/pytorch-latest.txt +++ /dev/null @@ -1 +0,0 @@ -1.11.0 From 55fff4662c5d478d81f2f9d50f753943818fcc7f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 5 Jul 2022 00:10:27 +0000 Subject: [PATCH 17/45] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 22.3.0 → 22.6.0](https://github.com/psf/black/compare/22.3.0...22.6.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2ac54612a4..bff221de53 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: - id: check-added-large-files - id: flake8 - repo: https://github.com/psf/black - rev: 22.3.0 + rev: 22.6.0 hooks: - id: black - repo: https://github.com/pycqa/pydocstyle From 4fe322bd5724dda20972f31619408a76ec733436 Mon Sep 17 00:00:00 2001 From: Claudia Comito Date: Tue, 5 Jul 2022 08:55:47 +0200 Subject: [PATCH 18/45] Push pytorch release update to release/1.2.x branch, not main --- .github/workflows/pytorch-latest-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pytorch-latest-release.yml b/.github/workflows/pytorch-latest-release.yml index 7ef6b93073..caca0cd957 100644 --- a/.github/workflows/pytorch-latest-release.yml +++ b/.github/workflows/pytorch-latest-release.yml @@ -1,7 +1,7 @@ name: Get latest PyTorch release version on: schedule: - - cron: '0 13 * * 1-5' + - cron: '10 7 * * 2' permissions: contents: write jobs: @@ -11,7 +11,7 @@ jobs: - uses: actions/checkout@v2 with: token: ${{ secrets.GITHUB_TOKEN }} - ref: 'main' + ref: 'release/1.2.x' - name: Fetch PyTorch release version run: | curl -sL https://api.github.com/repos/pytorch/pytorch/releases/latest | \ From a52156b73407607270fe87f46bc744f198742c29 Mon Sep 17 00:00:00 2001 From: Claudia Comito Date: Tue, 5 Jul 2022 09:09:40 +0200 Subject: [PATCH 19/45] Update schedule --- .github/workflows/pytorch-latest-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytorch-latest-release.yml b/.github/workflows/pytorch-latest-release.yml index caca0cd957..f5e1d51cc9 100644 --- a/.github/workflows/pytorch-latest-release.yml +++ b/.github/workflows/pytorch-latest-release.yml @@ -1,7 +1,7 @@ name: Get latest PyTorch release version on: schedule: - - cron: '10 7 * * 2' + - cron: '30 7 * * 2' permissions: contents: write jobs: From 229e172c0a27d9e8225fdd3514b9306ee1148b6a Mon Sep 17 00:00:00 2001 From: Claudia Comito Date: Tue, 5 Jul 2022 11:24:21 +0200 Subject: [PATCH 20/45] Bypass `on push` trigger --- .github/workflows/latest-pytorch-support.yml | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/latest-pytorch-support.yml b/.github/workflows/latest-pytorch-support.yml index 173ef3b4d3..e52e2540a6 100644 --- a/.github/workflows/latest-pytorch-support.yml +++ b/.github/workflows/latest-pytorch-support.yml @@ -1,18 +1,21 @@ name: Support latest PyTorch on: - push: - paths: - - '.github/pytorch-release-versions/*' + schedule: + - cron: '28 9 * * 2' env: previous_pytorch: $(grep 'torch>=' setup.py | awk -F '<=' '{print $2}' | tr -d '",') - new_pytorch: $(<.github/pytorch-release-versions/pytorch-latest.txt) + new_pytorch: $(curl -sL https://api.github.com/repos/pytorch/pytorch/releases/latest | jq -r ".tag_name" | tr -d 'v') permissions: contents: write issues: write pull-requests: write jobs: latest-torch-support: + if new_pytorch != previous_pytorch: + strategy: + matrix: + branches: ['main', 'release/1.2.x'] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -30,7 +33,7 @@ jobs: uses: actions/checkout@v2 with: token: ${{ secrets.GITHUB_TOKEN }} - ref: 'main' + ref: ${{ matrix.branches }} - name: Update setup.py run: | echo ${{ env.previous_pytorch }} @@ -43,14 +46,14 @@ jobs: - name: Create PR from branch uses: peter-evans/create-pull-request@v3 with: - base: main + base: ${{ matrix.branches }} delete-branch: true token: ${{ secrets.GITHUB_TOKEN }} commit-message: Support latest PyTorch release - title: Support PyTorch ${{ env.new }} + title: Support PyTorch ${{ env.new }} on branch ${{ matrix.branches }} body: | Run tests on latest PyTorch release Issue/s resolved: #${{ steps.create-issue.outputs.number }} Auto-generated by [create-pull-request][1] [1]: https://github.com/peter-evans/create-pull-request - reviewers: ClaudiaComito, mtar, coquelin77 + reviewers: ClaudiaComito, mtar, coquelin77, JuanPedroGHM From 6510ea4808f8b1e7068e683a3f6a74c6a56fa335 Mon Sep 17 00:00:00 2001 From: Claudia Comito Date: Tue, 5 Jul 2022 11:37:33 +0200 Subject: [PATCH 21/45] Update schedule --- .github/workflows/latest-pytorch-support.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/latest-pytorch-support.yml b/.github/workflows/latest-pytorch-support.yml index e52e2540a6..d49ef7e41f 100644 --- a/.github/workflows/latest-pytorch-support.yml +++ b/.github/workflows/latest-pytorch-support.yml @@ -2,7 +2,7 @@ name: Support latest PyTorch on: schedule: - - cron: '28 9 * * 2' + - cron: '45 9 * * 2' env: previous_pytorch: $(grep 'torch>=' setup.py | awk -F '<=' '{print $2}' | tr -d '",') new_pytorch: $(curl -sL https://api.github.com/repos/pytorch/pytorch/releases/latest | jq -r ".tag_name" | tr -d 'v') From 2a947a17d6a24a7be2bbacd6696d51753de0ff76 Mon Sep 17 00:00:00 2001 From: Claudia Comito Date: Tue, 5 Jul 2022 11:49:35 +0200 Subject: [PATCH 22/45] Fix condition syntax --- .github/workflows/latest-pytorch-support.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/latest-pytorch-support.yml b/.github/workflows/latest-pytorch-support.yml index d49ef7e41f..51034533e9 100644 --- a/.github/workflows/latest-pytorch-support.yml +++ b/.github/workflows/latest-pytorch-support.yml @@ -2,7 +2,7 @@ name: Support latest PyTorch on: schedule: - - cron: '45 9 * * 2' + - cron: '59 9 * * 2' env: previous_pytorch: $(grep 'torch>=' setup.py | awk -F '<=' '{print $2}' | tr -d '",') new_pytorch: $(curl -sL https://api.github.com/repos/pytorch/pytorch/releases/latest | jq -r ".tag_name" | tr -d 'v') @@ -12,7 +12,7 @@ permissions: pull-requests: write jobs: latest-torch-support: - if new_pytorch != previous_pytorch: + if: new_pytorch != previous_pytorch strategy: matrix: branches: ['main', 'release/1.2.x'] From 6ccec825ecc7eacabd2dbdb15f3a0da6fc37f6ce Mon Sep 17 00:00:00 2001 From: Claudia Comito Date: Tue, 5 Jul 2022 12:10:33 +0200 Subject: [PATCH 23/45] Fix syntax --- .github/workflows/latest-pytorch-support.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/latest-pytorch-support.yml b/.github/workflows/latest-pytorch-support.yml index 51034533e9..3edf8278ee 100644 --- a/.github/workflows/latest-pytorch-support.yml +++ b/.github/workflows/latest-pytorch-support.yml @@ -2,7 +2,7 @@ name: Support latest PyTorch on: schedule: - - cron: '59 9 * * 2' + - cron: '18 10 * * 2' env: previous_pytorch: $(grep 'torch>=' setup.py | awk -F '<=' '{print $2}' | tr -d '",') new_pytorch: $(curl -sL https://api.github.com/repos/pytorch/pytorch/releases/latest | jq -r ".tag_name" | tr -d 'v') @@ -12,7 +12,7 @@ permissions: pull-requests: write jobs: latest-torch-support: - if: new_pytorch != previous_pytorch + if: env.new_pytorch != env.previous_pytorch strategy: matrix: branches: ['main', 'release/1.2.x'] From 3cc0080317f8d60ff0534edabfb3f1035c052d9c Mon Sep 17 00:00:00 2001 From: Claudia Comito Date: Tue, 5 Jul 2022 14:01:52 +0200 Subject: [PATCH 24/45] On push trigger workaround --- .github/workflows/latest-pytorch-support.yml | 8 ++++---- .github/workflows/pytorch-latest-release.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/latest-pytorch-support.yml b/.github/workflows/latest-pytorch-support.yml index 3edf8278ee..80612fe92b 100644 --- a/.github/workflows/latest-pytorch-support.yml +++ b/.github/workflows/latest-pytorch-support.yml @@ -1,18 +1,18 @@ name: Support latest PyTorch on: - schedule: - - cron: '18 10 * * 2' + push: + paths: + - '.github/pytorch-release-versions/*' env: previous_pytorch: $(grep 'torch>=' setup.py | awk -F '<=' '{print $2}' | tr -d '",') - new_pytorch: $(curl -sL https://api.github.com/repos/pytorch/pytorch/releases/latest | jq -r ".tag_name" | tr -d 'v') + new_pytorch: $(<.github/pytorch-release-versions/pytorch-latest.txt) permissions: contents: write issues: write pull-requests: write jobs: latest-torch-support: - if: env.new_pytorch != env.previous_pytorch strategy: matrix: branches: ['main', 'release/1.2.x'] diff --git a/.github/workflows/pytorch-latest-release.yml b/.github/workflows/pytorch-latest-release.yml index f5e1d51cc9..f95edc2690 100644 --- a/.github/workflows/pytorch-latest-release.yml +++ b/.github/workflows/pytorch-latest-release.yml @@ -1,7 +1,7 @@ name: Get latest PyTorch release version on: schedule: - - cron: '30 7 * * 2' + - cron: '10 12 * * 2' permissions: contents: write jobs: @@ -10,7 +10,7 @@ jobs: steps: - uses: actions/checkout@v2 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GHACTIONS }} ref: 'release/1.2.x' - name: Fetch PyTorch release version run: | From 6c487d633b333d8bd70288841f68bbf2940bd384 Mon Sep 17 00:00:00 2001 From: Claudia Comito Date: Tue, 5 Jul 2022 14:50:15 +0200 Subject: [PATCH 25/45] Update schedule --- .github/workflows/pytorch-latest-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytorch-latest-release.yml b/.github/workflows/pytorch-latest-release.yml index f95edc2690..7406a21078 100644 --- a/.github/workflows/pytorch-latest-release.yml +++ b/.github/workflows/pytorch-latest-release.yml @@ -1,7 +1,7 @@ name: Get latest PyTorch release version on: schedule: - - cron: '10 12 * * 2' + - cron: '4 13 * * 2' permissions: contents: write jobs: From 05a2acd4e0622f284796be6ffb18f6536aba9cf8 Mon Sep 17 00:00:00 2001 From: Claudia Comito <39374113+ClaudiaComito@users.noreply.github.com> Date: Tue, 5 Jul 2022 16:13:01 +0200 Subject: [PATCH 26/45] Update schedule --- .github/workflows/pytorch-latest-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytorch-latest-release.yml b/.github/workflows/pytorch-latest-release.yml index 7406a21078..584ef8866b 100644 --- a/.github/workflows/pytorch-latest-release.yml +++ b/.github/workflows/pytorch-latest-release.yml @@ -1,7 +1,7 @@ name: Get latest PyTorch release version on: schedule: - - cron: '4 13 * * 2' + - cron: '25 14 * * 2' permissions: contents: write jobs: From d39cbfe0f29a0e31892fe8bd53f33c532b87fd2f Mon Sep 17 00:00:00 2001 From: neosunhan Date: Fri, 15 Jul 2022 14:36:25 +0800 Subject: [PATCH 27/45] Enable non-negative sample size --- heat/core/factories.py | 2 +- heat/core/tests/test_factories.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/heat/core/factories.py b/heat/core/factories.py index 50a55a0613..695545c879 100644 --- a/heat/core/factories.py +++ b/heat/core/factories.py @@ -946,7 +946,7 @@ def linspace( start = float(start) stop = float(stop) num = int(num) - if num <= 0: + if num < 0: raise ValueError( "number of samples 'num' must be non-negative integer, but was {}".format(num) ) diff --git a/heat/core/tests/test_factories.py b/heat/core/tests/test_factories.py index c996c06232..21d20dd1d0 100644 --- a/heat/core/tests/test_factories.py +++ b/heat/core/tests/test_factories.py @@ -586,6 +586,9 @@ def test_linspace(self): self.assertEqual(ascending.larray.dtype, torch.float32) self.assertEqual(ascending.split, None) + zero_samples = ht.linspace(-3, 5, num=0) + self.assertEqual(zero_samples.size, 0) + # simple inverse linear space descending = ht.linspace(-5, 3, num=100) self.assertIsInstance(descending, ht.DNDarray) @@ -633,8 +636,6 @@ def test_linspace(self): ht.linspace(-5, 3, split=1) with self.assertRaises(ValueError): ht.linspace(-5, 3, num=-1) - with self.assertRaises(ValueError): - ht.linspace(-5, 3, num=0) def test_logspace(self): # simple log space From 105b905d9910b9aa791ce4985cd6d7065708d581 Mon Sep 17 00:00:00 2001 From: neosunhan Date: Fri, 15 Jul 2022 15:06:25 +0800 Subject: [PATCH 28/45] Read `min` value directly from torch return object --- heat/core/tests/test_types.py | 1 + heat/core/types.py | 8 ++------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/heat/core/tests/test_types.py b/heat/core/tests/test_types.py index 91676650f8..6aa765a070 100644 --- a/heat/core/tests/test_types.py +++ b/heat/core/tests/test_types.py @@ -375,6 +375,7 @@ def test_iinfo(self): self.assertEqual(info32.bits, 32) self.assertEqual(info32.max, 2147483647) self.assertEqual(info32.min, -2147483648) + self.assertEqual(ht.iinfo(ht.uint8).min, 0) with self.assertRaises(TypeError): ht.iinfo(1.0) diff --git a/heat/core/types.py b/heat/core/types.py index 7af5994f67..0216b37620 100644 --- a/heat/core/types.py +++ b/heat/core/types.py @@ -996,11 +996,9 @@ def __new__(cls, dtype: Type[datatype]): def _init(self, dtype: Type[datatype]): _torch_finfo = torch.finfo(dtype.torch_type()) - for word in ["bits", "eps", "max", "tiny"]: + for word in ["bits", "eps", "max", "min", "tiny"]: setattr(self, word, getattr(_torch_finfo, word)) - self.min = -self.max - return self @@ -1044,11 +1042,9 @@ def __new__(cls, dtype: Type[datatype]): def _init(self, dtype: Type[datatype]): _torch_iinfo = torch.iinfo(dtype.torch_type()) - for word in ["bits", "max"]: + for word in ["bits", "min", "max"]: setattr(self, word, getattr(_torch_iinfo, word)) - self.min = -(self.max + 1) - return self From 54ab969d4f17cc5daaf5de776e421506d775ca20 Mon Sep 17 00:00:00 2001 From: neosunhan Date: Fri, 15 Jul 2022 15:21:07 +0800 Subject: [PATCH 29/45] Enable non-negative number of samples for `logspace` --- heat/core/tests/test_factories.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/heat/core/tests/test_factories.py b/heat/core/tests/test_factories.py index 21d20dd1d0..0cef3444c9 100644 --- a/heat/core/tests/test_factories.py +++ b/heat/core/tests/test_factories.py @@ -688,8 +688,6 @@ def test_logspace(self): ht.logspace(-5, 3, split=1) with self.assertRaises(ValueError): ht.logspace(-5, 3, num=-1) - with self.assertRaises(ValueError): - ht.logspace(-5, 3, num=0) def test_meshgrid(self): # arrays < 2 From 2dfd5916f14d5885d1e3725dff223bd7c5a2e30c Mon Sep 17 00:00:00 2001 From: neosunhan Date: Mon, 18 Jul 2022 16:01:55 +0800 Subject: [PATCH 30/45] Add test for `logspace` --- heat/core/tests/test_factories.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/heat/core/tests/test_factories.py b/heat/core/tests/test_factories.py index 0cef3444c9..dd973f988e 100644 --- a/heat/core/tests/test_factories.py +++ b/heat/core/tests/test_factories.py @@ -647,6 +647,9 @@ def test_logspace(self): self.assertEqual(ascending.larray.dtype, torch.float32) self.assertEqual(ascending.split, None) + zero_samples = ht.logspace(-3, 5, num=0) + self.assertEqual(zero_samples.size, 0) + # simple inverse log space descending = ht.logspace(-5, 3, num=100) self.assertIsInstance(descending, ht.DNDarray) From c85562b05bc191962fdf5e107949dad368e00af1 Mon Sep 17 00:00:00 2001 From: Claudia Comito <39374113+ClaudiaComito@users.noreply.github.com> Date: Mon, 22 Aug 2022 12:14:38 +0200 Subject: [PATCH 31/45] Add MPI version field to bug report template --- .github/ISSUE_TEMPLATE/bug_report.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index aef16d1152..0c3dabfdca 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -59,3 +59,9 @@ body: - 1.9 - 1.8 - 1.7 + - type: textarea + id: mpi-version + attributes: + label: MPI version + description: OpenMPI, ParaStation, IntelMPI version? + render: shell From 52d88c04ab1ea0342c5434978678bb2a34e3d484 Mon Sep 17 00:00:00 2001 From: JuanPedroGHM Date: Tue, 23 Aug 2022 11:18:37 +0200 Subject: [PATCH 32/45] fix: set cuda rng state on gpu tests for test_random.py (#1014) * Test latest pyorch on both main and release branch * Move pytorch release record out of workflows directory * Update paths * New PyTorch release * Temporarily remove trigger * Update pytorch-latest.txt * Reinstate trigger * New PyTorch release * Remove matrix strategy * Update pytorch-latest.txt * New PyTorch release * New PyTorch release * fix: set cuda rng state on gpu tests for test_random.py * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Added tests for python 3.9 and pytorch 1.12 Co-authored-by: Claudia Comito Co-authored-by: Daniel Coquelin Co-authored-by: ClaudiaComito Co-authored-by: Claudia Comito <39374113+ClaudiaComito@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- .../pytorch-latest.txt | 2 +- .github/workflows/ci.yaml | 2 ++ .github/workflows/latest-pytorch-support.yml | 6 +++--- heat/core/tests/test_random.py | 21 +++++++++++++++---- 5 files changed, 24 insertions(+), 9 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 0c3dabfdca..d09661121b 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -63,5 +63,5 @@ body: id: mpi-version attributes: label: MPI version - description: OpenMPI, ParaStation, IntelMPI version? + description: OpenMPI, ParaStation, IntelMPI version? render: shell diff --git a/.github/pytorch-release-versions/pytorch-latest.txt b/.github/pytorch-release-versions/pytorch-latest.txt index 1cac385c6c..0eed1a29ef 100644 --- a/.github/pytorch-release-versions/pytorch-latest.txt +++ b/.github/pytorch-release-versions/pytorch-latest.txt @@ -1 +1 @@ -1.11.0 +1.12.0 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 33237d4424..5c95e121df 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,12 +14,14 @@ jobs: py-version: - 3.7 - 3.8 + - 3.9 mpi: [ 'openmpi' ] install-options: [ '.', '.[hdf5,netcdf]' ] pytorch-version: - 'torch==1.7.1+cpu torchvision==0.8.2+cpu torchaudio==0.7.2' - 'torch==1.8.1+cpu torchvision==0.9.1+cpu torchaudio==0.8.1' - 'torch==1.9.0+cpu torchvision==0.10.0+cpu torchaudio==0.9.0' + - 'torch==1.12.0+cpu torchvision==0.13.0+cpu torchaudio==0.12.0' name: Python ${{ matrix.py-version }} with ${{ matrix.pytorch-version }}; options ${{ matrix.install-options }} diff --git a/.github/workflows/latest-pytorch-support.yml b/.github/workflows/latest-pytorch-support.yml index 80612fe92b..a0390fb530 100644 --- a/.github/workflows/latest-pytorch-support.yml +++ b/.github/workflows/latest-pytorch-support.yml @@ -33,7 +33,7 @@ jobs: uses: actions/checkout@v2 with: token: ${{ secrets.GITHUB_TOKEN }} - ref: ${{ matrix.branches }} + ref: 'release/1.2.x' - name: Update setup.py run: | echo ${{ env.previous_pytorch }} @@ -46,11 +46,11 @@ jobs: - name: Create PR from branch uses: peter-evans/create-pull-request@v3 with: - base: ${{ matrix.branches }} + base: release/1.2.x delete-branch: true token: ${{ secrets.GITHUB_TOKEN }} commit-message: Support latest PyTorch release - title: Support PyTorch ${{ env.new }} on branch ${{ matrix.branches }} + title: Support PyTorch ${{ env.new }} on branch release/1.2.x body: | Run tests on latest PyTorch release Issue/s resolved: #${{ steps.create-issue.outputs.number }} diff --git a/heat/core/tests/test_random.py b/heat/core/tests/test_random.py index ebc93ae5e7..c35b548233 100644 --- a/heat/core/tests/test_random.py +++ b/heat/core/tests/test_random.py @@ -44,7 +44,10 @@ def test_normal(self): def test_permutation(self): # Reset RNG ht.random.seed() - state = torch.random.get_rng_state() + if self.device.torch_device == "cpu": + state = torch.random.get_rng_state() + else: + state = torch.cuda.get_rng_state(self.device.torch_device) # results a = ht.random.permutation(10) @@ -58,7 +61,10 @@ def test_permutation(self): c0 = ht.random.permutation(ht.resplit(c_arr, 0)) c1 = ht.random.permutation(ht.resplit(c_arr, 1)) - torch.set_rng_state(state) + if self.device.torch_device == "cpu": + torch.random.set_rng_state(state) + else: + torch.cuda.set_rng_state(state, self.device.torch_device) # torch results to compare to a_cmp = torch.randperm(a.shape[0], device=self.device.torch_device) @@ -399,7 +405,11 @@ def test_randn(self): self.assertFalse(np.allclose(b, c)) def test_randperm(self): - state = torch.random.get_rng_state() + + if self.device.torch_device == "cpu": + state = torch.random.get_rng_state() + else: + state = torch.cuda.get_rng_state(self.device.torch_device) # results a = ht.random.randperm(10, dtype=ht.int32) @@ -407,7 +417,10 @@ def test_randperm(self): c = ht.random.randperm(5, split=0) d = ht.random.randperm(5, dtype=ht.float64) - torch.random.set_rng_state(state) + if self.device.torch_device == "cpu": + torch.random.set_rng_state(state) + else: + torch.cuda.set_rng_state(state, self.device.torch_device) # torch results to compare to a_cmp = torch.randperm(10, dtype=torch.int32, device=self.device.torch_device) From dd4a3963f8e76714a74bc702e8609d0caf17b181 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 13 Sep 2022 13:01:09 +0200 Subject: [PATCH 33/45] [pre-commit.ci] pre-commit autoupdate (#1024) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 22.6.0 → 22.8.0](https://github.com/psf/black/compare/22.6.0...22.8.0) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Claudia Comito <39374113+ClaudiaComito@users.noreply.github.com> --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bff221de53..593ee5aee5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: - id: check-added-large-files - id: flake8 - repo: https://github.com/psf/black - rev: 22.6.0 + rev: 22.8.0 hooks: - id: black - repo: https://github.com/pycqa/pydocstyle From 5ff03147ae0ff338a07efaefaf3f288e7090c6cc Mon Sep 17 00:00:00 2001 From: mtar Date: Fri, 23 Sep 2022 08:43:19 +0200 Subject: [PATCH 34/45] rename file and activate force push --- .github/workflows/{mirrorci.yml => ci_cpu.yml} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename .github/workflows/{mirrorci.yml => ci_cpu.yml} (94%) diff --git a/.github/workflows/mirrorci.yml b/.github/workflows/ci_cpu.yml similarity index 94% rename from .github/workflows/mirrorci.yml rename to .github/workflows/ci_cpu.yml index 54d0f4a273..312abbcf13 100644 --- a/.github/workflows/mirrorci.yml +++ b/.github/workflows/ci_cpu.yml @@ -12,7 +12,7 @@ jobs: with: args: "https://gitlab.jsc.fz-juelich.de/haf/heat" env: - FORCE_PUSH: "false" + FORCE_PUSH: "true" GITLAB_HOSTNAME: "gitlab.jsc.fz-juelich.de" GITLAB_USERNAME: "" GITLAB_PASSWORD: ${{ secrets.GITLAB_TOKEN }} From bd160404f69845ba0598ce164170af0d5b1e29d5 Mon Sep 17 00:00:00 2001 From: mtar Date: Tue, 27 Sep 2022 15:07:54 +0200 Subject: [PATCH 35/45] Update bug_report.yml fixes formatting issues --- .github/ISSUE_TEMPLATE/bug_report.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index d09661121b..8f9f3a0125 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -44,18 +44,19 @@ body: label: Python version description: What Python version? options: + - 3.7 - 3.8 - 3.9 - - 3.10 - - 3.7 + - "3.10" - type: dropdown id: pytorch-version attributes: label: PyTorch version description: What PyTorch version? options: + - 1.12 - 1.11 - - 1.10 + - "1.10" - 1.9 - 1.8 - 1.7 From ba1225af5279190e1392be3c2cd10750a4f3d410 Mon Sep 17 00:00:00 2001 From: mtar Date: Tue, 27 Sep 2022 15:11:45 +0200 Subject: [PATCH 36/45] Update bug_report.yml fixes an issue where the bug label is not set. --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 8f9f3a0125..707a87bc1e 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,7 +1,7 @@ name: Bug Report description: File a bug report title: "[Bug]: " -labels: ["bug"] +labels: ["bug :bug:"] body: - type: markdown From 9e4882aff247dfd6bde4cab2867deaa858b1c46d Mon Sep 17 00:00:00 2001 From: mtar Date: Tue, 27 Sep 2022 15:19:02 +0200 Subject: [PATCH 37/45] Update README.md Use status badge from a different workflow action --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 7d9510a677..ad5ebcfc35 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,7 @@ Heat is a distributed tensor framework for high performance data analytics. Project Status -------------- - -[![Jenkins](https://img.shields.io/jenkins/build?jobUrl=https%3A%2F%2Fheat-ci.fz-juelich.de%2Fjob%2Fheat%2Fjob%2Fheat%2Fjob%2Fmain%2F&label=CPU)](https://heat-ci.fz-juelich.de/blue/organizations/jenkins/heat%2Fheat/activity?branch=main) -[![Jenkins](https://img.shields.io/jenkins/build?jobUrl=https%3A%2F%2Fheat-ci.fz-juelich.de%2Fjob%2FGPU%2520Cluster%2Fjob%2Fmain%2F&label=GPU)](https://heat-ci.fz-juelich.de/blue/organizations/jenkins/GPU%20Cluster%2Fmain/activity) +[![Mirror and run GitLab CI](https://github.com/helmholtz-analytics/heat/actions/workflows/ci_cpu.yml/badge.svg?branch=main)](https://github.com/helmholtz-analytics/heat/actions/workflows/ci_cpu.yml) [![Documentation Status](https://readthedocs.org/projects/heat/badge/?version=latest)](https://heat.readthedocs.io/en/latest/?badge=latest) [![codecov](https://codecov.io/gh/helmholtz-analytics/heat/branch/main/graph/badge.svg)](https://codecov.io/gh/helmholtz-analytics/heat) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) From 439d54268e5968fb531dd8c93c7a3f45457b74f5 Mon Sep 17 00:00:00 2001 From: mtar Date: Fri, 30 Sep 2022 08:04:11 +0200 Subject: [PATCH 38/45] Update codecov.yml --- codecov.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/codecov.yml b/codecov.yml index 169384c39e..4f84c85a1a 100644 --- a/codecov.yml +++ b/codecov.yml @@ -38,6 +38,5 @@ coverage: only_pulls: false flags: - "unit" - - "gpu" paths: - "heat" From 0949a48f94cf1e3e2a5893064f985e37007bb7ea Mon Sep 17 00:00:00 2001 From: mtar Date: Fri, 30 Sep 2022 08:26:32 +0200 Subject: [PATCH 39/45] Update codecov.yml --- codecov.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/codecov.yml b/codecov.yml index 4f84c85a1a..6ea47e1bf2 100644 --- a/codecov.yml +++ b/codecov.yml @@ -16,7 +16,6 @@ coverage: base: auto flags: - unit - - gpu paths: - "heat" # advanced settings From 398ac0db63d6c6d7bfd18e934b6057c6697c26b0 Mon Sep 17 00:00:00 2001 From: Claudia Comito <39374113+ClaudiaComito@users.noreply.github.com> Date: Wed, 5 Oct 2022 11:01:54 +0200 Subject: [PATCH 40/45] Add section `Google Summer of Code 2022` --- .github/release-drafter.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 1791f1dd8f..4cb91a0024 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -29,6 +29,8 @@ categories: labels: - 'io' - 'communication' + - title: 'Google Summer of Code 2022' + label: 'GSoC22' change-template: '- #$NUMBER $TITLE (by @$AUTHOR)' categorie-template: '### $TITLE' exclude-labels: From 2fe13c3eab94d53d2016ac68243331c486f22f5d Mon Sep 17 00:00:00 2001 From: neosunhan <97215518+neosunhan@users.noreply.github.com> Date: Wed, 5 Oct 2022 17:29:42 +0800 Subject: [PATCH 41/45] Bug/1017 `prod` / `sum` with empty arrays (#1018) * Check for split in `__reduce_op` * Check whether x is distributed Co-authored-by: mtar Co-authored-by: mtar Co-authored-by: Claudia Comito <39374113+ClaudiaComito@users.noreply.github.com> --- heat/core/_operations.py | 2 +- heat/core/tests/test_arithmetics.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/heat/core/_operations.py b/heat/core/_operations.py index 75217f6b2d..08f04e305c 100644 --- a/heat/core/_operations.py +++ b/heat/core/_operations.py @@ -422,7 +422,7 @@ def __reduce_op( balanced = x.balanced # if local tensor is empty, replace it with the identity element - if 0 in x.lshape and (axis is None or (x.split in axis)): + if x.is_distributed() and 0 in x.lshape and (axis is None or split in axis): if neutral is None: neutral = float("nan") neutral_shape = x.gshape[:split] + (1,) + x.gshape[split + 1 :] diff --git a/heat/core/tests/test_arithmetics.py b/heat/core/tests/test_arithmetics.py index f1fc79d2d3..9e89a7e119 100644 --- a/heat/core/tests/test_arithmetics.py +++ b/heat/core/tests/test_arithmetics.py @@ -646,6 +646,10 @@ def test_prod(self): self.assertEqual(shape_split_axis_tuple_prod.split, None) self.assertTrue((shape_split_axis_tuple_prod == expected_result).all()) + # empty array + empty = ht.array([]) + self.assertEqual(ht.prod(empty), ht.array([1.0])) + # exceptions with self.assertRaises(ValueError): ht.ones(array_len).prod(axis=1) @@ -792,6 +796,10 @@ def test_sum(self): self.assertEqual(shape_split_axis_tuple_sum.split, None) self.assertTrue((shape_split_axis_tuple_sum == expected_result).all()) + # empty array + empty = ht.array([]) + self.assertEqual(ht.sum(empty), ht.array([0.0])) + # exceptions with self.assertRaises(ValueError): ht.ones(array_len).sum(axis=1) From db44c93c2e0fc8048e29c0dcb1b6882022be2aa5 Mon Sep 17 00:00:00 2001 From: Claudia Comito <39374113+ClaudiaComito@users.noreply.github.com> Date: Fri, 7 Oct 2022 13:54:28 +0200 Subject: [PATCH 42/45] Add section "Array API" --- .github/release-drafter.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 4cb91a0024..1d823f452e 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -31,6 +31,8 @@ categories: - 'communication' - title: 'Google Summer of Code 2022' label: 'GSoC22' + - title: 'Array API' + label: 'array API' change-template: '- #$NUMBER $TITLE (by @$AUTHOR)' categorie-template: '### $TITLE' exclude-labels: From d5c14b73d4bec036bc2c02e5709e570bed4a677d Mon Sep 17 00:00:00 2001 From: mtar Date: Fri, 7 Oct 2022 14:16:56 +0200 Subject: [PATCH 43/45] Mirror Repository and run GitHub CI at HZDR (#1032) * Update ci worflow action * Update codecov.yml --- .github/PULL_REQUEST_TEMPLATE.md | 3 --- .github/workflows/ci_cpu.yml | 8 +++--- .gitlab-ci.yml | 42 ++++++++++++++++++++------------ README.md | 2 +- codecov.yml | 13 ---------- setup.py | 2 +- 6 files changed, 32 insertions(+), 38 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 267787f455..5185637281 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -50,6 +50,3 @@ my be illegible. It may be easiest to save the output of each to a file. #### Does this change modify the behaviour of other functions? If so, which? yes / no - - -skip ci diff --git a/.github/workflows/ci_cpu.yml b/.github/workflows/ci_cpu.yml index 312abbcf13..a8b3f2efa7 100644 --- a/.github/workflows/ci_cpu.yml +++ b/.github/workflows/ci_cpu.yml @@ -10,11 +10,11 @@ jobs: - name: Mirror + trigger CI uses: SvanBoxel/gitlab-mirror-and-ci-action@master with: - args: "https://gitlab.jsc.fz-juelich.de/haf/heat" + args: "https://gitlab.hzdr.de/haf/heat" env: FORCE_PUSH: "true" - GITLAB_HOSTNAME: "gitlab.jsc.fz-juelich.de" + GITLAB_HOSTNAME: "gitlab.hzdr.de" GITLAB_USERNAME: "" - GITLAB_PASSWORD: ${{ secrets.GITLAB_TOKEN }} - GITLAB_PROJECT_ID: "4935" + GITLAB_PASSWORD: ${{ secrets.GITLAB_TOKEN_1 }} + GITLAB_PROJECT_ID: "845" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 10a3b4f889..822a501a9a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,19 +1,29 @@ test: - image: ubuntu:20.04 + image: nvidia/cuda:11.6.2-runtime-ubuntu20.04 tags: - - heat + - cuda + - x86_64 script: - - apt update - - apt -y install build-essential python3-pip curl - - DEBIAN_FRONTEND=noninteractive apt -y install libopenmpi-dev openmpi-bin openmpi-doc - - apt -y install libhdf5-openmpi-dev libpnetcdf-dev - - pip install pytest coverage - - pip install .[hdf5,netcdf] - - COVERAGE_FILE=report/cov/coverage1 mpirun --allow-run-as-root -n 1 coverage run --source=heat --parallel-mode -m pytest --junitxml=report/test/report1.xml heat/ - - COVERAGE_FILE=report/cov/coverage2 mpirun --allow-run-as-root -n 3 coverage run --source=heat --parallel-mode -m pytest --junitxml=report/test/report2.xml heat/ - - COVERAGE_FILE=report/cov/coverage5 mpirun --allow-run-as-root -n 5 coverage run --source=heat --parallel-mode -m pytest --junitxml=report/test/report5.xml heat/ - - COVERAGE_FILE=report/cov/coverage8 mpirun --allow-run-as-root -n 8 coverage run --source=heat --parallel-mode -m pytest --junitxml=report/test/report8.xml heat/ - - coverage combine report/cov/* - - coverage report - - coverage xml - - curl -s https://codecov.io/bash | bash -s -- -c -F unit -f coverage.xml -t $CODECOV_TOKEN || echo "Codecov failed to upload" + - apt update + - apt -y install build-essential python3-pip curl git + - DEBIAN_FRONTEND=noninteractive apt -y install libopenmpi-dev openmpi-bin openmpi-doc + - apt -y install libhdf5-openmpi-dev libpnetcdf-dev + - pip install pytest coverage + - pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116 + - pip install .[hdf5,netcdf] + - COVERAGE_FILE=report/cov/coverage1 HEAT_TEST_USE_DEVICE=cpu mpirun --allow-run-as-root -n 1 coverage run --source=heat --parallel-mode -m pytest --junitxml=report/test/report1.xml heat/ + - COVERAGE_FILE=report/cov/coverage2 HEAT_TEST_USE_DEVICE=gpu mpirun --allow-run-as-root -n 3 coverage run --source=heat --parallel-mode -m pytest --junitxml=report/test/report3.xml heat/ + - COVERAGE_FILE=report/cov/coverage5 HEAT_TEST_USE_DEVICE=cpu mpirun --allow-run-as-root -n 5 coverage run --source=heat --parallel-mode -m pytest --junitxml=report/test/report5.xml heat/ + - COVERAGE_FILE=report/cov/coverage8 HEAT_TEST_USE_DEVICE=gpu mpirun --allow-run-as-root -n 6 coverage run --source=heat --parallel-mode -m pytest --junitxml=report/test/report6.xml heat/ + - coverage combine report/cov/* + - coverage report + - coverage xml + - curl -Os https://uploader.codecov.io/latest/linux/codecov + - chmod +x codecov + - ./codecov -F unit -f ./coverage.xml -t $CODECOV_TOKEN -Z + artifacts: + when: always + paths: + - report/test/report*.xml + reports: + junit: report/test/report*.xml diff --git a/README.md b/README.md index ad5ebcfc35..fc2b53886e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Heat is a distributed tensor framework for high performance data analytics. Project Status -------------- -[![Mirror and run GitLab CI](https://github.com/helmholtz-analytics/heat/actions/workflows/ci_cpu.yml/badge.svg?branch=main)](https://github.com/helmholtz-analytics/heat/actions/workflows/ci_cpu.yml) +[![Mirror and run GitLab CI](https://github.com/helmholtz-analytics/heat/actions/workflows/ci_cpu.yml/badge.svg)](https://github.com/helmholtz-analytics/heat/actions/workflows/ci_cpu.yml) [![Documentation Status](https://readthedocs.org/projects/heat/badge/?version=latest)](https://heat.readthedocs.io/en/latest/?badge=latest) [![codecov](https://codecov.io/gh/helmholtz-analytics/heat/branch/main/graph/badge.svg)](https://codecov.io/gh/helmholtz-analytics/heat) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) diff --git a/codecov.yml b/codecov.yml index 6ea47e1bf2..95cd8ab0a5 100644 --- a/codecov.yml +++ b/codecov.yml @@ -13,28 +13,15 @@ coverage: # basic target: auto threshold: 3% - base: auto flags: - unit paths: - "heat" - # advanced settings - branches: - - main - if_ci_failed: error #success, failure, error, ignore - informational: false - only_pulls: false patch: default: # basic target: auto threshold: 3% - base: auto - # advanced - branches: - - main - if_ci_failed: error #success, failure, error, ignore - only_pulls: false flags: - "unit" paths: diff --git a/setup.py b/setup.py index 5aaea7ff3e..e97991ec3b 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ install_requires=[ "mpi4py>=3.0.0", "numpy>=1.13.0", - "torch>=1.7.0, <=1.12.1", + "torch>=1.7.0, <1.13", "scipy>=0.14.0", "pillow>=6.0.0", "torchvision>=0.8.0", From ea965ff9453e8a7965e2248e72e23ecd812c1de5 Mon Sep 17 00:00:00 2001 From: neosunhan <97215518+neosunhan@users.noreply.github.com> Date: Fri, 7 Oct 2022 21:27:54 +0800 Subject: [PATCH 44/45] Bug/999 Fix `keepdim` in `any`/`all` (#1000) * Fix `all` * Fix `any` * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add distributed tests * Expanded tests for combination of axis/split axis Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Claudia Comito <39374113+ClaudiaComito@users.noreply.github.com> Co-authored-by: mtar --- heat/core/logical.py | 6 ++++ heat/core/tests/test_logical.py | 52 +++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/heat/core/logical.py b/heat/core/logical.py index 9b4dcc8f79..a6be081ea7 100644 --- a/heat/core/logical.py +++ b/heat/core/logical.py @@ -91,6 +91,9 @@ def all( def local_all(t, *args, **kwargs): return torch.all(t != 0, *args, **kwargs) + if keepdim and axis is None: + axis = tuple(range(x.ndim)) + return _operations.__reduce_op( x, local_all, MPI.LAND, axis=axis, out=out, neutral=1, keepdim=keepdim ) @@ -196,6 +199,9 @@ def any( def local_any(t, *args, **kwargs): return torch.any(t != 0, *args, **kwargs) + if keepdim and axis is None: + axis = tuple(range(x.ndim)) + return _operations.__reduce_op( x, local_any, MPI.LOR, axis=axis, out=out, neutral=0, keepdim=keepdim ) diff --git a/heat/core/tests/test_logical.py b/heat/core/tests/test_logical.py index a995d53db3..691df7ec62 100644 --- a/heat/core/tests/test_logical.py +++ b/heat/core/tests/test_logical.py @@ -140,6 +140,32 @@ def test_all(self): out_noaxis = ht.zeros((1, 2, 3, 5), split=1) ht.all(ones_noaxis_split_axis_neg, axis=-2, out=out_noaxis) + # test keepdim + ones_2d = ht.ones((1, 1)) + self.assertEqual(ones_2d.all(keepdim=True).shape, ones_2d.shape) + + ones_2d_split = ht.ones((2, 2), split=0) + keepdim_is_one = ones_2d_split.all(keepdim=True) + self.assertEqual(keepdim_is_one.shape, (1, 1)) + self.assertEqual(keepdim_is_one.split, None) + keepdim_is_one = ones_2d_split.all(axis=0, keepdim=True) + self.assertEqual(keepdim_is_one.shape, (1, 2)) + self.assertEqual(keepdim_is_one.split, None) + keepdim_is_one = ones_2d_split.all(axis=1, keepdim=True) + self.assertEqual(keepdim_is_one.shape, (2, 1)) + self.assertEqual(keepdim_is_one.split, 0) + + ones_2d_split = ht.ones((2, 2), split=1) + keepdim_is_one = ones_2d_split.all(keepdim=True) + self.assertEqual(keepdim_is_one.shape, (1, 1)) + self.assertEqual(keepdim_is_one.split, None) + keepdim_is_one = ones_2d_split.all(axis=0, keepdim=True) + self.assertEqual(keepdim_is_one.shape, (1, 2)) + self.assertEqual(keepdim_is_one.split, 1) + keepdim_is_one = ones_2d_split.all(axis=1, keepdim=True) + self.assertEqual(keepdim_is_one.shape, (2, 1)) + self.assertEqual(keepdim_is_one.split, None) + # exceptions with self.assertRaises(ValueError): ht.ones(array_len).all(axis=1) @@ -212,6 +238,32 @@ def test_any(self): self.assertEqual(any_tensor.dtype, ht.bool) self.assertTrue(ht.equal(any_tensor, res)) + # test keepdim + ones_2d = ht.ones((1, 1)) + self.assertEqual(ones_2d.any(keepdim=True).shape, ones_2d.shape) + + ones_2d_split = ht.ones((2, 2), split=0) + keepdim_any = ones_2d_split.any(keepdim=True) + self.assertEqual(keepdim_any.shape, (1, 1)) + self.assertEqual(keepdim_any.split, None) + keepdim_any = ones_2d_split.any(axis=0, keepdim=True) + self.assertEqual(keepdim_any.shape, (1, 2)) + self.assertEqual(keepdim_any.split, None) + keepdim_any = ones_2d_split.any(axis=1, keepdim=True) + self.assertEqual(keepdim_any.shape, (2, 1)) + self.assertEqual(keepdim_any.split, 0) + + ones_2d_split = ht.ones((2, 2), split=1) + keepdim_any = ones_2d_split.any(keepdim=True) + self.assertEqual(keepdim_any.shape, (1, 1)) + self.assertEqual(keepdim_any.split, None) + keepdim_any = ones_2d_split.any(axis=0, keepdim=True) + self.assertEqual(keepdim_any.shape, (1, 2)) + self.assertEqual(keepdim_any.split, 1) + keepdim_any = ones_2d_split.any(axis=1, keepdim=True) + self.assertEqual(keepdim_any.shape, (2, 1)) + self.assertEqual(keepdim_any.split, None) + def test_isclose(self): size = ht.communication.MPI_WORLD.size a = ht.float32([[2, 2], [2, 2]]) From 5ba9b3276022b9b8f62ece396b78ba3a015c8f63 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 11 Oct 2022 02:20:36 +0000 Subject: [PATCH 45/45] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 22.8.0 → 22.10.0](https://github.com/psf/black/compare/22.8.0...22.10.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 593ee5aee5..20132efc45 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: - id: check-added-large-files - id: flake8 - repo: https://github.com/psf/black - rev: 22.8.0 + rev: 22.10.0 hooks: - id: black - repo: https://github.com/pycqa/pydocstyle