fix(tests): update run_layer_stage callers to the layer_names kwarg - #3038
Merged
Qubitium merged 1 commit intoAug 31, 2026
Merged
Conversation
run_layer_stage takes a keyword-only `layer_names: Optional[List[str]]` with
no default, but three tests in tests/test_stage_modules.py still pass the old
`layers_prefix="model.layers"`, so each fails with TypeError (unexpected
keyword 'layers_prefix' / missing required keyword-only 'layer_names') before
reaching any assertion. The production caller in module_looper.py already
passes layer_names.
layer_names holds one full layer path per layer: run_layer_stage resolves it
per index via get_layer_name and forwards the result as create_named_modules'
layers_prefix. The fixtures now pass ["model.layers.<i>"] lists sized by
layer_count, and the one dummy create_named_modules that consumes
layers_prefix drops the now-duplicated .{layer_index} segment. The full_name
strings that dummy builds are byte-identical before and after, so the dynamic
exclusion pattern it exercises (r"-:^model\.layers\.0\.") still matches
exactly the same modules.
Qubitium
approved these changes
Aug 31, 2026
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.
Problem
run_layer_stagetakes a keyword-onlylayer_nameswith no default:but three tests in
tests/test_stage_modules.pystill pass the oldlayers_prefix="model.layers", so each dies with aTypeErrorbefore reachingany assertion — it is both an unexpected keyword and a missing required one.
tests/test_stage_modules.py:826test_run_layer_stage_invokes_subset_stagetests/test_stage_modules.py:1044test_run_layer_stage_stops_after_last_quantized_layertests/test_stage_modules.py:1268test_run_layer_stage_reuses_subset_plan_for_replaytests/test_stage_modules.py:2008test_run_layer_stage_replays_untouched_layer_outputs_when_all_modules_skippedgptqmodel/looper/module_looper.py:1533So one test and the production caller were migrated; three tests were missed.
What the new parameter means
layers_prefixwas a single prefix string;layer_namesis one full layerpath per layer.
run_layer_stageresolves it per index and forwards theresult as
create_named_modules'layers_prefix:So the fixtures now pass
["model.layers.<i>"]lists sized bylayer_count,matching the already-migrated test at line 1044.
One dummy
create_named_modulesactually consumeslayers_prefixand builtf"{layers_prefix}.{layer_index}.{name}". Since it now receives the full layerpath, the
.{layer_index}segment is dropped. The strings it produces arebyte-identical before and after, so the dynamic exclusion pattern that test
exercises (
r"-:^model\.layers\.0\.") still matches exactly the same modules:The other two dummies accept
layers_prefixbut never read it, so they areunaffected.
Verification
The signature was parsed out of
stage_layer.pywithast, rebuilt as a stub,and every
run_layer_stagecall site in the repo replayed throughinspect.Signature.bind, with the already-migrated test and the productioncaller as the control group:
Caveat, stated plainly: I could not execute
pytest tests/test_stage_modules.pyto confirm the three tests now pass their assertions. Importing
gptqmodelonthis Windows box crashes with a fatal access violation inside
gptqmodel/utils/threadx.py, and the Linux box available to me has no CUDAbuild of torch. So this PR is verified at the signature level plus the
string-equivalence argument above; please let CI run it before merging.
Notes
tests/test_stage_modules.py, no library code.maintip rather than upstreammain,because my token lacks the
workflowscope and bothmerge-upstreamand adirect push are refused for
.github/workflows/code_quality.yml. The line at1044that upstream has already migrated is deliberately left untouched hereso the merge keeps upstream's version.
🤖 Generated with Claude Code