Skip to content

Remove dead code#2256

Open
ricardoV94 wants to merge 18 commits into
pymc-devs:mainfrom
ricardoV94:cleanup
Open

Remove dead code#2256
ricardoV94 wants to merge 18 commits into
pymc-devs:mainfrom
ricardoV94:cleanup

Conversation

@ricardoV94

@ricardoV94 ricardoV94 commented Jun 25, 2026

Copy link
Copy Markdown
Member

I told the bots to grab a mop and get to work, then walked with it through all the "findings". This is what we ended up with:

  • Remove dead frame-walking debug print in Validator.validate
  • Don't mutate global config.openmp from OpenMPOp codegen
  • Remove dead, broken profile-sum-at-exit block
  • Remove GPU-backend leftovers from scan
  • Remove dead GPU-era Type.filter_inplace hook
  • Remove dead gcc_llvm detector and Python-2 'SO' suffix fallback
  • Remove dead scalar and printing helpers
  • Remove dead config flags warn__ignore_bug_before and metaopt__verbose
  • Remove deprecated end/steps arguments from linspace/geomspace/logspace
  • Fix CachedEquilibrimDB cache never invalidating on register
  • Fix Elemwise.perform falling through with >32 operands
  • Fix linker=vm returning a tuple instead of a Mode
  • Fix misspelled DisconnectedType.filter_variable override
  • Fix OpToRewriterTracker double-registering OpPatterns
  • Fix print_global_stats writing to the filename string
  • Remove is_same_graph in favor of equal_computations
  • Remove dead full_tree debug param from perform_sigm_times_exp
  • Collapse three near-identical Unique lift rewriters into one

The except branch reached into the caller's frame locals to print a
validation-failure message. It was a no-op for every in-tree caller and
the real message comes from replace_all_validate.
The class-level gxx_support_openmp cache already disables OpenMP on every
op when the compiler lacks support, so the global write was redundant.
The 'Sum of all printed profiles at exit' path referenced a nonexistent
attribute and called .items() on a string, so it raised whenever more
than one profile was summed; it never worked.
Delete the dead 'traverse' helper (only its GPU branch did anything, and
nothing called it) and the unreachable gpudata else-branches in perform;
scan outputs are always TensorVariable (asserted in make_thunk).
No Type overrode filter_inplace; it only ever raised NotImplementedError,
so Container.__set__ raised and caught it on every container value set
(e.g. shared.set_value) before falling back to filter. Call filter directly.
gcc_llvm() had no callers (along with its GCCLLVMType typing scaffold);
EXT_SUFFIX is always present on supported Python versions, so the 'SO'
fallback in _get_ext_suffix is dead. PyPy branch left untouched.
Delete unused scalar helpers (int_out_nocomplex, float_out_nocomplex,
unary_out_lookup, as_common_dtype, Cast.clone_float32 from the old
float16/GPU codegen protocol) and the dead printing trio
(var_descriptor/position_independent_str/hex_digest), which only called
each other and were referenced nowhere.
Neither was wired up: _warn_default (the only reader of
warn__ignore_bug_before) had no callers, metaopt__verbose was never
registered, and the cast_policy 'numpy' branch was unreachable since
that enum value is disabled. Drop the helpers, annotations, the dead
cast branch, and the stale docs.
They were deprecated in July 2024 (gh pymc-devs#748) and have no in-repo callers; drop the end/steps parameters, the _check_deprecated_inputs helper, and the related docstrings/tests.
register() cleared self.cached_default_query (a junk attribute) instead
of self._cached_default_query, so rewrites registered after the first
default_query access were silently dropped from the cached query.
The >32-operand guard called the no-op super().perform() without
returning, so execution fell through to the ufunc path that segfaults or
raises with that many operands. Raise NotImplementedError instead.
fast_run_linkers_to_mode['vm'] wrapped the Mode in a 1-tuple, so
get_mode('FAST_RUN') with linker=vm returned a tuple.
It was defined as 'fiter_variable', so the base Type.filter_variable ran
instead of the intended guard that rejects assigning to a DisconnectedType.
The second isinstance check used 'if' instead of 'elif', so an OpPattern
(already handled) also fell into the tracked_instances branch.
print(..., file=destination_file) passed the destination string instead
of the open file handle f.
is_same_graph ran two graph-comparison implementations (a deepcopy +
MergeOptimizer path and equal_computations) and asserted they agree, with
a docstring noting one should eventually be dropped. It was test-only;
replace its call sites with equal_computations and delete the function,
its merge-based twin, and the dedicated TestIsSameGraph tests.
full_tree was documented 'Used for debugging only' and read solely by a
commented-out debug block; drop the parameter and the dead block.
local_Unique_Alloc_lift/Repeat_lift/second were structurally identical
(same flag bail-out + make_node/as_tensor tail), differing only in the
producer op checked and which input to unwrap. Merge into local_Unique_lift
and update the test rewrite-name references.
@ricardoV94 ricardoV94 marked this pull request as ready for review June 26, 2026 05:44
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.

1 participant