Fix default dtype restoration after model loader errors (#34440)
Co-authored-by: zhisbug <1654062+zhisbug@users.noreply.github.com> Co-authored-by: Brayden Zhong <b8zhong@uwaterloo.ca>
This commit is contained in:
co-authored by
zhisbug
Brayden Zhong
parent
c58953d90a
commit
93c1bff1d4
@@ -25,8 +25,10 @@ def set_default_torch_dtype(dtype: torch.dtype):
|
|||||||
"""Sets the default torch dtype to the given dtype."""
|
"""Sets the default torch dtype to the given dtype."""
|
||||||
old_dtype = torch.get_default_dtype()
|
old_dtype = torch.get_default_dtype()
|
||||||
torch.set_default_dtype(dtype)
|
torch.set_default_dtype(dtype)
|
||||||
yield
|
try:
|
||||||
torch.set_default_dtype(old_dtype)
|
yield
|
||||||
|
finally:
|
||||||
|
torch.set_default_dtype(old_dtype)
|
||||||
|
|
||||||
|
|
||||||
def _is_moe_model(model_config: ModelConfig, architectures: list[str]) -> bool:
|
def _is_moe_model(model_config: ModelConfig, architectures: list[str]) -> bool:
|
||||||
|
|||||||
Reference in New Issue
Block a user