Skip to content

deprecate implicit shared-variable capture in OpFromGraph#2047

Open
alessandrogentili001 wants to merge 8 commits intopymc-devs:mainfrom
alessandrogentili001:Deprecate-special-handling-of-shared-variables-in-OpFromGraph
Open

deprecate implicit shared-variable capture in OpFromGraph#2047
alessandrogentili001 wants to merge 8 commits intopymc-devs:mainfrom
alessandrogentili001:Deprecate-special-handling-of-shared-variables-in-OpFromGraph

Conversation

@alessandrogentili001
Copy link
Copy Markdown
Contributor

@alessandrogentili001 alessandrogentili001 commented Apr 12, 2026

Description

This PR starts deprecating implicit shared-variable capture in OpFromGraph when strict=False.

Related Issue

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

"All variables needed to compute inner-graph must be provided as inputs under strict=True. "
f"The inner-graph implicitly depends on the following shared variables {self.shared_inputs}"
)
elif self.shared_inputs:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

strict=True forbids implicit shared variables.

We are in practice deprecating implicit shared variables then. That's good but the warning message is confusing by mentioning strict

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I'll simplify the message to state that the behavior is deprecated and provide the direct fix.

Tell me if this could be enough:
warnings.warn( "Implicit capture of shared variables is deprecated. " "Please provide shared variables explicitly in the 'inputs' list.", FutureWarning, stacklevel=2, )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yeah

@alessandrogentili001
Copy link
Copy Markdown
Contributor Author

idk what happened... is it my fault?

@alessandrogentili001
Copy link
Copy Markdown
Contributor Author

Of course was my fault :) now is ready!

@ricardoV94
Copy link
Copy Markdown
Member

I don't even know what happened but if blame is settled as must be good

Comment thread pytensor/compile/builders.py Outdated
warnings.warn(
"Implicit capture of shared variables is deprecated. "
"Please provide shared variables explicitly in the 'inputs' list.",
FutureWarning,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's make it DeprecationWarning. Users aren't really building OFGs and it gives a bit of room for devs in downstream packages to tackle it

@alessandrogentili001
Copy link
Copy Markdown
Contributor Author

pre-commit.ci autofix

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.

2 participants