Skip to content

[Fix] Pass config keys through to dataset classes that forward **kwargs - #1684

Closed
reinainblood wants to merge 1 commit into
open-compass:mainfrom
reinainblood:fix/dataset-config-kwargs-mro
Closed

reinainblood wants to merge 1 commit into
open-compass:mainfrom
reinainblood:fix/dataset-config-kwargs-mro

Conversation

@reinainblood

@reinainblood reinainblood commented Sep 12, 2026 •

Copy link
Copy Markdown

Fixes #1185

Problem

build_dataset_from_config in run.py keeps only the config keys that appear in inspect.signature(cls.__init__). MMMUProDataset.__init__ is (self, **kwargs) and forwards to MMMUDataset, so its signature names no parameters and every key in the config is dropped. The config from the issue builds the default MMBench-named dataset instead of MMMU_Pro_10c, and with --strict (the strict=True path added in #1573) it raises Unsupported parameter(s) for dataset class MMMUProDataset: dataset.

Scanning vlmeval/dataset, seven classes have a **kwargs-only __init__ (MMMUProDataset, VLADBench, VLRMBench, Spatial457, ERQADataset, SiteBenchBase, RefCOCODataset) and about thirty more name one or two parameters and forward the rest, so keys like skip_noimg, nframe and fps are silently lost for those too. For a video class that forwards fps/nframe this turns into the "fps and nframe should be set at least one valid value" error even when the config sets one.

Change

run.py: a small helper _accepted_init_params(cls) walks cls.__mro__, collecting the named parameters of each __init__ and stopping at the first one that does not take **kwargs. build_dataset_from_config filters (and, in strict mode, validates) against that set instead of the leaf signature. Classes whose __init__ names all their parameters get exactly the same set as before.

tests/test_dataset_config.py: unit tests for the helper on three constructor shapes, and for build_dataset_from_config with a **kwargs-forwarding class in both lenient and strict mode.

Verification

Probe with the issue's config (constructor replaced by one that records its kwargs, so nothing downloads):

main:      kwargs passed to MMMUProDataset: {}
           strict=True raised: ValueError Unsupported parameter(s) for dataset class MMMUProDataset: dataset
this PR:   kwargs passed to MMMUProDataset: {'dataset': 'MMMU_Pro_10c'}
           strict=True kwargs: {'dataset': 'MMMU_Pro_10c'}

python -m unittest tests.test_dataset_config: 5 pass on this branch, 1 failure and 4 errors on main. pre-commit run --files run.py tests/test_dataset_config.py is clean. I do not have a GPU here, so I did not run an end-to-end run.py --config evaluation.

Disclosure

Drafted by Claude from the Hive Fidelity Usage-Surplus OSS Program. All code reviewed by a human prior to submission. To request us back for more, email [email protected] or [email protected]. Usage-Surplus OSS Program

build_dataset_from_config filtered the config keys against
inspect.signature(cls.__init__). A dataset class whose __init__ is
`(self, **kwargs)` and forwards to its parent therefore exposed no named
parameters, so every key was dropped: `{"class": "MMMUProDataset",
"dataset": "MMMU_Pro_10c"}` built the default dataset instead, and with
`strict=True` it raised "Unsupported parameter(s) ... dataset". Seven
dataset classes have a **kwargs-only __init__ and about thirty more forward
**kwargs after their own parameters, losing keys such as skip_noimg, nframe
and fps.

Collect the accepted parameters by walking the __init__ chain through the
MRO until an __init__ that does not take **kwargs, and filter against that
set. Classes whose __init__ names every parameter behave exactly as before.

Fixes open-compass#1185

Co-Authored-By: Claude <[email protected]>
@ssiq

ssiq commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. This problem has been resolved in #1622

@ssiq ssiq closed this Sep 22, 2026
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.

[BUG] dataset parameter not passed when using config.json with MMMUProDataset

2 participants