Cache key — the structural signature of a TraceGraph.
Two traces share an executable iff every field below matches. The
input values are not part of the key; only the per-op output meta
influences the compiled graph (because MPSGraph placeholders are
shape-static in Phase 1.2 and Phase 1.6 will introduce a separate
dynamic key variant).
Attributes
op_ namesstd::vector<std::string>Op-name sequence in dispatch order. Compared element-wise.
op_ inputsstd::vector<std::vector<std::int64_t>>Per-op input wiring: every tensor id renumbered by first appearance across the walk, so the numbers depend only on how the graph is connected and not on the ids a particular trace drew.
a * b fed one tensor twice reads {0, 0}, fed two tensors {0, 1}. Without this both hashed alike and one caller ran the other's executable — one feed bound where two were passed.output_ shapesstd::vector<Shape>Per-op single-output shape. Phase 1.2 supports one output per node; Phase 1.3+ may append entries for multi-output ops.
output_ dtypesstd::vector<Dtype>Per-op single-output dtype.
op_ attrsstd::vector<std::vector<std::pair<std::string, AttributeValue>>>Per-op attribute map, serialised in sorted-key order so the hash is deterministic. Required for emitter-divergent attributes that don't show up in shapes (e.g.
dropout's training / p, softmax's axis). Without this two traces with identical structure but different attributes would collide on the same cache entry and one caller would silently receive the other's executable.feedsstd::vector<FeedSig>Shape + dtype of every external feed (user input or parameter), ordered by the same first-appearance numbering as
op_inputs. The executable's placeholders are typed and shaped by its feeds and run_executable refuses a mismatch, so two traces whose ops agree but whose inputs do not must not share an entry. Without this, isnan(x) + 1 traced on float32 and then on int64 — every op output the same shape and dtype — hit the float executable and raised "feed slot 0 expects dtype float32, got int64".outputsstd::vector<std::int64_t>The tensors the caller asked for, in order and in the same numbering. The graph alone does not say which of its values are returned: two callables tracing
(t + 1, t * 2) and (t * 2, t + 1) build the same ops, and without this the second ran the first's executable and got its outputs in the first's order — as topk(t)[0] got the indices of an earlier topk(t)[1].deviceDeviceDevice on which the executable was compiled (all ops in a trace must agree on one device — Phase 1.2 builder enforces this).