Skip to content

Commit

Permalink
Add support for Python 3.8 (#448)
Browse files Browse the repository at this point in the history
Co-authored-by: 玄钛 <[email protected]>
Co-authored-by: Pete <[email protected]>
Co-authored-by: epwalsh <[email protected]>
  • Loading branch information
4 people authored Feb 13, 2024
1 parent d9c0993 commit 9fd9130
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 8 additions & 1 deletion olmo/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

import logging
import math
import sys
from abc import abstractmethod
from collections import defaultdict
from collections.abc import MutableMapping
from functools import partial
from typing import (
Callable,
Expand Down Expand Up @@ -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",
Expand Down
6 changes: 5 additions & 1 deletion olmo/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import warnings
from datetime import datetime
from enum import Enum
from functools import cache
from itertools import cycle, islice
from pathlib import Path
from queue import Queue
Expand All @@ -34,6 +33,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):
"""
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ description = "Open Language Model (OLMo)"
authors = [
{ name = "Allen Institute for Artificial Intelligence", email = "[email protected]" }
]
requires-python = ">=3.9"
requires-python = ">=3.8"
license = { file = "LICENSE" }
dependencies = [
"numpy",
Expand Down

0 comments on commit 9fd9130

Please sign in to comment.