Skip to content

[WIP] [part-3] [dep: #1430] Declarative units validation for the v0.2.1 schema#1433

Draft
Bslabe123 wants to merge 5 commits into
mainfrom
units-validator-refactor
Draft

[WIP] [part-3] [dep: #1430] Declarative units validation for the v0.2.1 schema#1433
Bslabe123 wants to merge 5 commits into
mainfrom
units-validator-refactor

Conversation

@Bslabe123
Copy link
Copy Markdown

@Bslabe123 Bslabe123 commented May 29, 2026

Summary

Replaces the hand-written per-class check_units methods in v0.2.1 with a
declarative table.
A new UnitsValidatedModel base holds a UNIT_RULES map
(field name -> allowed units); one inherited validator merges the rules declared
across the class hierarchy and checks them. Each class now declares only the
fields it introduces instead of writing a validator method.

Pure refactor, no behavior change. Depends on #1430 (introduces the
v0.2.1 classes this touches). Independent of the converter PR (no file overlap),
so it can review and merge in either order once #1430 lands.

@github-actions
Copy link
Copy Markdown
Contributor

Unsigned commits detected! Please sign your commits.

For instructions on how to set up GPG/SSH signing and verify your commits, please see GitHub Documentation.

@Bslabe123 Bslabe123 changed the title [part-3] [dep: #1430] Declarative units validation for the v0.2.1 schema [WIP] [part-3] [dep: #1430] Declarative units validation for the v0.2.1 schema May 29, 2026
@Bslabe123 Bslabe123 force-pushed the units-validator-refactor branch from 1b74a51 to 27abdea Compare May 29, 2026 21:46
Bslabe123 added 5 commits May 29, 2026 17:56
Additive minor revision of the v0.2 benchmark report schema. Introduces
optional per-modality (image/video/audio) payload statistics on the request
aggregates and new unit categories (pixels, ratio, bytes, media throughput).

- base.py: add Units.PIXELS/RATIO/BYTES and images/videos/audios per-second
  rate units; add UNITS_RATIO and UNITS_MEDIA_THROUGHPUT lists.
- schema_v0_2_1.py: MediaPayloadStats hierarchy (image/video/audio), extended
  AggregateRequests (request_size, multimodal) and AggregateThroughput
  (image/video/audio_rate), and BenchmarkReportV021.
- core.py / __init__.py: register and dispatch schema version 0.2.1.
- regenerated br_v0_2_1 example and JSON schema artifacts.

All new fields are Optional, so any v0.2 report remains valid under v0.2.1.

Refs: #989, kubernetes-sigs/inference-perf#450
Signed-off-by: Brendan Slabe <slabe@google.com>
Enforces the hard requirement that every valid v0.2 benchmark report is also
valid under v0.2.1, via three angles: the committed v0.2 example validates
under both models, v0.2 data dumps identically under either version, and every
field v0.2.1 adds is Optional (no v0.2 field becomes required). Runs under the
existing `pytest tests/` PR CI job.

Signed-off-by: Brendan Slabe <slabe@google.com>
- tests/test_benchmark_report_v0_2_1_multimodal.py: a fully populated
  multi-modal report validates and round-trips; each per-modality unit is
  accepted with its correct category; mismatched units are rejected, including
  proof that the inherited v0.2 request_rate guardrail is not loosened.
- README: document v0.2.1 as an additive superset of v0.2, listing the new
  request_size, per-modality multimodal block, and media-rate fields plus the
  new unit categories.

Signed-off-by: Brendan Slabe <slabe@google.com>
Grounding the v0.2.1 schema against inference-perf's emitted lifecycle
report (post #450/#477) shows video temporal extent is modeled as sampled
frames, not wall-clock seconds: the native Video record carries
pixels/bytes/aspect_ratio/frames and no duration. The seconds field on
VideoPayloadStats therefore had no producer, so remove it; audio.seconds
stays since the native Audio record emits it.

Updates the schema, generated JSON schema, example, README, and the
video unit tests accordingly.

Signed-off-by: Brendan Slabe <slabe@google.com>
Adds UnitsValidatedModel to base.py: a model base whose subclasses declare a
UNIT_RULES table (field name -> allowed units) instead of hand-writing a
check_units method. A single inherited validator merges the rules declared
across the MRO, so each class only states the fields it introduces and shared
fields are validated once.

Migrates the six v0.2.1 unit validators (the MediaPayloadStats hierarchy plus
AggregateRequests/AggregateThroughput) to this mechanism. The two aggregate
classes multiply-inherit UnitsValidatedModel alongside their v0.2 base; the
shared validator is named distinctly from v0.2's check_units so both co-run
rather than one shadowing the other. Behavior is unchanged and covered by the
existing compat and multimodal guardrail tests; the only schema-artifact diff
is an expanded AggregateRequests description.

Signed-off-by: Brendan Slabe <slabe@google.com>
@Bslabe123 Bslabe123 force-pushed the units-validator-refactor branch from 27abdea to 9e685f9 Compare May 29, 2026 21:59
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