Skip to content

Commit 159617d

Browse files
authored
Update requirements for Ligthning Deepspeed (#9)
1 parent 4b08a1d commit 159617d

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

Lightning/DeepSpeed_Lightning/DeepSpeed_Lightning.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@
313313
}
314314
],
315315
"source": [
316-
"!pip install git+https://github.com/HabanaAI/DeepSpeed.git@1.11.0"
316+
"!pip install git+https://github.com/HabanaAI/DeepSpeed.git@1.14.0"
317317
]
318318
},
319319
{

Lightning/DeepSpeed_Lightning/lightning_gpt/models.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def training_step(self, batch: torch.Tensor, batch_idx: int) -> torch.Tensor:
199199
return loss
200200

201201
def generate(
202-
self, idx: torch.Tensor, max_new_tokens: int, temperature: float = 1.0, top_k: Optional[int] = None
202+
self, idx: torch.Tensor, max_new_tokens: int, temperature: float = 1.0, do_sample:bool = False, top_k: Optional[int] = None
203203
) -> torch.Tensor:
204204
return self.nanogpt.generate(idx, max_new_tokens, temperature, top_k)
205205

@@ -247,7 +247,7 @@ def configure_optimizers(self) -> torch.optim.AdamW:
247247

248248
class DeepSpeedNanoGPT(NanoGPT):
249249
# TODO: activation checkpointing (requires overriding forward)
250-
def __init__(self, fused_adam: bool = True, offload: bool = False, **kwargs: Any):
250+
def __init__(self, fused_adam: bool = False, offload: bool = False, **kwargs: Any):
251251
if fused_adam and offload:
252252
raise RuntimeError(
253253
"Cannot use FusedAdam and CPUAdam at the same time! "
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
lightning>=1.8.0
2-
torch>=1.10.0
1+
lightning>=2.2.0
2+
torch>=2.2.0
33
numpy
4-
lightning-habana==1.1.0
4+
lightning-habana==1.4.0

Lightning/DeepSpeed_Lightning/train.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
if module_available("lightning"):
99
import lightning.pytorch as L
10-
from lightning.pytorch.plugins import DeepSpeedPrecisionPlugin
10+
from lightning.pytorch.plugins import DeepSpeedPrecision
1111
elif module_available("pytorch_lightning"):
1212
import pytorch_lightning as L
13-
from pytorch_lightning.plugins import DeepSpeedPrecisionPlugin
13+
from pytorch_lightning.plugins import DeepSpeedPrecision
1414

1515
import gc
1616

@@ -157,7 +157,6 @@ def main(args):
157157
else HPUParallelStrategy(bucket_cap_mb=125, gradient_as_bucket_view=True, static_graph=True),
158158
callbacks=callback_list,
159159
accumulate_grad_batches=1,
160-
precision="bf16-mixed" if args.strategy == "deepspeed" else "16-mixed", # 16,
161160
max_epochs=args.max_epochs,
162161
num_nodes=1,
163162
check_val_every_n_epoch=5000,
@@ -166,7 +165,7 @@ def main(args):
166165
limit_val_batches=10,
167166
max_steps=args.max_steps,
168167
gradient_clip_val=1.0,
169-
plugins=[DeepSpeedPrecisionPlugin(precision="bf16-mixed")] if args.strategy == "deepspeed" else None,
168+
plugins=[DeepSpeedPrecision(precision="bf16-mixed")] if args.strategy == "deepspeed" else None,
170169
)
171170

172171
trainer.fit(model, train_loader)

0 commit comments

Comments
 (0)