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

Deprecate remaining VI methods #5642

Closed
wants to merge 9 commits into from

Conversation

purna135
Copy link
Member

Addressing #5581

Replaced remaining NotImplementedInference methods with deprecation warning.

@twiecki twiecki marked this pull request as draft March 22, 2022 13:21
@twiecki twiecki changed the title [WIP] Deprecate remaining VI methods Deprecate remaining VI methods Mar 22, 2022
@codecov
Copy link

codecov bot commented Mar 22, 2022

Codecov Report

Merging #5642 (4623916) into main (b5a5b56) will decrease coverage by 7.32%.
The diff coverage is 62.50%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5642      +/-   ##
==========================================
- Coverage   89.36%   82.04%   -7.33%     
==========================================
  Files          74       73       -1     
  Lines       13805    13152     -653     
==========================================
- Hits        12337    10790    -1547     
- Misses       1468     2362     +894     
Impacted Files Coverage Δ
pymc/sampling_jax.py 0.00% <0.00%> (-96.97%) ⬇️
pymc/tuning/starting.py 92.56% <ø> (-0.13%) ⬇️
pymc/variational/__init__.py 100.00% <ø> (ø)
pymc/variational/opvi.py 36.80% <15.00%> (-45.47%) ⬇️
pymc/variational/approximations.py 43.72% <25.00%> (-22.35%) ⬇️
pymc/variational/inference.py 18.94% <33.33%> (-68.30%) ⬇️
pymc/parallel_sampling.py 86.79% <66.66%> (+0.08%) ⬆️
pymc/sampling.py 70.21% <76.74%> (-18.22%) ⬇️
pymc/aesaraf.py 90.88% <100.00%> (-0.74%) ⬇️
pymc/distributions/censored.py 93.02% <100.00%> (-1.72%) ⬇️
... and 30 more

@purna135
Copy link
Member Author

I need some help with the next step; is adding a deprecation warning the right way to go?

@ghost
Copy link

ghost commented Mar 23, 2022

I think the idea was to just remove them (even though the title in the issue says "deprecate"). The methods are not implemented in v4, so there is really nothing to deprecate.

@purna135
Copy link
Member Author

purna135 commented Mar 26, 2022

Could someone please help me remove the Normalizing flows?
I'm not sure if I should remove the entire NormalizingFlowGroup class or just a few lines of code.

def __init_group__(self, group):
raise NotImplementedInference("Normalizing flows are not yet ported to v4")
super().__init_group__(group)

@canyon289
Copy link
Member

@ferrine would you like to take a look here?

Copy link
Member

@ferrine ferrine left a comment

Choose a reason for hiding this comment

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

As for normalizing flows I expect something like rm pymc/variational/flows.py as a good first step

@@ -270,14 +272,14 @@ def _new_initial(self, size, deterministic, more_replacements=None):
at.repeat(self.mean.reshape((1, -1)), size, -1),
self.histogram[self.randidx(size)],
)
elif deterministic:
warnings.warn(
"Deterministic sampling from a Histogram is deprecated and will be removed soon.",
Copy link
Member

Choose a reason for hiding this comment

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

Is it indeed broken or it was a false alarm?

Copy link
Member

Choose a reason for hiding this comment

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

We can enable the test for that and check

@@ -957,9 +957,9 @@ def __init_group__(self, group):
if not group:
raise GroupError("Got empty group")
if self.local:
Copy link
Member

Choose a reason for hiding this comment

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

I think the context of the issue was to entirely delete the code and local kwarg, feel free to just delete large portions of the code.

@@ -957,9 +957,9 @@ def __init_group__(self, group):
if not group:
raise GroupError("Got empty group")
if self.local:
raise NotImplementedInference("Local inferene aka AEVB is not supported in v4")
warnings.warn("Local inferene aka AEVB is deprecated.", DeprecationWarning)
if self.batched:
Copy link
Member

@ferrine ferrine Apr 22, 2022

Choose a reason for hiding this comment

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

Same for batched kwarg and all its mentions. Just delete without hesitation

@fonnesbeck
Copy link
Member

Is this enough to go on @purna135 ?

@purna135
Copy link
Member Author

I'll work on these suggestions and let you know if I need anything else.
Thank you very much.

@michaelosthege michaelosthege added this to the v4.0.0 milestone May 21, 2022
@michaelosthege
Copy link
Member

Hi @purna135, this PR is one of the final steps towards v4.0.0. Could you pick it up again and push it over the finish line?

@purna135
Copy link
Member Author

Hi @michaelosthege sorry for the delay; I was preoccupied with my exam, which has now been done.
I will complete this RP in few days.

@@ -957,9 +957,9 @@ def __init_group__(self, group):
if not group:
raise GroupError("Got empty group")
if self.local:
raise NotImplementedInference("Local inferene aka AEVB is not supported in v4")
warnings.warn("Local inferene aka AEVB is deprecated.", DeprecationWarning)
Copy link
Member

Choose a reason for hiding this comment

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

We should just delete this code, rather than deprecate.

@purna135 purna135 force-pushed the deprecate_vi_methods branch from 473e28e to 66c1786 Compare May 23, 2022 10:37
@purna135
Copy link
Member Author

Hi @twiecki and @ferrine could you please have a look if this is the right way to go?

@twiecki twiecki requested a review from ferrine May 24, 2022 10:48
Copy link
Member

@ferrine ferrine left a comment

Choose a reason for hiding this comment

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

Looks good to me, can be merged once tests pass

@purna135
Copy link
Member Author

Thank you very much, @ferrine. Could you kindly advise me on how to pass these failed tests?
In the doc string, I realised I left some references to batched and local, which I will remove in my next commit.

@ferrine
Copy link
Member

ferrine commented May 24, 2022

@purna135, the tests diff was collapsed. I think I missed something here. I have to go through it once more

(not_raises(), {MeanFieldGroup: ["one"], FullRankGroup: ["two", "three"]}),
],
)
@ignore_not_implemented_inference
Copy link
Member

@ferrine ferrine May 24, 2022

Choose a reason for hiding this comment

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

the ignore_not_implemented_inference hook was used to ignore tests that fail due to the not supported functionality.

NotImplementedInference is an explicit error not to confuse failures with other "bugs". Most of the tests that are deleted so far are valid tests.

The commit that deletes all these tests should be reverted. Or, if not easy, you can use the original file that is present in master.

To summarise.

  1. The only obsolete thing in the test file is ignore_not_implemented_inference.
  2. Once it is removed, all tests should pass and no NotImplementedInference is raised.
  3. The only tests to remove are that fail because of the removed functionality.

Copy link
Member

@ferrine ferrine left a comment

Choose a reason for hiding this comment

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

I missed the collapsed diff of tests. Most of the deleted tests are valid. I've left a comment above with the explanation.

@ferrine
Copy link
Member

ferrine commented May 24, 2022

We did a quick video chat with @purna135 to avoid further confusion. Additional thing to revisit was the documentation. That missed my eye as well.

@purna135
Copy link
Member Author

Thank you so much for your time and help @ferrine : )

@purna135
Copy link
Member Author

Hello, @ferrine. I deleted several flow-related tests and refactored others, but there are still 10 tests that I am unable to refactor and have commented so that other tests can be checked. Could you please assist me in refactoring the tests I commented?
Many thanks

@purna135 purna135 closed this May 25, 2022
@purna135 purna135 deleted the deprecate_vi_methods branch May 25, 2022 19:02
@purna135 purna135 restored the deprecate_vi_methods branch May 25, 2022 19:03
@purna135 purna135 reopened this May 25, 2022
@purna135 purna135 closed this May 25, 2022
@purna135 purna135 deleted the deprecate_vi_methods branch May 25, 2022 19:24
@purna135 purna135 restored the deprecate_vi_methods branch May 25, 2022 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants