Skip to content

Commit faabff9

Browse files
committed
fix(weight-transfer): record loaders from live kernel tensors
1 parent d53e8fb commit faabff9

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

  • src/prime_rl/inference/vllm/worker

src/prime_rl/inference/vllm/worker/nixl.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,24 @@ def _bake(self, manifest: WeightManifest) -> list[_BakedGroup]:
236236
# Nemotron's e_score_correction_bias) still load those via
237237
# vLLM's default loader, and the bake must attribute that
238238
# copy to its destination like any custom loader copy.
239-
loader = _get_original_loader(tensor)
239+
# The meta restore metadata can predate model-specific
240+
# loader installation. In particular, a restored Qwen
241+
# expert parameter may expose the default loader even
242+
# though its saved live kernel parameter retains the
243+
# FusedMoE loader. The saved live tensor is what vLLM will
244+
# restore after processing, so use it as the source of
245+
# truth for the loader graph as well.
246+
loader_tensor = tensor
247+
info = LAYERWISE_INFO.get(module)
248+
if info is not None and info.kernel_tensors is not None:
249+
kernel_params, kernel_buffers = info.kernel_tensors
250+
loader_tensor = kernel_params.get(name, kernel_buffers.get(name, tensor))
251+
loader = _get_original_loader(loader_tensor)
252+
# Shared tensors may surface through several module
253+
# aliases. Do not compose recorder wrappers when that
254+
# happens; stamp the actual vLLM loader once for the
255+
# current destination.
256+
loader = getattr(loader, "_prime_rl_original_loader", loader)
240257
if loader.__name__ == "composed_loader":
241258
transform = getclosurevars(loader).nonlocals.get("fn")
242259
if not callable(transform):
@@ -538,6 +555,7 @@ def stamped(*args, **kwargs):
538555
finally:
539556
recorder.current = None
540557

558+
stamped._prime_rl_original_loader = loader
541559
return stamped
542560

543561
def _allocate_arena(self, manifest: WeightManifest, groups: list[_BakedGroup]) -> None:

0 commit comments

Comments
 (0)