sbi icon indicating copy to clipboard operation
sbi copied to clipboard

sampling via pymc raises TypeError since pymc v5.20.1

Open janfb opened this issue 10 months ago • 11 comments

see #1390 for details.

To fix this issue, we should check whether pymc made a new release and fixed the problem and then remove the fail mark from the tests here

https://github.com/sbi-dev/sbi/blob/4c1ffa256f530ae09a330078a188e1dfa0b5603e/tests/mcmc_test.py#L188-L196

and here

https://github.com/sbi-dev/sbi/blob/4c1ffa256f530ae09a330078a188e1dfa0b5603e/tests/posterior_sampler_test.py#L30-L36

janfb avatar Feb 20 '25 13:02 janfb

Hi @janfb @gmoss13,

I hope you're doing well!

I’d like to take on this issue. From what I understand, the solution would involve checking if a new version of PyMC has been released that fixes the TypeError issue introduced in version 5.20.1. If there is a new release, I would then remove the xfail marks from the tests in sbi/tests/mcmc_test.py and sbi/tests/posterior_sampler_test.py.

Could you please assign this issue to me?

Thank You !

Muhammad-Rebaal avatar Mar 21 '25 07:03 Muhammad-Rebaal

Hi @Muhammad-Rebaal

thanks for offering to take on this issue. Yes, your plan looks good. Maybe this has been raised as an issue in pymc already.

If not, we should find out what exactly causes the error. Maybe there is a workaround for use until pymc has a fix. Maybe this problem is actually caused on our end and we can fix it. If not, we should create an issue in pymc.

Let me know if you have any questions!

janfb avatar Mar 25 '25 15:03 janfb

Hi @janfb, since Muhammad didn’t raise a PR, I will go ahead and try to resolve this issue—if that’s okay with you. He was assigned to it back in March, and now it’s already November.

Dev-Sudarshan avatar Nov 05 '25 19:11 Dev-Sudarshan

yeah, sounds good! Please check our contribution guide for how to get started contributing. Let me know if you need any input. Thanks! 🙏

janfb avatar Nov 05 '25 21:11 janfb

@janfb The new release of pymc has not been made that solves this issue and there are no any mentioned issue that points to this, when i searched in issue tracker of pymc . I think the workaround is to constrain the pymc version to 5.20.0 not sure if there are other options for it . Can you please suggest me what shall i do next ?

Dev-Sudarshan avatar Nov 06 '25 15:11 Dev-Sudarshan

Great to get this started!

A couple of questions:

  • Where you able to reproduce the issue with the current sbi release, 0.25, by running the test without the fail mark?
  • Does the error message still occur if you manually install the most recent pymc?

janfb avatar Nov 07 '25 14:11 janfb

Yes, the issue still persists with the current sbi release (v0.25). I ran the test without the @pytest.mark.xfail decorator and reproduced the error. Additionally, manually installing the latest version of pymc does not resolve it — the same error message continues to appear.

Dev-Sudarshan avatar Nov 08 '25 15:11 Dev-Sudarshan

I see, thanks for checking!

and pinning the version to "pymc>=5.0.0, <5.20" resolves the problem?

janfb avatar Nov 09 '25 16:11 janfb

Yes, pinning the version to "pymc>=5.0.0, <5.20" resolves the problem. -Working Range: The test works correctly on versions of PyMC less than 5.20 and also on 5.20.0.

-Failure Point: The failure starts at 5.20.1 (and continues in later versions), showing the TypeError: unsupported format string in the progress bar.

Dev-Sudarshan avatar Nov 09 '25 19:11 Dev-Sudarshan

Good, then we have a solution for now.

The tests already have a conditional flag for the 5.21 version, right? We can just keep that.

So, the only change would be in the dependencies, updating the pyproject.toml.

Would you be up for making that small PR?

janfb avatar Nov 10 '25 05:11 janfb

Yes , sure . I will be creating the PR as soon as i update pyproject.toml.

Dev-Sudarshan avatar Nov 10 '25 15:11 Dev-Sudarshan