[Fix] Migrate unittest parameterization to PyTorch - #2002
Closed
jayhenry wants to merge 3 commits into
Closed
Conversation
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.
Summary
parametrizedecorator in 28 test filesparametrizeplusinstantiate_parametrized_testsfor unittest-based classespytest.mark.parametrizefor the one plain pytest classRoot cause
The third-party decorator recursively scans decoration-frame globals to count stacked decorators. Transformers lazy modules can materialize attributes while that dictionary is being iterated, which raises
RuntimeError: dictionary changed size during iteration. The upgrade exposed the latent incompatibility by changing the lazy-module surface imported during test collection.PyTorch unittest parameterization records metadata on the test method and materializes cases from the decorated class. It does not recursively inspect imported module dictionaries.
Why parameterization is split
pytest.mark.parametrizecannot be used directly onunittest.TestCasesubclasses. Pytest delegates those methods to the unittest runner, which invokes them without injected arguments. A minimal reproduction underpt29_glm2fails withTypeError: test_value() missing 1 required positional argument.Therefore:
parametrizeplusinstantiate_parametrized_testspytest.mark.parametrizeThis keeps each test on the parameterization mechanism supported by its runner without changing existing test base classes.
Transformers 5.14.1 compatibility
The first Action run proved that 547 tests still passed and isolated 12 remaining regressions. This PR also addresses them:
position_embeddingsandseq_ctxget_vision_bilinear_indices_and_weights, the shared Transformers 5.14 vision interpolation API, while retaining FP32 accumulation and returning the model dtype before LayerNormValidation
Using
pt29_glm2, variables fromzdev/env.sh, andgpu_lock.shfor GPU runs:pytest.mark.parametrizeonunittest.TestCasefails because unittest does not inject parameters212 tests collectedinstantiate_parametrized_tests3 passed2 passed2 passed1 passedgit diff --check: passedThe follow-up Action completed with 558 passed, 18 skipped, and one stale Qwen3.5 chat-template expectation. The four original HF video-reference failures passed. Commit
cde72f58updates both remaining video-template expectations for the Transformers 5.14 outer boundary; the exact failed node now passes locally.