Skip to content

Build a ComposableConfig from more than one entry in from_dict - #2617

Open
PerryLink wants to merge 1 commit into
intel:mainfrom
PerryLink:fix/composable-config-from-dict
Open

PerryLink wants to merge 1 commit into
intel:mainfrom
PerryLink:fix/composable-config-from-dict

Conversation

@PerryLink

Copy link
Copy Markdown

What

ComposableConfig.from_dict() silently keeps only the first entry when the dict describes more than
one config:

ComposableConfig.from_dict({
    "fake_a": {"weight_bits": 2},
    "fake_b": {"weight_bits": 6},
})
# -> FakeAConfig(weight_bits=2)          (the second key is gone)
# expected -> ComposableConfig([FakeAConfig(2), FakeBConfig(6)])

The return value is not even a ComposableConfig, so anything that then treats it as one
(config.compose(...), iteration) fails or ignores the other entries. The single-entry case works, which
is why this stayed hidden.

The change

Iterate all entries, build one sub-config per key, and return a ComposableConfig that holds them —
+3/−4 lines in neural_compressor/common/base_config.py. Single-entry behaviour is unchanged.

Verification

  • new unit test test_composable_config_from_dict: fails on pristine main with
    FakeAlgoConfig ... is not an instance of ComposableConfig, passes after;
  • a direct repro prints FakeAConfig(weight_bits=2) before and
    ComposableConfig([FakeAConfig(2), FakeBConfig(6)]) after;
  • test/common suite: 32 tests OK under both unittest and pytest;
  • git apply --check on a pristine main; both files are 100644.

No framework-level end-to-end test is included: the bug is in the framework-agnostic common layer, and
torch/TF are not available offline here.

No CLA in the repository; commits are signed off, as the repo's DCO check requires.

Signed-off-by: PerryLink <255665900+PerryLink@users.noreply.github.com>

This branch has not been deployed

No deployments
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