lutzroeder/netron · error · Error

Expected 'quant_algo_name'.

Error message

Expected 'quant_algo_name'.

What it means

Thrown by the generated protobuf decoder for mind_ir.TensorProto.QuantParamProto when a decoded message is missing the required field 'quant_algo_name'. In .proto declarations, fields without a label are required in proto2 semantics, so the decoder verifies presence after consuming all input bytes. It indicates the serialized tensor's quant_param message never set quant_algo_name.

Source

Thrown at source/mindir-proto.js:1111

    static decode(reader, length) {
        const message = new mind_ir.TensorProto.QuantParamProto();
        const end = length === undefined ? reader.length : reader.position + length;
        while (reader.position < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.quant_algo_name = reader.string();
                    break;
                case 2:
                    message.attribute.push(mind_ir.AttributeProto.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        if (!Object.prototype.hasOwnProperty.call(message, 'quant_algo_name')) {
            throw new Error("Expected 'quant_algo_name'.");
        }
        return message;
    }

    static decodeText(reader) {
        const message = new mind_ir.TensorProto.QuantParamProto();
        reader.start();
        while (!reader.end()) {
            const tag = reader.tag();
            switch (tag) {
                case "quant_algo_name":
                    message.quant_algo_name = reader.string();
                    break;
                case "attribute":
                    message.attribute.push(mind_ir.AttributeProto.decodeText(reader));
                    break;
                default:
                    reader.field(tag, message);

View on GitHub (pinned to d8a543f5f8)

Solutions

  1. Verify the model file was produced by a MindSpore version compatible with the mindir-proto schema bundled in this library.
  2. Re-export the MindIR model ensuring quantization params include quant_algo_name.
  3. If you control the schema build, regenerate the proto with quant_algo_name as optional, or patch the generated decoder to remove the required-field check.
  4. Inspect the raw bytes of the tensor's quant_param submessage to confirm the field is absent vs. corrupted.

Example fix

// before
const quant = mindir.TensorProto.QuantParamProto.decode(reader);

// after — tolerate models missing the required field
const proto = require('./mindir-proto.js');
const origDecode = proto.mind_ir.TensorProto.QuantParamProto.decode;
proto.mind_ir.TensorProto.QuantParamProto.decode = function (reader, length) {
    const save = reader.pos;
    try {
        return origDecode.call(this, reader, length);
    } catch (e) {
        if (e.message === "Expected 'quant_algo_name'.") {
            reader.pos = save;
            return origDecode.call(this, reader, length); // decode again via patched schema without required check
        }
        throw e;
    }
};
Defensive patterns

Strategy: try-catch

Try / catch

try {
    const quant = mindir.TensorProto.QuantParamProto.decode(reader);
} catch (e) {
    if (e.message === "Expected 'quant_algo_name'.") {
        // treat as missing quantization info; substitute defaults
        return { quant_algo_name: 'DEFAULT' };
    }
    throw e;
}

Prevention

When it happens

Trigger: Calling mindir.TensorProto.QuantParamProto.decode (or decoding a parent TensorProto containing a quant_param) on a buffer where the quant_param submessage has no field with tag corresponding to quant_algo_name (field 1).

Common situations: Loading a MindIR model produced by an older/newer MindSpore version where quant_param became optional, hand-crafted or truncated serialized protos, or exporting a quantized model whose quantization parameters were never populated.

Related errors


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