Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work with Python 3.8 #448

Merged
merged 10 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading