Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Update torch requirement from <1.10.0,>=1.7.0 to >=1.7.0,<1.11.0 (#305)
Browse files Browse the repository at this point in the history
* Update torch requirement from <1.10.0,>=1.7.0 to >=1.7.0,<1.11.0

Updates the requirements on [torch](https://github.com/pytorch/pytorch) to permit the latest version.
- [Release notes](https://github.com/pytorch/pytorch/releases)
- [Changelog](https://github.com/pytorch/pytorch/blob/master/RELEASE.md)
- [Commits](pytorch/pytorch@v1.7.0...v1.10.0)

---
updated-dependencies:
- dependency-name: torch
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* update torch version in CI

* patch allennlp branch

* fix qanet models

* set seed for checklist test

* Fix conflict

* Update requirements.txt

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: epwalsh <petew@allenai.org>
Co-authored-by: epwalsh <epwalsh10@gmail.com>
  • Loading branch information
3 people authored Oct 25, 2021
1 parent 39557dd commit d1b81c3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
27 changes: 8 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ on:

env:
# NOTE: Need to update `TORCH_VERSION` and `TORCH_VISION_VERSION` for new torch releases.
TORCH_VERSION: 1.9.1
TORCH_VISION_VERSION: 0.10.1
TORCH_VERSION: 1.10.0
TORCH_VISION_VERSION: 0.11.1
# Change this to invalidate the current cache.
CACHE_PREFIX: v1
# Disable tokenizers parallelism because this doesn't help, and can cause issues in distributed tests.
Expand Down Expand Up @@ -156,20 +156,17 @@ jobs:
with:
path: .venv
key: ${{ env.CACHE_PREFIX }}-${{ env.WEEK_NUMBER }}-${{ runner.os }}-${{ env.RUNNER_ARCH }}-${{ env.PYTHON_VERSION }}-${{ matrix.task.torch_platform }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('dev-requirements.txt') }}
restore-keys: |
${{ env.CACHE_PREFIX }}-${{ env.WEEK_NUMBER }}-${{ runner.os }}-${{ env.RUNNER_ARCH }}-${{ env.PYTHON_VERSION }}-${{ matrix.task.torch_platform }}-

- name: Create virtual environment
if: steps.virtualenv-cache.outputs.cache-hit != 'true'
run: |
test -d .venv || virtualenv -p $(which python) --copies --reset-app-data .venv
pip install torch==${{ env.TORCH_VERSION }}+${{ matrix.task.torch_platform }} torchvision==${{ env.TORCH_VISION_VERSION }}+${{matrix.task.torch_platform}} -f https://download.pytorch.org/whl/torch_stable.html
- name: Install requirements
run: |
. .venv/bin/activate
pip install torch==${{ env.TORCH_VERSION }}+${{ matrix.task.torch_platform }} torchvision==${{ env.TORCH_VISION_VERSION }}+${{matrix.task.torch_platform}} -f https://download.pytorch.org/whl/torch_stable.html
pip uninstall -y allennlp
pip install --upgrade -r requirements.txt -r dev-requirements.txt
pip install -r requirements.txt -r dev-requirements.txt
- name: Show environment info
if: always()
Expand Down Expand Up @@ -286,21 +283,17 @@ jobs:
with:
path: .venv
key: ${{ env.CACHE_PREFIX }}-${{ env.WEEK_NUMBER }}-${{ runner.os }}-${{ env.RUNNER_ARCH }}-${{ env.PYTHON_VERSION }}-${{ env.TORCH_PLATFORM }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('dev-requirements.txt') }}
restore-keys: |
${{ env.CACHE_PREFIX }}-${{ env.WEEK_NUMBER }}-${{ runner.os }}-${{ env.RUNNER_ARCH }}-${{ env.PYTHON_VERSION }}-${{ env.TORCH_PLATFORM }}-

- name: Create virtual environment
if: steps.virtualenv-cache.outputs.cache-hit != 'true'
run: |
test -d .venv || virtualenv -p $(which python) --copies --reset-app-data .venv
pip install torch==${{ env.TORCH_VERSION }}+${{ env.TORCH_PLATFORM }} torchvision==${{ env.TORCH_VISION_VERSION }}+${{ env.TORCH_PLATFORM }} -f https://download.pytorch.org/whl/torch_stable.html
- name: Install requirements
run: |
. .venv/bin/activate
pip install torch==${{ env.TORCH_VERSION }}+${{ env.TORCH_PLATFORM }} torchvision==${{ env.TORCH_VISION_VERSION }}+${{ env.TORCH_PLATFORM }} -f https://download.pytorch.org/whl/torch_stable.html
pip uninstall -y allennlp
pip install --upgrade --upgrade-strategy eager -r requirements.txt
pip install --upgrade --upgrade-strategy eager -r dev-requirements.txt
pip install -r requirements.txt -r dev-requirements.txt
- name: Show environment info
run: |
Expand Down Expand Up @@ -431,21 +424,17 @@ jobs:
with:
path: .venv
key: ${{ env.CACHE_PREFIX }}-${{ env.WEEK_NUMBER }}-${{ runner.os }}-${{ env.RUNNER_ARCH }}-${{ env.PYTHON_VERSION }}-${{ env.TORCH_PLATFORM }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('dev-requirements.txt') }}
restore-keys: |
${{ env.CACHE_PREFIX }}-${{ env.WEEK_NUMBER }}-${{ runner.os }}-${{ env.RUNNER_ARCH }}-${{ env.PYTHON_VERSION }}-${{ env.TORCH_PLATFORM }}-

- name: Create virtual environment
if: steps.virtualenv-cache.outputs.cache-hit != 'true'
run: |
test -d .venv || virtualenv -p $(which python) --copies --reset-app-data .venv
pip install torch==${{ env.TORCH_VERSION }}+${{ env.TORCH_PLATFORM }} torchvision==${{ env.TORCH_VISION_VERSION }}+${{ env.TORCH_PLATFORM }} -f https://download.pytorch.org/whl/torch_stable.html
- name: Install requirements
run: |
. .venv/bin/activate
pip install torch==${{ env.TORCH_VERSION }}+${{ env.TORCH_PLATFORM }} torchvision==${{ env.TORCH_VISION_VERSION }}+${{ env.TORCH_PLATFORM }} -f https://download.pytorch.org/whl/torch_stable.html
pip uninstall -y allennlp
pip install --upgrade --upgrade-strategy eager -r requirements.txt
pip install --upgrade --upgrade-strategy eager -r dev-requirements.txt
pip install -r requirements.txt -r dev-requirements.txt
- name: Show environment info
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def forward(self, inputs: torch.Tensor, mask: torch.BoolTensor = None) -> torch.

for conv_norm_layer, conv_layer in zip(self._conv_norm_layers, self._conv_layers):
conv_norm_out = self.dropout(conv_norm_layer(output))
conv_out = self.dropout(conv_layer(conv_norm_out.transpose_(1, 2)).transpose_(1, 2))
conv_out = self.dropout(conv_layer(conv_norm_out.transpose(1, 2)).transpose(1, 2))
sublayer_count += 1
output = self.residual_with_layer_dropout(
output, conv_out, sublayer_count, total_sublayers
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
git+https://github.com/allenai/allennlp.git@main

torch>=1.7.0,<1.10.0
torch>=1.7.0,<1.11.0

# For structured prediction.
conllu==4.4.1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import random

import pytest
from allennlp.confidence_checks.task_checklists.textual_entailment_suite import (
TextualEntailmentSuite,
)
from allennlp.common.testing import AllenNlpTestCase
from allennlp.models.archival import load_archive
from allennlp.predictors import Predictor
import torch
import numpy

from allennlp_models.pair_classification.predictors import * # noqa: F403
from tests import FIXTURES_ROOT
Expand All @@ -19,6 +23,9 @@ class TestTextualEntailmentSuite(AllenNlpTestCase):
],
)
def test_run(self, model: str):
torch.manual_seed(1)
numpy.random.seed(1)
random.seed(1)

archive = load_archive(
FIXTURES_ROOT / "pair_classification" / model / "serialization" / "model.tar.gz"
Expand Down
3 changes: 3 additions & 0 deletions tests/rc/models/naqanet_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ def setup_method(self):
)

def test_model_can_train_save_and_load(self):
import torch

torch.autograd.set_detect_anomaly(True)
self.ensure_model_can_train_save_and_load(
self.param_file,
# Due to numerical instability, these scalar tensors might sometimes
Expand Down

0 comments on commit d1b81c3

Please sign in to comment.