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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
"""Helpers for WorkerMetadata source_payload migration."""
return
=
return
return
return
return
# Accelerator-compatibility policy (fail-closed by construction):
# - Same accelerator family: always allowed.
# - Different family: allowed only for a hetero-eligible source type, an
# allowlisted family pair, and explicitly unquantized weights.
# - Unknown (empty) accelerator: deferred on the pre-fetch check, rejected on
# the authoritative post-fetch check for a quantized identity.
# Anything undeclared or unrecognized is treated as the unsafe case.
# Accelerator families whose weight bytes are transferable cross-vendor over
# NIXL. Weights are plain tensor bytes whose dtype and size are validated on the
# receive path before any transfer, so they carry across families. Generated
# artifacts (CUDA graphs, torch.compile, Triton, DeepGEMM, TileLang, CuTe,
# FlashInfer caches) are accelerator/arch-specific and must never cross.
=
# Source types eligible for heterogeneous transfer. WEIGHTS only: LoRA has no
# live tensor publish/transfer path yet, so it stays strict same-family until
# one exists and is tested. Add MX_SOURCE_TYPE_LORA here once that lands.
=
# Sentinel for the quantization/dtype arguments so an omitted value fails
# closed: a caller that does not explicitly declare the identity's quantization
# is treated as quantized and never gets cross-family compatibility.
=
# Normalized dtype strings that are known-plain (non-quantized) weight storage.
# This is an allowlist, not a denylist: only these dtypes enable a cross-family
# transfer, so an unknown or future quantized dtype fails closed instead of
# silently admitting a hardware-specific layout. Values are compared after
# stripping a leading ``torch.`` and lowercasing (see ``_normalize_dtype``).
=
# Quantization strings that mean "not quantized" (raw bf16/fp16 weights).
=
"""Lowercase and drop a leading ``torch.`` so ``str(tensor.dtype)`` and the
already-stripped identity form both normalize to the same token."""
return
"""Return whether an identity describes plain (non-quantized) weights.
Both signals must affirmatively say "plain": ``SourceIdentity.quantization``
must be an unquantized value and ``dtype`` must be an allowlisted plain
dtype. This is "explicitly unquantized only" and fail-closed by
construction: an argument left ``_UNSPECIFIED``, an empty ``dtype``, or any
dtype not on the allowlist (int8/int4/qint8/auto and unknown future
quantized dtypes) is treated as quantized, so a call site that does not
fully declare a plain identity cannot silently enable a cross-family
transfer.
"""
return False
return False
return in
"""Return whether ``target`` may pull from ``source`` given the source type.
Empty accelerator values mean unknown and are accepted for backward
compatibility with workers published before accelerator metadata existed.
Exact family matches are always compatible regardless of quantization.
Cross-family transfer is allowed only for source types in
``HETEROGENEOUS_NIXL_SOURCE_TYPES``, family pairs in
``HETEROGENEOUS_NIXL_WEIGHT_PAIRS``, and only for unquantized weights:
quantized weight layouts (fp8 scale packing, fp4/nvfp4 swizzle, hidden
quant-config tensors) are hardware/kernel specific and are not proven
transferable cross-vendor, so they are rejected pending inference-correctness
validation. This is the single compatibility rule shared by RDMA tensor
source selection and artifact source discovery, in both their pre-fetch and
post-fetch checks.
Args:
target: Runtime accelerator family of the pulling (target) worker,
e.g. ``"cuda"`` or ``"xpu"``. Empty means unknown.
source: Runtime accelerator family of the source worker being
considered. Empty means unknown.
mx_source_type: The ``MxSourceType`` of the source. Defaults to ``None``
so the gate fails closed: a caller that does not pass a
hetero-eligible source type only ever gets strict same-family
compatibility. Cross-family transfer requires a type in
``HETEROGENEOUS_NIXL_SOURCE_TYPES``.
quantization: The identity's ``SourceIdentity.quantization`` string.
Defaults to a sentinel that fails closed (treated as quantized) so a
caller that does not declare it cannot silently enable a cross-family
quantized transfer. Empty/``none`` is the unquantized signal.
dtype: The identity's ``SourceIdentity.dtype`` string. Defaults to a
sentinel that fails closed. Serves as a defensive net for backends
that express quantized storage through dtype alone (see
``_is_unquantized``).
defer_unknown: How an unknown (empty) accelerator is treated for
quantized weights. ``True`` (the pre-fetch default) defers an unknown
accelerator to the post-fetch check instead of rejecting it: the
lightweight ``SourceInstanceRef`` may legitimately omit the
accelerator (the ``k8s-service`` backend publishes a synthetic ref
and only learns the real accelerator from ``GetTensorManifest``), and
rejecting there would strand a valid same-family quantized source
before the accelerator is known. ``False`` (the authoritative
post-fetch check, where the real ``WorkerMetadata.accelerator`` is in
hand) fails closed on a still-empty accelerator for a quantized
identity, since an unknown family could be a different vendor whose
kernels expect a different quantized layout.
Returns:
``True`` if ``target`` may pull weights from ``source``, else ``False``.
"""
= and and ==
# Quantized weight layouts are hardware/kernel specific and only ride P2P
# on a verified same-family match. On the authoritative post-fetch path
# (not defer_unknown), this is checked before the empty-means-unknown
# affordance below: an empty (unknown) accelerator may belong to a
# different vendor whose kernels expect a different layout, so trusting it
# would silently corrupt a quantized transfer. On the pre-fetch path an
# unknown accelerator is deferred to that post-fetch check instead of being
# rejected here (see defer_unknown).
return False
return True
return True
return False
return
return False