@@ -147,29 +147,3 @@ def state_dict(self, destination=None, prefix='', keep_vars=False):
147147 # Store adapter state dict under the "adapter" prefix in the destination dict
148148 self .adapter .state_dict (destination = destination , prefix = f'{ prefix } adapter.' , keep_vars = keep_vars )
149149 return destination
150-
151- def sharded_state_dict (
152- self ,
153- prefix : str = '' ,
154- sharded_offsets : Tuple [Tuple [int , int , int ]] = (),
155- metadata : Optional [dict ] = None ,
156- ) -> "ShardedStateDict" :
157- """Retrieve the sharded state dictionary of the wrapped module and adapter.
158-
159- This method is used for distributed checkpointing, combining the sharded states
160- of both the main module and the adapter.
161-
162- Args:
163- prefix (str): A prefix added to parameter and buffer names. Defaults to ''.
164- sharded_offsets (Tuple[Tuple[int, int, int]]): Offsets for sharded parameters.
165- Defaults to an empty tuple.
166- metadata (Optional[dict]): Additional metadata for the sharded state.
167- Defaults to None.
168-
169- Returns:
170- ShardedStateDict: The combined sharded state dictionary.
171- """
172- sharded_state_dict = {}
173- sharded_state_dict .update (self .to_wrap .sharded_state_dict (prefix , sharded_offsets , metadata ))
174- sharded_state_dict .update (self .adapter .sharded_state_dict (f"{ prefix } adapter." , sharded_offsets , metadata ))
175- return sharded_state_dict
0 commit comments