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

revert: support Pytorch multiple optimizers and LR schedulers #806

Merged
merged 1 commit into from
Jun 30, 2020
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
5 changes: 1 addition & 4 deletions common/determined_common/experimental/checkpoint/_torch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ def load_model(ckpt_dir: pathlib.Path, metadata: Dict[str, Any], **kwargs: Any)
trial = cast(PyTorchTrial, trial)
model = trial.build_model()
checkpoint = torch.load(ckpt_dir.joinpath("state_dict.pth"), map_location="cpu") # type: ignore

# TODO(DET-3456): The checkpoint schema is changed for mutliple models so this function should
# be updated accordingly.
model.load_state_dict(checkpoint["models_state_dict"][0])
model.load_state_dict(checkpoint["model_state_dict"])

return model
1 change: 0 additions & 1 deletion harness/determined/_experiment_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def native_enabled(self) -> bool:
def native_parallel_enabled(self) -> bool:
return bool(self["resources"]["native_parallel"])

# TODO(DET-3262): remove this backward compatibility.
def mixed_precision_enabled(self) -> bool:
return bool(self["optimizations"]["mixed_precision"] != "O0")

Expand Down
3 changes: 0 additions & 3 deletions harness/determined/pytorch/_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def on_before_optimizer_step(self, parameters: Iterator) -> None:
after gradient updates have been communicated. Typically used to perform gradient
clipping.
"""
# TODO(DET-3267): deprecate this when releasing pytorch flexible primitives.
pass

def on_validation_step_start(self) -> None:
Expand Down Expand Up @@ -88,7 +87,6 @@ def load_state_dict(self, state_dict: Dict[str, Any]) -> None:
pass


# TODO(DET-3267): deprecate this when releasing pytorch flexible primitives.
class ClipGradsL2Norm(PyTorchCallback):
"""
Callback that performs gradient clipping using
Expand All @@ -102,7 +100,6 @@ def on_before_optimizer_step(self, parameters: Iterator) -> None:
torch.nn.utils.clip_grad_norm_(parameters, self._clip_value) # type: ignore


# TODO(DET-3267): deprecate this when releasing pytorch flexible primitives.
class ClipGradsL2Value(PyTorchCallback):
"""
Callback that performs gradient clipping using
Expand Down
7 changes: 3 additions & 4 deletions harness/determined/pytorch/_lr_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ class LRScheduler:
"""Wrapper for a PyTorch LRScheduler.

This wrapper fulfills two main functions:

1. Save and restore the learning rate when a trial is paused, preempted, etc.
2. Step the learning rate scheduler at the configured frequency
(e.g., every batch or every epoch).
1. Save and restore the learning rate when a trial is paused, preempted, etc.
2. Step the learning rate scheduler at the configured frequency
(e.g., every batch or every epoch).
"""

class StepMode(enum.Enum):
Expand Down
Loading