diff --git a/src/sparse_runtime_lab/profiling/schema.py b/src/sparse_runtime_lab/profiling/schema.py index 0b70c1d..542424a 100644 --- a/src/sparse_runtime_lab/profiling/schema.py +++ b/src/sparse_runtime_lab/profiling/schema.py @@ -150,7 +150,7 @@ def _validate_layer(layer: object, index: int, errors: list[str]) -> None: if not isinstance(layer, dict): errors.append(f"layers[{index}] must be an object") return - for field_name in ("layer_index", "module_name", "total_values", "zero_values"): + for field_name in ("layer_index", "module_name", "total_values", "zero_values", "sparsity"): if field_name not in layer: errors.append(f"layers[{index}].{field_name} is required") diff --git a/tests/test_profiling_fixtures.py b/tests/test_profiling_fixtures.py index b58c987..c7402ac 100644 --- a/tests/test_profiling_fixtures.py +++ b/tests/test_profiling_fixtures.py @@ -76,3 +76,10 @@ def test_cli_renders_profile_fixture_to_markdown(tmp_path): def test_fixture_paths_do_not_import_torch_or_transformers(): assert "torch" not in sys.modules assert "transformers" not in sys.modules + + +def test_activation_profile_layer_without_sparsity_is_invalid(): + fixture = _load_fixture("activation_profile_report_layers.json") + fixture["layers"][0].pop("sparsity") + + assert "layers[0].sparsity is required" in validate_profile_report(fixture)