Skip to content

Commit 4e87401

Browse files
musebcfacebook-github-bot
authored andcommitted
#71946 Remove Python 3.6 references (#72211)
Summary: Fixes #71946 This commit removes some bits of code that were hard coded for Python 3.6 support from the `.circleci` and `torch` folders. It should only be merged if #66462 is complete. Pull Request resolved: #72211 Reviewed By: dagitses, seemethere Differential Revision: D33982604 Pulled By: musebc fbshipit-source-id: a4948ce60bece8df9d2adc6d2add8dc19b637b22
1 parent f5c7f81 commit 4e87401

File tree

13 files changed

+23
-80
lines changed

13 files changed

+23
-80
lines changed

.circleci/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ A **binary configuration** is a collection of
7171
* release or nightly
7272
* releases are stable, nightlies are beta and built every night
7373
* python version
74-
* linux: 3.5m, 3.6m 3.7m (mu is wide unicode or something like that. It usually doesn't matter but you should know that it exists)
75-
* macos: 3.6, 3.7, 3.8
76-
* windows: 3.6, 3.7, 3.8
74+
* linux: 3.7m (mu is wide unicode or something like that. It usually doesn't matter but you should know that it exists)
75+
* macos: 3.7, 3.8
76+
* windows: 3.7, 3.8
7777
* cpu version
7878
* cpu, cuda 9.0, cuda 10.0
7979
* The supported cuda versions occasionally change
@@ -428,7 +428,7 @@ docker run \
428428
# possibly need are in .circleci/scripts/binary_populate_env.sh
429429
# You should probably always export at least these 3 variables
430430
export PACKAGE_TYPE=conda
431-
export DESIRED_PYTHON=3.6
431+
export DESIRED_PYTHON=3.7
432432
export DESIRED_CUDA=cpu
433433

434434
# Call the entrypoint
@@ -476,7 +476,7 @@ conda activate binary
476476
# possibly need are in .circleci/scripts/binary_populate_env.sh
477477
# You should probably always export at least these 3 variables
478478
export PACKAGE_TYPE=conda
479-
export DESIRED_PYTHON=3.6
479+
export DESIRED_PYTHON=3.7
480480
export DESIRED_CUDA=cpu
481481

482482
# Call the entrypoint you want

.circleci/cimodel/data/pytorch_build_definitions.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,13 +334,12 @@ def instantiate_configs(only_slow_gradcheck):
334334
build_only=build_only,
335335
)
336336

337-
# run docs builds on "pytorch-linux-xenial-py3.6-gcc5.4". Docs builds
337+
# run docs builds on "pytorch-linux-xenial-py3.7-gcc5.4". Docs builds
338338
# should run on a CPU-only build that runs on all PRs.
339-
# XXX should this be updated to a more modern build? Projects are
340-
# beginning to drop python3.6
339+
# XXX should this be updated to a more modern build?
341340
if (
342341
distro_name == "xenial"
343-
and fc.find_prop("pyver") == "3.6"
342+
and fc.find_prop("pyver") == "3.7"
344343
and cuda_version is None
345344
and parallel_backend is None
346345
and not is_vulkan

.circleci/cimodel/data/simple/docker_definitions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def get_workflow_jobs(images=IMAGE_NAMES, only_slow_gradcheck=False):
2626
"name": quote(f"docker-{image_name}"),
2727
"image_name": quote(image_name),
2828
})
29-
if image_name == "pytorch-linux-xenial-py3.6-gcc5.4":
29+
if image_name == "pytorch-linux-xenial-py3.7-gcc5.4":
3030
# pushing documentation on tags requires CircleCI to also
3131
# build all the dependencies on tags, including this docker image
3232
parameters['filters'] = gen_filter_dict(branches_list=r"/.*/",

.circleci/docker/common/install_conda.sh

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ if [ -n "$ANACONDA_PYTHON_VERSION" ]; then
1313
CONDA_FILE="Miniconda2-latest-Linux-x86_64.sh"
1414
;;
1515
3)
16-
if [ "$ANACONDA_PYTHON_VERSION" = "3.6" ]; then
17-
# Latest release of Conda that still supports python-3.6
18-
CONDA_FILE="Miniconda3-py37_4.10.3-Linux-x86_64.sh"
19-
else
20-
CONDA_FILE="Miniconda3-latest-Linux-x86_64.sh"
21-
fi
16+
CONDA_FILE="Miniconda3-latest-Linux-x86_64.sh"
2217
;;
2318
*)
2419
echo "Unsupported ANACONDA_PYTHON_VERSION: $ANACONDA_PYTHON_VERSION"
@@ -61,9 +56,7 @@ if [ -n "$ANACONDA_PYTHON_VERSION" ]; then
6156
pushd /opt/conda
6257

6358
# Track latest conda update
64-
if [ "$ANACONDA_PYTHON_VERSION" != "3.6" ]; then
65-
as_jenkins conda update -y -n base conda
66-
fi
59+
as_jenkins conda update -y -n base conda
6760

6861
# Install correct Python version
6962
as_jenkins conda install -y python="$ANACONDA_PYTHON_VERSION"

torch/_jit_internal.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,11 +1217,8 @@ def _isinstance(obj, target_type) -> bool:
12171217
if origin_type:
12181218
return container_checker(obj, target_type)
12191219

1220-
# Check to handle weird python type behaviors
1221-
# 1. python 3.6 returns None for origin of containers without
1222-
# contained type (intead of returning outer container type)
1223-
# 2. non-typed optional origin returns as none instead
1224-
# of as optional in 3.6-3.8
1220+
# Check to handle non-typed optional origin returns as none instead
1221+
# of as optional in 3.7-3.8
12251222
check_args_exist(target_type)
12261223

12271224
# handle non-containers

torch/csrc/utils/python_compat.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,9 @@
22

33
#include <torch/csrc/python_headers.h>
44

5-
#if PY_VERSION_HEX < 0x03070000
6-
// METH_FASTCALL was introduced in Python 3.7, so we wrap _PyCFunctionFast
7-
// signatures for earlier versions.
8-
9-
template <PyObject* (*f)(PyObject*, PyObject *const *, Py_ssize_t)>
10-
PyObject* maybe_wrap_fastcall(PyObject *module, PyObject *args) {
11-
return f(
12-
module,
13-
14-
// _PyTuple_ITEMS
15-
// Because this is only a compat shim for Python 3.6, we don't have
16-
// to worry about the representation changing.
17-
((PyTupleObject *)args)->ob_item,
18-
PySequence_Fast_GET_SIZE(args)
19-
);
20-
}
21-
22-
#define MAYBE_METH_FASTCALL METH_VARARGS
23-
#define MAYBE_WRAP_FASTCALL(f) maybe_wrap_fastcall<f>
24-
25-
#else
26-
275
#define MAYBE_METH_FASTCALL METH_FASTCALL
286
#define MAYBE_WRAP_FASTCALL(f) (PyCFunction)(void(*)(void))f
297

30-
#endif
31-
328
// PyPy 3.6 does not yet have PySlice_Unpack
339
#if PY_VERSION_HEX < 0x03060100 || defined(PYPY_VERSION)
3410

torch/distributed/algorithms/join.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,6 @@ def _notify_procs_to_terminate(self):
297297
"""
298298
ones = torch.ones(1, device=self._device)
299299
dist.all_reduce(ones, group=self._process_group)
300-
# NOTE: Raising `StopIteration` does not throw an error in Python 3.6
301-
# and throws a `RuntimeError` in Python 3.7+ (PEP 479), so we just
302-
# raise a `RuntimeError` here
303300
raise RuntimeError(f"Rank {self._rank} exhausted all inputs.")
304301

305302
@staticmethod

torch/distributed/elastic/multiprocessing/api.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import subprocess
1515
import sys
1616
import time
17-
from contextlib import AbstractContextManager
17+
from contextlib import nullcontext
1818
from dataclasses import dataclass, field
1919
from enum import IntFlag
2020
from multiprocessing import synchronize
@@ -334,22 +334,9 @@ def close(
334334
self._stderr_tail.stop()
335335

336336

337-
class _nullcontext(AbstractContextManager):
338-
# TODO remove and replace in favor of contextlib.nullcontext
339-
# when torch drops support for python3.6
340-
def __init__(self, enter_result=None):
341-
self.enter_result = enter_result
342-
343-
def __enter__(self):
344-
return self.enter_result
345-
346-
def __exit__(self, *excinfo):
347-
pass
348-
349-
350337
def get_std_cm(std_rd: str, redirect_fn):
351338
if IS_WINDOWS or IS_MACOS or not std_rd:
352-
return _nullcontext()
339+
return nullcontext()
353340
else:
354341
return redirect_fn(std_rd)
355342

torch/futures/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from typing import cast, Callable, Generic, List, Optional, Type, TypeVar, Union
24

35
import torch
@@ -90,8 +92,7 @@ def value(self) -> T:
9092
"""
9193
return super().value()
9294

93-
# Have to use string annotations because PEP-0563 is not available in 3.6
94-
def then(self, callback): # type: (Callable[[Future[T]], S]) -> Future[S]
95+
def then(self, callback: Callable[[Future[T]], S]) -> Future[S]:
9596
r"""
9697
Append the given callback function to this ``Future``, which will be run
9798
when the ``Future`` is completed. Multiple callbacks can be added to
@@ -154,8 +155,7 @@ def then(self, callback): # type: (Callable[[Future[T]], S]) -> Future[S]
154155
"""
155156
return cast(Future[S], super().then(callback))
156157

157-
# Have to use string annotations because PEP-0563 is not available in 3.6
158-
def add_done_callback(self, callback): # type: (Callable[[Future[T]], None]) -> None
158+
def add_done_callback(self, callback: Callable[[Future[T]], None]) -> None:
159159
r"""
160160
Append the given callback function to this ``Future``, which will be run
161161
when the ``Future`` is completed. Multiple callbacks can be added to

torch/fx/node.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ def _type_repr(obj):
4949
typically enough to uniquely identify a type. For everything
5050
else, we fall back on repr(obj).
5151
"""
52-
# HACK: In Python 3.6, type aliases from ``typing`` are instances of ``type``, but in
53-
# later Python versions, type aliases are not instances of ``type``!! We want
54-
# all type aliases to fall through to ``repr``, so if we have a type that is
55-
# in the module typing, don't go down this path.
56-
if isinstance(obj, type) and obj.__module__ != 'typing':
52+
if isinstance(obj, type):
5753
if obj.__module__ == 'builtins':
5854
return obj.__qualname__
5955
return f'{obj.__module__}.{obj.__qualname__}'

0 commit comments

Comments
 (0)