huggingface/candle · error

cannot find output {}

Error message

cannot find output {}

What it means

After evaluating all graph nodes, simple_eval_ looks up each declared graph output in the computed values map. If a requested output name was never produced by any node or initializer, this error is thrown. It typically indicates a mismatch between the model's declared graph.outputs and what the graph actually computes.

Source

Thrown at candle-onnx/src/eval.rs:2574

                                    flat_output.slice_scatter(&update_slice, 0, flat_idx)?;
                            }
                        }
                    }
                }

                // Reshape flat output back to original shape
                output = flat_output.reshape(data_shape.to_vec())?;

                values.insert(node.output[0].clone(), output);
            }
            op_type => bail!("unsupported op_type {op_type} for op {node:?}"),
        }
    }
    graph
        .output
        .iter()
        .map(|output| match values.remove(&output.name) {
            None => bail!("cannot find output {}", output.name),
            Some(value) => Ok((output.name.clone(), value)),
        })
        .collect()
}

fn broadcast_shape(shape_a: &[usize], shape_b: &[usize]) -> Result<Vec<usize>> {
    let (longest, shortest) = if shape_a.len() > shape_b.len() {
        (shape_a, shape_b)
    } else {
        (shape_b, shape_a)
    };
    let diff = longest.len() - shortest.len();
    let mut target_shape = longest[0..diff].to_vec();
    for (dim1, dim2) in longest[diff..].iter().zip(shortest.iter()) {
        if *dim1 == *dim2 || *dim2 == 1 || *dim1 == 1 {
            target_shape.push(usize::max(*dim1, *dim2));
        } else {
            bail!(

View on GitHub (pinned to d5fee525bf)

Solutions

  1. Verify graph.output names match actual node output names (netron / onnx.checker)
  2. Update graph.outputs after any graph trimming/editing
  3. Re-export the model from the source framework

Example fix

# before
# graph.output = ["logits_old"] but nodes produce "logits"
# after
del graph.output[:]
graph.output.append(onnx.ValueInfoProto(name="logits"))
Defensive patterns

Strategy: validation

Validate before calling

let produced: HashSet<_> = graph.node.iter().flat_map(|n| n.output.iter()).collect();
for out in &graph.output {
    if !produced.contains(&out.name) {
        return Err(format!("graph output {} is never produced", out.name));
    }
}

Type guard

fn outputs_are_produced(graph: &Graph) -> bool {
    let produced: HashSet<&str> = graph.node.iter().flat_map(|n| n.output.iter().map(|s| s.as_str())).collect();
    graph.output.iter().all(|o| produced.contains(o.name.as_str()))
}

Try / catch

match eval(...) {
    Err(e) if e.contains("cannot find output") => eprintln!("graph.output references a non-existent tensor"),
    other => other,
}

Prevention

When it happens

Trigger: Loading an ONNX model whose graph.output list references a tensor name not present in node outputs or initializers (renamed outputs, partially trimmed graphs), then calling simple_eval.

Common situations: Graph surgery that removed the node producing an output without updating graph.outputs; exporter bugs; manually editing output names; version changes altering output naming.

Related errors


AI-assisted analysis of huggingface/candle@d5fee525bf (2026-09-02). Data as JSON: /api/errors/51722834149027fc. Report an issue: GitHub.