MCPcopy Index your code
hub / github.com/PRIME-RL/PRIME / get_weight_buffer_meta_from_module

Function get_weight_buffer_meta_from_module

training/verl/utils/memory_buffer.py:58–65  ·  view source on GitHub ↗

Return a dictionary containing name to a shape and dtype.

(module: nn.Module)

Source from the content-addressed store, hash-verified

56
57
58def get_weight_buffer_meta_from_module(module: nn.Module) -> Dict[str, Dict]:
59 """
60 Return a dictionary containing name to a shape and dtype.
61 """
62 weight_buffer_meta = {}
63 for name, param in sorted(module.named_parameters()):
64 weight_buffer_meta[name] = {'shape': param.shape, 'dtype': param.dtype}
65 return weight_buffer_meta
66
67
68def build_memory_buffer(weight_buffer_meta: Dict[str, Dict]) -> Dict[torch.dtype, MemoryBuffer]:

Callers 2

_build_param_bufferMethod · 0.90
__init__Method · 0.85

Calls 1

named_parametersMethod · 0.80

Tested by

no test coverage detected