From feb6b874df8b5c4805b0f0b84abfbb41e304b181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=84=E9=92=9B?= Date: Mon, 12 Feb 2024 18:12:00 +0800 Subject: [PATCH 1/9] adapt for py38 --- olmo/model.py | 2 +- olmo/util.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/olmo/model.py b/olmo/model.py index cc621a37b..8e682cd36 100644 --- a/olmo/model.py +++ b/olmo/model.py @@ -10,10 +10,10 @@ import math from abc import abstractmethod from collections import defaultdict -from collections.abc import MutableMapping from functools import partial from typing import ( Callable, + MutableMapping, Dict, Iterable, List, diff --git a/olmo/util.py b/olmo/util.py index 62e964b5d..47391b3be 100644 --- a/olmo/util.py +++ b/olmo/util.py @@ -7,7 +7,10 @@ import warnings from datetime import datetime from enum import Enum -from functools import cache +try: + from functools import cache +except ImportError: + from functools import lru_cache as cache from itertools import cycle, islice from pathlib import Path from queue import Queue From a97eba02fdda2ecc7ede60e21239072a96b0a964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=84=E9=92=9B?= Date: Mon, 12 Feb 2024 18:13:24 +0800 Subject: [PATCH 2/9] adapt for py38 --- olmo/model.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/olmo/model.py b/olmo/model.py index 8e682cd36..5881e9322 100644 --- a/olmo/model.py +++ b/olmo/model.py @@ -10,10 +10,13 @@ import math from abc import abstractmethod from collections import defaultdict +try: + from collections.abc import MutableMapping +except ImportError: + from typing import MutableMapping from functools import partial from typing import ( Callable, - MutableMapping, Dict, Iterable, List, From f7e3f186679ce537b352756bb96bc50f2db078f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=84=E9=92=9B?= Date: Mon, 12 Feb 2024 18:28:56 +0800 Subject: [PATCH 3/9] adapt for py38 --- olmo/model.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/olmo/model.py b/olmo/model.py index 5881e9322..c343612a2 100644 --- a/olmo/model.py +++ b/olmo/model.py @@ -10,10 +10,6 @@ import math from abc import abstractmethod from collections import defaultdict -try: - from collections.abc import MutableMapping -except ImportError: - from typing import MutableMapping from functools import partial from typing import ( Callable, @@ -33,6 +29,13 @@ import torch.nn as nn import torch.nn.functional as F from torch import einsum +import sys +if sys.version_info.minor > 8 : + from collections.abc import MutableMapping +elif sys.version_info.minor == 8: + from typing import MutableMapping +else: + raise SystemExit("This script supports Python 3.8 or higher") from .aliases import PathOrStr from .beam_search import BeamSearch, Constraint, FinalSequenceScorer, Sampler From 6989527a9dd6761d1752a3e3c29cac4a072fc0c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=84=E9=92=9B?= Date: Tue, 13 Feb 2024 10:23:29 +0800 Subject: [PATCH 4/9] sort import module --- olmo/model.py | 14 +++++++------- olmo/util.py | 10 ++++++---- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/olmo/model.py b/olmo/model.py index c343612a2..569f24e2c 100644 --- a/olmo/model.py +++ b/olmo/model.py @@ -6,6 +6,7 @@ from __future__ import annotations +import sys import logging import math from abc import abstractmethod @@ -29,13 +30,6 @@ import torch.nn as nn import torch.nn.functional as F from torch import einsum -import sys -if sys.version_info.minor > 8 : - from collections.abc import MutableMapping -elif sys.version_info.minor == 8: - from typing import MutableMapping -else: - raise SystemExit("This script supports Python 3.8 or higher") from .aliases import PathOrStr from .beam_search import BeamSearch, Constraint, FinalSequenceScorer, Sampler @@ -70,6 +64,12 @@ "OlmoGenerateOutput", ] +if sys.version_info.minor > 8 : + from collections.abc import MutableMapping +elif sys.version_info.minor == 8: + from typing import MutableMapping +else: + raise SystemExit("This script supports Python 3.8 or higher") log = logging.getLogger(__name__) diff --git a/olmo/util.py b/olmo/util.py index 47391b3be..bfcf766e7 100644 --- a/olmo/util.py +++ b/olmo/util.py @@ -7,10 +7,6 @@ import warnings from datetime import datetime from enum import Enum -try: - from functools import cache -except ImportError: - from functools import lru_cache as cache from itertools import cycle, islice from pathlib import Path from queue import Queue @@ -27,6 +23,7 @@ from rich.text import Text from rich.traceback import Traceback + from .aliases import PathOrStr from .exceptions import ( OlmoCliError, @@ -37,6 +34,11 @@ ) from .torch_util import get_global_rank, get_local_rank, get_node_rank, is_distributed +try: + from functools import cache +except ImportError: + from functools import lru_cache as cache + class StrEnum(str, Enum): """ From c9ba73f7f5f1531e1c7bf95f9a03822debb1801b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=84=E9=92=9B?= Date: Tue, 13 Feb 2024 10:24:10 +0800 Subject: [PATCH 5/9] sort import module --- olmo/util.py | 1 - 1 file changed, 1 deletion(-) diff --git a/olmo/util.py b/olmo/util.py index bfcf766e7..69b640b22 100644 --- a/olmo/util.py +++ b/olmo/util.py @@ -23,7 +23,6 @@ from rich.text import Text from rich.traceback import Traceback - from .aliases import PathOrStr from .exceptions import ( OlmoCliError, From 316e2349c8233ceeea0cbcffc22f0a00641e4c63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=84=E9=92=9B?= Date: Tue, 13 Feb 2024 11:10:18 +0800 Subject: [PATCH 6/9] sort import module --- olmo/model.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/olmo/model.py b/olmo/model.py index 569f24e2c..abc287bd2 100644 --- a/olmo/model.py +++ b/olmo/model.py @@ -46,6 +46,13 @@ from .initialization import ModuleType, init_weights from .torch_util import ensure_finite_ +if sys.version_info.minor > 8 : + from collections.abc import MutableMapping +elif sys.version_info.minor == 8: + from typing import MutableMapping +else: + raise SystemExit("This script supports Python 3.8 or higher") + __all__ = [ "LayerNormBase", "LayerNorm", @@ -64,12 +71,6 @@ "OlmoGenerateOutput", ] -if sys.version_info.minor > 8 : - from collections.abc import MutableMapping -elif sys.version_info.minor == 8: - from typing import MutableMapping -else: - raise SystemExit("This script supports Python 3.8 or higher") log = logging.getLogger(__name__) From daaca882c9fd70c0c5f057fbcdc6a2a4e01a0295 Mon Sep 17 00:00:00 2001 From: epwalsh Date: Tue, 13 Feb 2024 11:56:58 -0800 Subject: [PATCH 7/9] allow python 3.8 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index ba451325f..db9af8201 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ description = "Open Language Model (OLMo)" authors = [ { name = "Allen Institute for Artificial Intelligence", email = "olmo@allenai.org" } ] -requires-python = ">=3.9" +requires-python = ">=3.8" license = { file = "LICENSE" } dependencies = [ "numpy", From f767275d300f478acc55c227a258520c08e38f8b Mon Sep 17 00:00:00 2001 From: epwalsh Date: Tue, 13 Feb 2024 11:58:33 -0800 Subject: [PATCH 8/9] fix style --- olmo/model.py | 4 ++-- olmo/util.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/olmo/model.py b/olmo/model.py index 4f748b972..ce7ca28d1 100644 --- a/olmo/model.py +++ b/olmo/model.py @@ -6,9 +6,9 @@ from __future__ import annotations -import sys import logging import math +import sys from abc import abstractmethod from collections import defaultdict from functools import partial @@ -46,7 +46,7 @@ from .initialization import ModuleType, init_weights from .torch_util import ensure_finite_ -if sys.version_info.minor > 8 : +if sys.version_info.minor > 8: from collections.abc import MutableMapping elif sys.version_info.minor == 8: from typing import MutableMapping diff --git a/olmo/util.py b/olmo/util.py index 69b640b22..71ee67e60 100644 --- a/olmo/util.py +++ b/olmo/util.py @@ -34,10 +34,10 @@ from .torch_util import get_global_rank, get_local_rank, get_node_rank, is_distributed try: - from functools import cache + from functools import cache except ImportError: from functools import lru_cache as cache - + class StrEnum(str, Enum): """ From 5bee047b8547b035868a062ca3cde06df55e3967 Mon Sep 17 00:00:00 2001 From: epwalsh Date: Tue, 13 Feb 2024 12:15:53 -0800 Subject: [PATCH 9/9] CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a1c89f419..b916f3c4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed default value of `--tokenizer` argument to `scripts/prepare_tulu_data.py` to be an absolute path, not relative path, the script can be run from other directories. - Added the option to directly pass input embeddings to `OLMo` and `OLMoForCausalLM`. +- Added support for Python 3.8. ## [v0.2.4](https://github.com/allenai/OLMo/releases/tag/v0.2.4) - 2024-02-02