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

Remove prefetch for megatron_gpt_sft_model.py #7274

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,20 @@ def inference_step(self, dataloader_iter, batch_idx, mode, dataloader_idx=0):
self._reconfigure_and_process_inference_batch(batch, data_cfg)
# Meta data from dataset
metadata = batch.get('metadata', [{}] * len(batch['tokens']))
loss = super().validation_step(itertools.chain([batch]), batch_idx)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the issue happens because of prefetch-ing when len(dataloader) ==1, what happens during GPT pre-training when val set is small enough to be just 1 batch?


# Initialize userbuffer communicators.
if self.initialize_ub:
self.initialize_ub_func()

if isinstance(self.model, list):
for model_module in self.model:
model_module.eval()

loss = self.fwd_bwd_step(itertools.chain([batch]), batch_idx, True)

if isinstance(self.model, list):
for model_module in self.model:
model_module.train()

# We need _inference_config to get generation params
# add_BOS and tokens_to_generate are set in dataset
Expand Down Expand Up @@ -428,10 +441,10 @@ def inference_step(self, dataloader_iter, batch_idx, mode, dataloader_idx=0):
if mode == 'validation':
if type(self.trainer.val_dataloaders) == list and len(self.trainer.val_dataloaders) > 1:
# super().validation_step appends just loss to self.validation_step_outputs, replace the last appended loss with the outputs dict
self.validation_step_outputs[dataloader_idx][-1] = outputs
self.validation_step_outputs[dataloader_idx].append(outputs)
aklife97 marked this conversation as resolved.
Show resolved Hide resolved
else:
# super().validation_step appends just loss to self.validation_step_outputs, replace the last appended loss with the outputs dict
self.validation_step_outputs[-1] = outputs
self.validation_step_outputs.append(outputs)
else:
if type(self.trainer.test_dataloaders) == list and len(self.trainer.test_dataloaders) > 1:
self.test_step_outputs[dataloader_idx][-1] = outputs
Expand Down
Loading