pytorch / opacus

Training PyTorch models with differential privacy
https://opacus.ai
Apache License 2.0
1.65k stars 328 forks source link

Disable memory benchmarking #589

Closed ffuuugor closed 11 months ago

ffuuugor commented 1 year ago

Our tests have been red for a while due to failing memory bechmarks.

Issue

When benchmarking opacus we run the training script multiple times within one process:

for i in range(args.num_runs):
    run_layer_benchmark(
        ...
    )

We use built-in pytorch tools to check memory stats. Crucially, we verify that torch.cuda.memory_allocated() is 0 before the run starts. Normally, it should be 0, as all previous tensors are out of scope and should have been collected.

It all worked fine until something changed and some GPU memory stayed allocated between runs. No idea why, but explicit cache clearing or object deletion didn't help.

So I gave up and disabled memory benchmarking, since it seems like it's not a complicated thing to do due to some PyTorch update

facebook-github-bot commented 1 year ago

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot commented 1 year ago

@ffuuugor has updated the pull request. You must reimport the pull request before landing.

facebook-github-bot commented 1 year ago

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot commented 1 year ago

@ffuuugor has updated the pull request. You must reimport the pull request before landing.

facebook-github-bot commented 1 year ago

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

karthikprasad commented 1 year ago

So I gave up and disabled memory benchmarking,

I don't know well enough to make suggestion to resolve the issue, but I'm not so sure about disable the check (atleast not without knowing what failed).

since it seems like it's not a complicated thing to do due to some PyTorch update

Are you saying memory benchmarking is not necessary, or that doing it is easy?

facebook-github-bot commented 1 year ago

Hi @ffuuugor!

Thank you for your pull request.

We require contributors to sign our Contributor License Agreement, and yours needs attention.

You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

ffuuugor commented 1 year ago

Oh it came to this, I now have to sign CLA :(

@karthikprasad, let's maybe revise this? I got emails every night about broken tests and would rather make them stop.

Are you saying memory benchmarking is not necessary, or that doing it is easy?

I'm saying it's not critical and I think it's fine to disable it, given there's no obvious way to perform it. In other words, if we were writing these tests today, we wouldn't have included the memory tests, and the rest would still be useful

facebook-github-bot commented 11 months ago

@karthikprasad has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

facebook-github-bot commented 11 months ago

@karthikprasad merged this pull request in pytorch/opacus@7b280548d3199fd9ae09c19018e577ce271f9833.