1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
"""Datacenter topology signal for topology-aware source selection.
A worker reports its RDMA-fabric location as a ``{domain: value}`` map (e.g.
``{"block": "b1", "rack": "r3", "host": "node7"}``), published once at
registration and surfaced on ``SourceInstanceRef.topology``. The
``topology_aware`` selector ranks candidates by the narrowest domain the target
and source share (see ``source_selection.TopologyAwareSelector``).
The representation matches **Grove's** ``ClusterTopology`` CRD
(``clustertopologies.grove.io``), which is the source-of-truth topology hierarchy
Dynamo/Grove expose to workloads. Its ``spec.levels`` is an ordered list (broad
-> narrow) of ``{domain, key}`` entries, where ``domain`` is a platform-agnostic
level from the fixed set below and ``key`` is the node-label key carrying that
domain's value for a node. MX therefore keys its map on the Grove ``domain`` (so
the metadata lines up across the fleet) and takes the value from the node's label
for that domain's ``key``. Both come through the environment, so MX stays
runtime-agnostic and needs no Kubernetes API access from the worker:
- ``MX_P2P_TOPOLOGY_LEVELS``: comma-separated Grove domains, broad -> narrow,
matching the cluster's ``ClusterTopology`` ``spec.levels`` order, e.g.
``"region,zone,datacenter,block,rack,host"``.
- ``MX_P2P_TOPOLOGY``: a JSON object of ``{domain: value}`` for THIS node, e.g.
``'{"block":"b1","rack":"r3","host":"node7"}'``. The deploying operator
populates it from the node's labels using the ``ClusterTopology`` domain->key
mapping. Missing or unparseable yields ``{}``, so topology-aware selection
degrades to rendezvous ordering rather than failing.
NVLink is not a level here: MX P2P moves weights between *different* replicas
(different nodes, RDMA transport), so the relevant domains are the inter-node
ones (``rack``/``block`` and above); ``host``/``numa`` matter only for
co-located pairs, which use the NVLink backend NIXL selects automatically.
"""
=
# Grove ClusterTopology (clustertopologies.grove.io, v1alpha1) domain enum,
# broadest -> narrowest. Levels outside this set still work (a ClusterTopology
# binding may extend it) but are flagged, since a typo would silently misalign
# this node's map with the rest of the fleet.
=
: =
"""Ordered topology levels (broad -> narrow) from ``MX_P2P_TOPOLOGY_LEVELS``.
Unset defaults to Grove's canonical domain order, so ``topology_aware`` works
out-of-the-box on a Dynamo-managed cluster (where the per-node values arrive
via the injected topology, see ``local_topology``). Ordering still collapses
to rendezvous whenever a node has no topology values.
"""
=
return
=
return
# Dynamo's operator projects each scheduled worker's node topology into a
# directory (one file per Grove domain, contents = this node's value for it) --
# the same source Dynamo's own topology-aware KV transfer reads. Consuming it
# means MX reports exactly the topology Dynamo already resolved for the node, so
# the metadata lines up on real datacenter hardware with no extra wiring.
=
=
=
: =
=
return
continue
=
continue
=
continue
=
return
"""This node's ``{domain: value}`` topology map.
Resolution order: the explicit ``MX_P2P_TOPOLOGY`` JSON override, else the
Dynamo operator's projected topology directory (``DYN_TOPOLOGY_MOUNT_PATH``,
default ``/etc/dynamo/topology`` -- one file per Grove domain). Best-effort:
unset/unparseable/absent yields ``{}`` (this node then shares no domain with
any source, i.e. rendezvous ordering).
"""
=
return
=
return
return
return