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

Optimize memory in loss consumption #259

Open
NouamaneTazi opened this issue Dec 4, 2024 · 0 comments
Open

Optimize memory in loss consumption #259

NouamaneTazi opened this issue Dec 4, 2024 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@NouamaneTazi
Copy link
Member

If we check memory snapshot using:

        if self.iteration_step == self.initial_iter_step:
            torch.cuda.memory._record_memory_history(max_entries=100000)

        outputs = self.pipeline_engine.train_batch_iter(
            model=self.model,
            pg=self.parallel_context.pp_pg,
            batch=(next(dataloader) for _ in range(self.n_micro_batches_per_batch)),
            nb_microbatches=self.n_micro_batches_per_batch,
            grad_accumulator=self.grad_accumulator,
        )

        if self.iteration_step == self.initial_iter_step:
            torch.cuda.memory._dump_snapshot("memory_snapshot.pkl")
            torch.cuda.memory._record_memory_history(enabled=None)

We get
image

We can see that the memory consumption for the loss (which is at the top) is pretty big (10GB). It's composed from:

  • src/nanotron/models/llama.py:876:: 4GB
  • src/nanotron/parallel/tensor_parallel/functional.py:115:sharded_cross_entropy: 4GB

We need to optimize that

@NouamaneTazi NouamaneTazi added the help wanted Extra attention is needed label Dec 4, 2024
@NouamaneTazi NouamaneTazi changed the title Optimizer memory in loss consumption Optimize memory in loss consumption Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant