Upload folder using huggingface_hub
Browse files
__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (208 Bytes). View file
|
|
|
__pycache__/config.cpython-310.pyc
ADDED
|
Binary file (1.23 kB). View file
|
|
|
__pycache__/modeling.cpython-310.pyc
ADDED
|
Binary file (10.6 kB). View file
|
|
|
__pycache__/psi.cpython-310.pyc
ADDED
|
Binary file (23.8 kB). View file
|
|
|
modeling.py
CHANGED
|
@@ -4,6 +4,17 @@ import torch.nn as nn
|
|
| 4 |
import torch.nn.functional as F
|
| 5 |
import math
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
try:
|
| 8 |
import torch_xla.core.xla_model as xm
|
| 9 |
import torch_xla.distributed.spmd.xla_sharding as xs
|
|
|
|
| 4 |
import torch.nn.functional as F
|
| 5 |
import math
|
| 6 |
|
| 7 |
+
import sys
|
| 8 |
+
if "torch_xla" not in sys.modules:
|
| 9 |
+
sys.modules["torch_xla"] = type(sys)("torch_xla")
|
| 10 |
+
# Recreate the submodule structure
|
| 11 |
+
sys.modules["torch_xla"].core = type(sys)("core")
|
| 12 |
+
sys.modules["torch_xla"].distributed = type(sys)("distributed")
|
| 13 |
+
sys.modules["torch_xla"].distributed.spmd = type(sys)("spmd")
|
| 14 |
+
# Set required attributes to None (matching your try-except)
|
| 15 |
+
sys.modules["torch_xla"].core.xla_model = None
|
| 16 |
+
sys.modules["torch_xla"].distributed.spmd.xla_sharding = None
|
| 17 |
+
|
| 18 |
try:
|
| 19 |
import torch_xla.core.xla_model as xm
|
| 20 |
import torch_xla.distributed.spmd.xla_sharding as xs
|