Repository navigation
test(nemotron_h): use a real NemotronHConfig in stateful-cache tests - #1845
Merged
jlarson4 merged 1 commit intoOct 1, 2026
Merged
Conversation
DynamicCache(config=...) on newer transformers (5.17) compares config.num_kv_shared_layers against an int, which fails on a bare MagicMock config. Use a tiny real NemotronHConfig instead.
Collaborator
|
Looks good, thanks @YHC66! |
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.
Description
TestNemotronHStatefulCachepasses a bareMagicMock()as the HF model, sohf_model.configis aMagicMocktoo. On transformers 5.17,DynamicCache(config=...)goes throughget_layer_types_and_kwargs, which doesnum_kv_shared_layers > 0, and both tests fail with:CI pins transformers 5.13.0, so this doesn't show there, but
pyproject.tomlallowstransformers>=5.9.0and the tests break as soon as the lock moves up.The adapter itself is fine: with a real
NemotronHConfig,DynamicCache(config=...)builds on both 5.13 and 5.17. This PR only changes the tests to handcreate_stateful_cachea mock model carrying a tiny realNemotronHConfig(built with the typedlayers_block_typeargument, so mypy reports nothing new for the file).Results:
test_nemotron_h_adapter.pybeforetest_nemotron_h_adapter.pyafterOn dev
02a7f5a0with transformers 5.17, these two were the only failures intests/unit -m "not slow"(6792 passed). With the locked environment,tests/unit -m "not slow"passes in full after the change (6898 passed).Type of change
Checklist: