MCPcopy Create free account
hub / github.com/AI-Hypercomputer/maxtext / load_single_adapter

Method load_single_adapter

src/MaxText/maxengine.py:285–305  ·  view source on GitHub ↗

Load Single adapter from adapter_path. Expect adapter_config.json and LoRA adapter weights at this path within subdirectory `/0/items`.

(self, adapter_path)

Source from the content-addressed store, hash-verified

283 return params
284
285 def load_single_adapter(self, adapter_path):
286 """
287 Load Single adapter from adapter_path.
288 Expect adapter_config.json and LoRA adapter weights at this path within subdirectory `/0/items`.
289 """
290 adapter_config_path = os.path.join(adapter_path, "adapter_config.json")
291 adapter_weights_path = os.path.join(adapter_path, "0", "items")
292
293 params, config = lora_utils.load_adapter(self.config, self.abstract_params, adapter_config_path, adapter_weights_path)
294
295 if config is None:
296 raise ValueError(f"Failed to read lora_config from {adapter_config_path}")
297
298 if params is None:
299 raise ValueError(f"Failed to read lora_config from {adapter_config_path}")
300
301 config["adapter_path"] = adapter_weights_path
302
303 self.print_stats("After load_single_adapter.")
304
305 return params, config
306
307 def apply_adapter(self, base_params, adapter_config, adapter_params):
308 """Apply the adapter params on the base params."""

Callers

nothing calls this directly

Calls 1

print_statsMethod · 0.95

Tested by

no test coverage detected