cocoindex-io/cocoindex · error · ValueError

Unsupported quantize type: {quantize!r}

Error message

Unsupported quantize type: {quantize!r}

What it means

Mapper guard in _quantize_type during zvec schema building. Recognized quantize modes are 'none' (no quantization, returns None), 'fp16', 'int8', and 'int4' (case-insensitive); anything else has no zvec QuantizeType counterpart and is rejected here rather than surfacing as an engine-internal failure. Caused by a misspelled or unsupported quantize setting; use none, fp16, int8, or int4.

Source

Thrown at python/cocoindex/connectors/zvec/_target.py:535

        return _zvec.MetricType.COSINE
    if key == "ip":
        return _zvec.MetricType.IP
    if key == "l2":
        return _zvec.MetricType.L2
    raise ValueError(f"Unsupported metric type: {metric!r}")


def _quantize_type(quantize: str) -> Any | None:
    key = quantize.lower()
    if key == "none":
        return None
    if key == "fp16":
        return _zvec.QuantizeType.FP16
    if key == "int8":
        return _zvec.QuantizeType.INT8
    if key == "int4":
        return _zvec.QuantizeType.INT4
    raise ValueError(f"Unsupported quantize type: {quantize!r}")


def _build_zvec_schema(collection_name: str, schema: CollectionSchema[Any]) -> Any:
    fields: list[Any] = []
    vectors: list[Any] = []
    for name, col in schema.columns.items():
        if name == schema.primary_key:
            continue  # primary key maps to the document id, not a field
        if col.kind == "scalar":
            index_param = _zvec.InvertIndexParam() if col.indexed else None
            fields.append(
                _zvec.FieldSchema(
                    name=name,
                    data_type=col.data_type,
                    nullable=col.nullable,
                    index_param=index_param,
                )
            )

View on GitHub (pinned to e84aa99b32)

Solutions

  1. Use one of: 'none', 'fp16', 'int8', 'int4'.
  2. Remove the quantize setting entirely to use the default (no quantization).
  3. Normalize/validate the quantize string before declaring the collection.

Example fix

// before
Column(kind="dense", dim=768, quantize="product")
// after
Column(kind="dense", dim=768, quantize="int8")
Defensive patterns

Strategy: validation

Validate before calling

ALLOWED = {"none", "fp16", "int8", "int4"}
assert quantize.lower() in ALLOWED, f"quantize must be one of {ALLOWED}"

Try / catch

try:
    target = collection_target(...)
except ValueError as e:
    if "quantize" in str(e): ...

Prevention

When it happens

Trigger: Setting quantize on a vector column to an unsupported value, e.g. 'scalar', 'product', 'pq', or mis-cased like 'FP16' beyond the recognized keys.

Common situations: Copying quantization settings from FAISS/GPU index configs; typo like 'int8 ' with whitespace; expecting binary quantization which zvec does not expose here.

Related errors


AI-assisted analysis of cocoindex-io/cocoindex@e84aa99b32 (2026-09-08). Data as JSON: /api/errors/3ca4dcfc1435e175. Report an issue: GitHub.