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

update logic to inject FastForwardSampler / CaptureIterableDataset 2/n #8366

Merged
merged 96 commits into from
Aug 2, 2021

Conversation

tchaton
Copy link
Contributor

@tchaton tchaton commented Jul 10, 2021

What does this PR do?

Should be merged after #8364

Does your PR introduce any breaking changes ? If yes, please list them.

  • Could cause different behaviour depending on the seed of samplers within the iterable dataset.

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)
  • Did you list all the breaking changes introduced by this pull request?

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 🙃

@tchaton tchaton added the design Includes a design discussion label Jul 10, 2021
@tchaton tchaton added this to the v1.4 milestone Jul 10, 2021
@tchaton tchaton self-assigned this Jul 10, 2021
@tchaton tchaton changed the base branch from dataloaders_restore to master July 10, 2021 19:03
@tchaton tchaton changed the title update logic to inject FastForwardSampler / CaptureIterableDataset update logic to inject FastForwardSampler / CaptureIterableDataset 2/n Jul 10, 2021
@tchaton tchaton changed the base branch from master to dataloaders_restore July 10, 2021 19:05
@codecov
Copy link

codecov bot commented Jul 10, 2021

Codecov Report

Merging #8366 (36076ed) into master (850416f) will increase coverage by 4%.
The diff coverage is 100%.

@@           Coverage Diff           @@
##           master   #8366    +/-   ##
=======================================
+ Coverage      88%     93%    +4%     
=======================================
  Files         168     167     -1     
  Lines       13985   13971    -14     
=======================================
+ Hits        12355   12940   +585     
+ Misses       1630    1031   -599     

@tchaton tchaton changed the title update logic to inject FastForwardSampler / CaptureIterableDataset 2/n update logic to inject FastForwardSampler / CaptureIterableDataset 2/n [Merge in order] Jul 10, 2021
@awaelchli awaelchli added the feature Is an improvement or enhancement label Jul 29, 2021
@mergify mergify bot added the ready PRs ready to be merged label Aug 2, 2021
Co-authored-by: Carlos Mocholí <carlossmocholi@gmail.com>
Co-authored-by: Justus Schock <12886177+justusschock@users.noreply.github.com>
@tchaton tchaton enabled auto-merge (squash) August 2, 2021 18:39
@tchaton tchaton merged commit 567e905 into master Aug 2, 2021
# use current sampler
sampler = dataloader.sampler

dataloader = self.replace_sampler(dataloader, sampler, mode=mode)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @tchaton, should we have replaced the sampler even when self.accelerator_connector.replace_sampler_ddp is False? I'm not familiar with the logic here, but a few of our tests failed because replace_sampler is now invoked after this change. Specifically, the test uses a custom sampler, but _resolve_batch_sampler expects to be able to re-construct the sampler following way:

if (batch_sampler is not None and type(batch_sampler) is not BatchSampler) or is_predicting:
    batch_sampler = type(batch_sampler)(
        sampler,
        batch_size=batch_sampler.batch_size,
        drop_last=(False if is_predicting else batch_sampler.drop_last),
    )

However, the custom sampler in question doesn't have the expected fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It won't actually replace it if replace_sampler_ddp. But the code should be refactored as it does more than just replace the sampler.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is it fine if we only invoke replace_sampler in the if-clause like before? I've confirmed that it would "fix" our test.

@carmocca carmocca deleted the data_loading_extensions branch September 8, 2021 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design Includes a design discussion feature Is an improvement or enhancement ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants