Skip to content

Commit

Permalink
Add support for PyTorch v2.2 (#476)
Browse files Browse the repository at this point in the history
  • Loading branch information
epwalsh committed Mar 1, 2024
1 parent 67d24f5 commit cb711e2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Added `output_hidden_states` argument and associated functionality to `OLMo` and `OLMoForCausalLM` to return model intermediate hidden states.
- Added MMLU downstream evaluation tasks.
- Added support for PyTorch v2.2.

## [v0.2.4](https://github.com/allenai/OLMo/releases/tag/v0.2.4) - 2024-02-02

Expand Down
8 changes: 7 additions & 1 deletion olmo/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@
ShardedOptimStateDictConfig,
ShardedStateDictConfig,
)
from torch.distributed.fsdp.flat_param import FlatParamHandle
from torch.futures import Future

try:
from torch.distributed.fsdp.flat_param import FlatParamHandle # type: ignore
except ModuleNotFoundError:
from torch.distributed.fsdp._flat_param import FlatParamHandle # type: ignore

from .aliases import PathOrStr
from .config import BaseConfig, ShardedCheckpointerType, TrainConfig
from .optim import Optimizer, fix_optim_state_dict
Expand Down Expand Up @@ -1124,6 +1128,8 @@ def _fsdp_handles(self, fsdp_model: FSDP) -> List[FlatParamHandle]:
return [fsdp_model._handle] # type: ignore
else:
return []
elif version.parse(torch.__version__) < version.parse("2.3.0"):
return fsdp_model._all_handles
else:
# Need to verify FSDP internals with newer versions.
raise NotImplementedError
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ requires-python = ">=3.8"
license = { file = "LICENSE" }
dependencies = [
"numpy",
"torch>=2.0,<2.2",
"torch>=2.0,<2.3",
"omegaconf",
"rich",
"boto3",
Expand Down

0 comments on commit cb711e2

Please sign in to comment.