Skip to content

Remove dead beam-search dummies from dummy_pt_objects.py#45722

Merged
Rocketknight1 merged 1 commit into
huggingface:mainfrom
jw9603:fix-dead-pt-dummies
Apr 30, 2026
Merged

Remove dead beam-search dummies from dummy_pt_objects.py#45722
Rocketknight1 merged 1 commit into
huggingface:mainfrom
jw9603:fix-dead-pt-dummies

Conversation

@jw9603
Copy link
Copy Markdown
Contributor

@jw9603 jw9603 commented Apr 30, 2026

Fixes #45712

What does this PR do?

Removes six dead dummy classes from dummy_pt_objects.py:
BeamScorer, ConstrainedBeamSearchScorer, Constraint, ConstraintListState, DisjunctiveConstraint, PhrasalConstraint.

The real implementations were removed in v5 (#41223) but the dummies stayed. None of the six is referenced anywhere under src/, tests/, docs/, or in MIGRATION_GUIDE_V5.md. Without torch they leak into dir(transformers) and utils/check_repo.py fails the public-init-vs-docs invariant.

After removal, from transformers import BeamScorer raises ImportError in a no-torch env (matching the with-torch behavior) instead of returning the dummy and producing a misleading requires backend torch error on use.

DEPRECATED_OBJECTS in check_repo.py would be the alternative, but that list is for objects that still exist as aliases or shims (e.g. PretrainedConfigPreTrainedConfig). These six don't.

Tests run (no-torch venv):

$ python utils/check_repo.py
# was: "Exception: ... in the public init, but not in the docs"
# now: docs step passes (later steps fail only on torch import, unrelated to this change)

$ python utils/check_dummies.py     # exit 0
$ python utils/check_inits.py       # exit 0
$ python utils/checkers.py copies,modular_conversion   # all pass

Code Agent Policy

  • I confirm that this is not a pure code agent PR.

AI assistance (Claude) was used during investigation and patch preparation. All changes were reviewed and tested by me.

Before submitting

Copy link
Copy Markdown
Member

@Rocketknight1 Rocketknight1 left a comment

Choose a reason for hiding this comment

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

Yep, looks clean to me. Thank you!

@Rocketknight1 Rocketknight1 enabled auto-merge April 30, 2026 13:46
@Rocketknight1 Rocketknight1 added this pull request to the merge queue Apr 30, 2026
@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Merged via the queue into huggingface:main with commit aa830d3 Apr 30, 2026
17 checks passed
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.

Six leftover dummy classes in dummy_pt_objects.py fail check_repo.py and leak into dir(transformers) without torch

3 participants