Reorganize compile module and remove deprecated functionality#1351
Open
ricardoV94 wants to merge 11 commits intopymc-devs:v3from
Open
Reorganize compile module and remove deprecated functionality#1351ricardoV94 wants to merge 11 commits intopymc-devs:v3from
ricardoV94 wants to merge 11 commits intopymc-devs:v3from
Conversation
0dc3147 to
782bc2d
Compare
9f026c7 to
4c1f269
Compare
a15d0e5 to
482cded
Compare
Open
7 tasks
482cded to
b5b538f
Compare
2e801bc to
aaf2419
Compare
aaf2419 to
7033561
Compare
Member
|
@ricardoV94 What is this |
Member
Author
|
Something that changed name in #1993 probably, let me find and rerun |
Member
Author
|
Ah dropped during rebase, it was new to this PR?... |
7033561 to
a6fd083
Compare
ab8ada1 to
02dcb25
Compare
02dcb25 to
a5a6893
Compare
a5a6893 to
67f24f5
Compare
493ecbc to
4bd3817
Compare
Remove pfunc as a separate entry point. function() now directly calls construct_function_ins_and_outs + FunctionMaker, eliminating an unnecessary layer of indirection. Also: - Inline _pfunc_param_to_in as a local closure (param_to_in), drop unused strict parameter - Fix stale docstring in construct_function_ins_and_outs Remove redundant tests between TestFunction (ex-TestPfunc) and TestFunctionIn: - test_param_strict (duplicate of test_in_strict) - test_param_mutable (duplicate of test_in_mutable) - test_param_allow_downcast_int (duplicate of test_in_allow_downcast_int) - test_param_allow_downcast_floatX (duplicate of test_in_allow_downcast_floatX) - test_param_allow_downcast_vector_floatX (duplicate of test_in_allow_downcast_vector_floatX) - test_explicit_shared_input (duplicate of test_no_shared_as_input)
Only used internally in construct_function_ins_and_outs, replace with direct isinstance(updates, dict) checks at the two call sites.
Replace orig_function usage in Scan with direct mode.function_maker() call. The profiling that orig_function did is already handled by FunctionMaker itself.
Subsume std_fgraph as a staticmethod on FunctionMaker and inline _optcheck_fgraph in DebugMode._Maker where it was the only caller. Also fixes a bug where the clone parameter was computed but not passed to FunctionGraph.__init__.
7c1c3db to
ae25e2a
Compare
Member
Author
|
mypy failures look unrelated... |
Replace with flat modules: - compile/maker.py: function(), FunctionMaker - compile/executor.py: Function class, pickle support, AliasedMemoryError - compile/aliasing.py: Supervisor, alias/view/deepcopy utilities - compile/rebuild.py: rebuild_collect_shared, construct_function_ins_and_outs Also moves get_info_on_inputs into Function as a static method and inlines fgraph_updated_vars at its only call site.
- compile/debugmode.py -> compile/debug/debugmode.py - compile/nanguardmode.py -> compile/debug/nanguardmode.py - compile/monitormode.py -> compile/debug/monitormode.py - compile/profiling.py -> compile/debug/profiling.py - Move function_dump into compile/debug/dump.py
ae25e2a to
7cc06ff
Compare
Update type: ignore comments to use correct error codes for mypy 1.20: - random.py: suppress unreachable warning in match/case - einsum.py: replace stale misc/has-type codes with str-unpack/arg-type
7cc06ff to
2b325e6
Compare
Member
Author
|
Second round, scope creep so original reviews are pretty much moot |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removing all the deprecated stuff that nobody uses
Update: Many of the performance-critical changes were already adopted in spin-off, so this PR is mostly deprecating old stuff and refactoring things
Old discussion on perf
I think after this there's not much more fat to trim. We could try to avoid the input/output list thing with linkers that don't need it but we still need to sort them/ recognize kwargs which is pretty much what's left.
The C part of the call takes 100ns, so the "overhead" in this case is 200-250ns.
For reference, calling
numpy.zeros(100)takes like ~250ns, and a python identity function is ~20ns.Results of the new benchmark
Before
After
I also removed the strict zip, because passing
strict=Falseis more than 100ns slower than not specifying it at all. Check out with this snippet:Closes #1332
Does the same as and closes #1976
Closes #1647
📚 Documentation preview 📚: https://pytensor--1351.org.readthedocs.build/en/1351/