nncf: [Good First Issue][NNCF]: fix invalid error reporting in JSON schema
Context
Configuration for NNCF algorithms can be defined in JSON format. For instance, [config.json].(https://github.com/openvinotoolkit/nncf/blob/develop/examples/torch/classification/configs/sparsity_quantization/inception_v3_imagenet_rb_sparsity_int8.json#L17-L38)
Compression section in these configuration files are validated using jsonschema.validate
But there’s some bug with reporting error in JSON schema when a field is not defined in schema.
Steps to reproduce:
-
checkout https://github.com/ljaljushkin/nncf_pytorch/tree/nl/bug_in_schema_report
-
There’s unit test checking 2 config files:
To run tests:
test $pytest tests/torch/test_config_schema.py -sv -k 'bug_in_error_report'
The expected behavior, that the first test should pass, the second — fail. But the reported error in the second test should be the following:
error = <ValidationError: "Additional properties are not allowed ('unknown_field' was unexpected)">
However, the second test reports this, which is not correct:
jsonschema.exceptions.ValidationError: 'polynomial' is not one of ['exponential', 'exponential_with_bias', 'baseline']
The message is misleading, because it’s saying that the supported schedule type polynomial for rb_sparsity doesn’t correspond to the list of supported schedule types for the filter pruning algorithm.
https://openvinotoolkit.github.io/nncf/schema/index.html#compression_oneOf_i0_oneOf_i1_params_schedule https://openvinotoolkit.github.io/nncf/schema/index.html#tab-pane_compression_oneOf_i0_oneOf_i9
filter pruning’s definition: https://github.com/openvinotoolkit/nncf/blob/develop/nncf/config/schemata/algo/filter_pruning.py#L88 rb sparsity’s definition: https://github.com/openvinotoolkit/nncf/blob/develop/nncf/config/schemata/common/sparsity.py#L52C14-L52C30
What needs to be done?
Fix the error reporting for the given test case
Example Pull Requests
The issue is not reproduced before these changes: Refactor schemata and prepare for rendering. (#1268)
Resources
Here’s the automatically generated page with parameters from json schema. https://openvinotoolkit.github.io/nncf/schema/index.html#compression
Contact points
Ticket
94933
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 23 (8 by maintainers)
Commits related to this issue
- #2570 :Update config.py — committed to LalitSP/nncf by LalitSP 3 years ago
.take