Home > EulerNPU > Tutorials > 02. Spec Validation

02. Spec Validation

Every eulernpu workflow starts with a YAML spec. Before compile, runtime, or silicon deployment, that spec is checked for both formal and semantic validity. This validation step is the early-fail gate for every downstream stage.

Two-Stage Validation

StageWhatTool
1. schemaYAML structure, key names, typesJSON Schema (Draft 7)
2. semanticMeaning consistency, component-op relations, board limits20 rules S01–S23 (S03–S05 reserved)

Schema asks "is this YAML well-formed?". Semantic asks "is this combination physically and logically possible?".

Running

eulernpu validate path/to/spec.yaml

Success:

Validation OK: 14 operators · 5 components · backend=cpu_ref

Failure is always in the 3-line format:

SemanticError: gru_cell present but no recurrent_unit component declared
Fix: Add `components: [recurrent_unit: {...}]` to spec
See: docs/specs/spec_schema.md#S01

Semantic Rules (20)

Representative ones:

RuleWhat it prevents
S01gru/lstm without a recurrent_unit component
S02vector_alu referencing a disabled op
S07accumulator_bits < activation_bits (overflow risk)
S08backend/board mismatch (zynq_ps + non-Xilinx board)
S10weight + activation totals exceed board SRAM
S11systolic_size that is not a power of 2
S17flash_attention without a sparse_attn_unit
S18ddim_step without a diffusion_unit
S20token_acceptance not in decode mode
S22board capability matrix violation (op not in board profile)
S23quantize/dequantize adjacency mismatch

Full list + error messages at docs/specs/spec_schema.md.

Fixture Policy

Valid fixtures (tests/fixtures/valid_yamls/) — specs that must pass. New valid fixtures require updating docs/fixtures/fixtures_index.md.

Invalid fixtures (tests/fixtures/invalid_yamls/) — specs that must be blocked. They are regression assets.

Rules:

i18n

eulernpu --lang en validate path/to/spec.yaml
eulernpu --lang ko validate path/to/spec.yaml

The error body is translated. These are not translated:

Default language is ko. Missing translations fall back to Korean.

Tiny Example — Minimal Valid

spec_version: "0.1"
target_backend: cpu_ref
operators:
  - linear
  - relu
components:
  - vector_alu: {ops: [linear, relu]}
quantization:
  mode: fp32
$ eulernpu validate minimal.yaml
Validation OK: 2 operators · 1 component · backend=cpu_ref

Tiny Example — Invalid (S10 violation)

spec_version: "0.1"
target_backend: zynq_ps
target_board: xc7z020
components:
  - sram: {size_kb: 1024}    # XC7Z020 caps at 256KB
$ eulernpu validate huge_sram.yaml
SemanticError: sram size 1024 KB exceeds board xc7z020 (max 256 KB)
Fix: Reduce sram.size_kb to ≤ 256, or pick a larger board (xczu7ev etc)
See: docs/specs/spec_schema.md#S10

Next

Once the spec passes → 03. compile_run.