react-native-executorch-spec / config.schema.json
aceOfDiamonds's picture
Stop storing quantized and default on a variant
402e59e
Raw
History Blame Contribute Delete
6.34 kB
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://huggingface.co/software-mansion/react-native-executorch-spec/resolve/main/config.schema.json",
"title": "react-native-executorch model config",
"description": "Per-backend config.json published alongside .pte files in software-mansion/react-native-executorch-* repositories.",
"type": "object",
"required": [
"$schema",
"model",
"family",
"capabilities",
"backend",
"license",
"variants"
],
"additionalProperties": false,
"properties": {
"$schema": {
"type": "string",
"format": "uri"
},
"model": {
"type": "string",
"pattern": "^[a-z0-9_]+$",
"description": "Model token used in file names; lowercase, underscore-separated."
},
"family": {
"type": "string",
"pattern": "^[a-z0-9_]+$",
"description": "Loose grouping (llama, qwen, whisper, yolo, style_transfer, ...)."
},
"size": {
"type": "string",
"pattern": "^[a-z0-9_]+$",
"description": "Optional size token. Omit when the model has no size variants."
},
"capabilities": {
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": {
"enum": [
"text-generation",
"vision",
"speech-to-text",
"text-to-speech",
"classification",
"object-detection",
"semantic-segmentation",
"instance-segmentation",
"style-transfer",
"text-embedding",
"image-embedding",
"image-generation",
"voice-activity-detection",
"text-detection",
"text-recognition"
]
}
},
"backend": {
"enum": ["xnnpack", "coreml", "vulkan", "qnn", "mlx"]
},
"license": {
"type": "string",
"minLength": 1
},
"tokenizer": {
"type": "string",
"description": "Relative path to tokenizer.json, when applicable."
},
"tokenizer_config": {
"type": "string",
"description": "Relative path to tokenizer_config.json, when applicable."
},
"variants": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#/$defs/variant" }
}
},
"$defs": {
"variant": {
"type": "object",
"required": ["precision"],
"additionalProperties": false,
"properties": {
"file": {
"type": ["string", "null"],
"description": "Single-file variants set this. Multi-component variants set this to null and populate `components`."
},
"components": {
"type": "object",
"minProperties": 1,
"additionalProperties": { "type": "string" },
"description": "For multi-component models (e.g. encoder/decoder, scheduler/text_encoder/unet/vae)."
},
"precision": {
"type": "string",
"pattern": "^[a-z0-9_]+$",
"description": "Precision token. precisions.json is the authoritative quantized/non-quantized partition; a variant is quantized iff its token is listed there under `quantized`."
},
"size_bytes": {
"type": "integer",
"minimum": 0
},
"methods": {
"type": "object",
"minProperties": 1,
"additionalProperties": {
"oneOf": [
{ "$ref": "#/$defs/methodSignature" },
{ "$ref": "#/$defs/componentMethods" }
]
},
"description": "Single-file variants key this by method name. Multi-component variants key it by component name, matching `components`, and nest that component's methods inside."
}
},
"oneOf": [
{
"required": ["file"],
"properties": { "file": { "type": "string", "minLength": 1 } }
},
{ "required": ["components"] }
]
},
"methodSignature": {
"type": "object",
"required": ["inputs", "outputs"],
"additionalProperties": false,
"properties": {
"inputs": {
"type": "array",
"items": { "$ref": "#/$defs/tensorSpec" }
},
"outputs": {
"type": "array",
"items": { "$ref": "#/$defs/tensorSpec" }
}
}
},
"componentMethods": {
"type": "object",
"minProperties": 1,
"additionalProperties": { "$ref": "#/$defs/methodSignature" },
"description": "One component's methods, keyed by method name. Used under `methods` when a variant sets `components`, so that components sharing a method name (several `forward`s in one pipeline) stay distinct."
},
"precisions": {
"type": "object",
"required": ["quantized", "non_quantized"],
"additionalProperties": false,
"properties": {
"$schema": { "type": "string" },
"description": { "type": "string" },
"quantized": {
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": { "type": "string", "pattern": "^[a-z0-9_]+$" }
},
"non_quantized": {
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": { "type": "string", "pattern": "^[a-z0-9_]+$" }
}
},
"description": "Shape of precisions.json, which every precision token must appear in exactly once."
},
"tensorSpec": {
"type": "object",
"required": ["shape", "dtype"],
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"minLength": 1,
"description": "Optional. Executorch .pte files do not carry user-meaningful tensor names; introspected configs use positional `input_N`/`output_N` keys via the array order instead and omit `name`. Set this when a hand-curated semantic name is available."
},
"shape": {
"type": "array",
"items": { "type": "integer" },
"description": "Use -1 for dynamic dimensions."
},
"dtype": {
"enum": [
"bool",
"int8",
"int16",
"int32",
"int64",
"uint8",
"float16",
"float32",
"float64",
"bfloat16"
]
}
}
}
}
}