lutzroeder/netron · error · Error

Expected 'scale'.

Error message

Expected 'scale'.

What it means

Generated protobuf requirement check: a binary-decoded caffe2.QTensorProto lacks the required 'scale' field. decode() checks precision, scale, bias and is_signed in order and throws as soon as one is absent, here at the second check.

Source

Thrown at source/caffe2-proto.js:271

                case 10:
                    message.biases = reader.doubles(message.biases, tag);
                    break;
                case 11:
                    message.axis = reader.int32();
                    break;
                case 12:
                    message.is_multiparam = reader.bool();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        if (!Object.prototype.hasOwnProperty.call(message, 'precision')) {
            throw new Error("Expected 'precision'.");
        }
        if (!Object.prototype.hasOwnProperty.call(message, 'scale')) {
            throw new Error("Expected 'scale'.");
        }
        if (!Object.prototype.hasOwnProperty.call(message, 'bias')) {
            throw new Error("Expected 'bias'.");
        }
        if (!Object.prototype.hasOwnProperty.call(message, 'is_signed')) {
            throw new Error("Expected 'is_signed'.");
        }
        return message;
    }

    static decodeText(reader) {
        const message = new caffe2.QTensorProto();
        reader.start();
        while (!reader.end()) {
            const tag = reader.tag();
            switch (tag) {
                case "dims":
                    reader.array(message.dims, () => reader.int64());

View on GitHub (pinned to d8a543f5f8)

Solutions

  1. Verify the quantized model was produced by a compatible caffe2 version and re-export
  2. Check the file size/checksum against the source
  3. Decode with protoc --decode_raw to confirm the scale field exists in the bytes
  4. Ensure the reader is positioned on a genuine QTensorProto payload
Defensive patterns

Strategy: validation

Validate before calling

const REQUIRED = ['precision','scale','bias','is_signed'];
const missing = REQUIRED.filter((k) => !(k in qt));
if (missing.length) throw new Error(`QTensorProto missing: ${missing.join(', ')}`);

Type guard

function isQTensor(m) {
  return m != null && ['precision','scale','bias','is_signed']
    .every((k) => Object.prototype.hasOwnProperty.call(m, k));
}

Try / catch

try {
  caffe2.QTensorProto.decode(reader);
} catch (e) {
  if (/^Expected '(precision|scale|bias|is_signed)'\.$/.test(e.message)) {
    // corrupt/incomplete quantized data — abort load with clear message
  } else throw e;
}

Prevention

When it happens

Trigger: Decoding QTensorProto bytes where precision was present but scale (field for quantization scale) was not — truncated wire data or mismatched schema/producer version.

Common situations: Quantized caffe2 model files from incompatible toolchains; partial file transfers; misparsed stream alignment.

Related errors


AI-assisted analysis of lutzroeder/netron@d8a543f5f8 (2026-08-27). Data as JSON: /api/errors/b30c30387a9889cf. Report an issue: GitHub.