Skip to main content

Module infer_peer_classes

Module infer_peer_classes 

Source
Expand description

infer_peer_classes - stamp every NodeProto with the class of Node it runs on.

Runs in runner::run_pipeline after expand_ops and before synthesize_wire_recvs. The result feeds partition_by_wire_ops - partitions are now defined by home_class, not by module_instance chains.

§Algorithm

  1. Seed every function input’s home to SELF_CLASS.
  2. Walk nodes in declaration order. For each NodeProto:
    • wire.Send re-homes its data output to the destination class (taken from the peer input’s peer_class tag). The send itself runs on its payload’s home class; the handle output stays with the sender. Self-send case (dest_class == payload_home) is just a value of dest_class.
    • Every other op inherits its home from its data inputs. All data inputs (i.e. inputs that aren’t PEER_ID values) must agree on a home; otherwise CompileError::CrossClassDataflow. Peer-id inputs are ambient - they don’t constrain the consuming op’s home class.
  3. The home is stamped on the NodeProto as HOME_CLASS_KEY metadata for downstream passes.

§Self-send semantics

When a wire.Send’s destination class equals its sender’s home class, both the send and the synthesized recv land in the same partition at the partition pass. The runtime side is N physical instances of one class talking to each other (e.g. gossip peers).

Functions§

infer_peer_classes
Walk graph.node and stamp HOME_CLASS_KEY on each NodeProto. Pure.