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

Prune deprecated trainer attributes 2 #7502

Merged
merged 5 commits into from
May 12, 2021
Merged

Prune deprecated trainer attributes 2 #7502

merged 5 commits into from
May 12, 2021

Conversation

Borda
Copy link
Member

@Borda Borda commented May 12, 2021

What does this PR do?

remove some other trainer arguments

Before submitting

  • Was this discussed/approved via a GitHub issue? (not for typos and docs)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together?
  • Did you make sure to update the documentation with your changes? (if necessary)
  • Did you write any new necessary tests? (not for typos and docs)
  • Did you verify new and existing tests pass locally with your changes?
  • Did you update the CHANGELOG? (not for typos, docs, test updates, or internal minor changes/refactorings)

PR review

Anyone in the community is free to review the PR once the tests have passed.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:

  • Is this pull request ready for review? (if not, please submit in draft mode)
  • Check that all items from Before submitting are resolved
  • Make sure the title is self-explanatory and the description concisely explains the PR
  • Add labels and milestones (and optionally projects) to the PR so it can be classified

Did you have fun?

Make sure you had fun coding 🙃

@Borda Borda added the refactor label May 12, 2021
@Borda Borda added this to the v1.4 milestone May 12, 2021
@codecov
Copy link

codecov bot commented May 12, 2021

Codecov Report

Merging #7502 (c60a821) into master (b9a52fa) will decrease coverage by 0%.
The diff coverage is n/a.

@@          Coverage Diff           @@
##           master   #7502   +/-   ##
======================================
- Coverage      92%     92%   -0%     
======================================
  Files         199     199           
  Lines       13066   13056   -10     
======================================
- Hits        12021   11973   -48     
- Misses       1045    1083   +38     

@Borda Borda marked this pull request as ready for review May 12, 2021 12:36
@Borda Borda added the ready PRs ready to be merged label May 12, 2021
@Borda Borda enabled auto-merge (squash) May 12, 2021 14:51
@Borda Borda merged commit 140b0c7 into master May 12, 2021
@Borda Borda deleted the prune/trainer-attribs2 branch May 12, 2021 17:19
@mmiakashs
Copy link

@Borda in the old version of PL, I used the following code to get the model inside the trainer

def get_model(self):
        is_dp_module = isinstance(self, (LightningDistributedDataParallel,
                                         LightningDataParallel))
        model = self.module if is_dp_module else self
        return model

I think this way to get the model is deprecated in the recent version. Could you please let me know, whether is there any way to get the model inside the trainer in computing strategy, like ddp_spawn ddp?

@carmocca
Copy link
Contributor

@mmiakashs
Copy link

Thanks, @carmocca. I have a custom model checkpointing class. I will try your suggestion. Just a quick question: does this self.strategy.lightning_module allow me to save the model in the traditional way (like torch.save(checkpoint, ckpt_filepath))?

@carmocca
Copy link
Contributor

I'm not quite sure about what you mean, but keep in mind that saving can be strategy-specific.

So trainer.save_checkpoint() calls strategy.save_checkpoint() internally: https://github.com/PyTorchLightning/pytorch-lightning/blob/d24361733c40fef3f7e981cc7f534db84a25509f/pytorch_lightning/trainer/connectors/checkpoint_connector.py#L448-L449

I suggest you use the same function yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready PRs ready to be merged refactor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants