Skip to content

test: add regression test for no_split_module_classes accepting set type#4048

Open
UFO0506 wants to merge 1 commit into
huggingface:mainfrom
UFO0506:test/no-split-module-classes-set-type
Open

test: add regression test for no_split_module_classes accepting set type#4048
UFO0506 wants to merge 1 commit into
huggingface:mainfrom
UFO0506:test/no-split-module-classes-set-type

Conversation

@UFO0506
Copy link
Copy Markdown

@UFO0506 UFO0506 commented May 25, 2026

What this PR does

Adds a regression test for get_balanced_memory and infer_auto_device_map
when no_split_module_classes is passed as a set instead of a list or tuple.

Background

In accelerate <= 1.5.0, passing a set caused:
TypeError: unhashable type: 'set'
File "accelerate/utils/modeling.py", in get_balanced_memory
if set(no_split_children.keys()) == set(no_split_module_classes):

This was silently fixed as part of #2345, but no regression test was added.
This PR adds explicit coverage so the fix cannot regress undetected.

Testing

pytest tests/test_modeling_utils.py::ModelingUtilsTester::test_get_balanced_memory_no_split_module_classes_set -v
# 1 passed

get_balanced_memory and infer_auto_device_map should accept a set for
no_split_module_classes without raising 'TypeError: unhashable type: set'.
Bug was present in <=1.5.0, fixed in huggingface#2345, this test prevents regression.
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