AQIT 0.1.0
Loading...
Searching...
No Matches
aquin.compute.weight_diff Namespace Reference

Functions

int _layer_from_key (str key)
str _matrix_label_from_key (str key)
Path ensure_smoke_lora_checkpoint ()
bool _has_lora_keys (dict[str, Any] state)
dict[str, Any] _matrix_entry (*, int layer, str matrix, str module, torch.Tensor delta, float|None base_norm=None)
list[dict[str, Any]] _layer_profile (list[dict[str, Any]] matrices)
dict[str, Any] _finalize_payload (*, str model_id, str mode, str checkpoint_name, str checkpoint_path, str delta_mode, list[dict[str, Any]] matrices, int|None step=None)
list[tuple[int, str, str, torch.Tensor, torch.Tensor]] _iter_tl_matrix_pairs (Any tl_base, Any tl_ft)
dict[str, Any] run_llm_hf_weight_diff (str model_id, str|Path checkpoint_path, *, str checkpoint_name="checkpoint")
dict[str, Any] run_llm_lora_weight_diff (str model_id, dict[str, Any] state_dict, *, str checkpoint_name="checkpoint", str checkpoint_path="", int|None step=None, int lora_r=_DEFAULT_LORA_R, float lora_alpha=_DEFAULT_LORA_ALPHA)
dict[str, Any] run_weight_diff (str model_id, str|Path checkpoint_path, *, str|None checkpoint_name=None)
dict[str, Any] run_weight_diff_from_args (dict[str, Any] args)

Variables

 _LAYER_RE = re.compile(r"(?:^|\.)(?:layers?|layer|block)\.?(\d+)(?:\.|$)", re.I)
int _DEFAULT_LORA_R = 8
float _DEFAULT_LORA_ALPHA = 16.0
str _SMOKE_LORA_PATH = Path.home() / ".aquin" / "smoke" / "weight-diff-lora.pt"

Function Documentation

◆ _finalize_payload()

dict[str, Any] _finalize_payload ( * ,
str model_id,
str mode,
str checkpoint_name,
str checkpoint_path,
str delta_mode,
list[dict[str, Any]] matrices,
int | None step = None )
protected

Definition at line 111 of file weight_diff.py.

References _layer_profile().

Referenced by run_llm_hf_weight_diff(), and run_llm_lora_weight_diff().

◆ _has_lora_keys()

bool _has_lora_keys ( dict[str, Any] state)
protected

Definition at line 66 of file weight_diff.py.

Referenced by run_llm_hf_weight_diff().

◆ _iter_tl_matrix_pairs()

list[tuple[int, str, str, torch.Tensor, torch.Tensor]] _iter_tl_matrix_pairs ( Any tl_base,
Any tl_ft )
protected

Definition at line 147 of file weight_diff.py.

◆ _layer_from_key()

int _layer_from_key ( str key)
protected

Definition at line 27 of file weight_diff.py.

Referenced by run_llm_hf_weight_diff(), and run_llm_lora_weight_diff().

◆ _layer_profile()

list[dict[str, Any]] _layer_profile ( list[dict[str, Any]] matrices)
protected

Definition at line 92 of file weight_diff.py.

Referenced by _finalize_payload().

◆ _matrix_entry()

dict[str, Any] _matrix_entry ( * ,
int layer,
str matrix,
str module,
torch.Tensor delta,
float | None base_norm = None )
protected

Definition at line 70 of file weight_diff.py.

Referenced by run_llm_hf_weight_diff(), and run_llm_lora_weight_diff().

◆ _matrix_label_from_key()

str _matrix_label_from_key ( str key)
protected

Definition at line 32 of file weight_diff.py.

Referenced by run_llm_hf_weight_diff(), and run_llm_lora_weight_diff().

◆ ensure_smoke_lora_checkpoint()

Path ensure_smoke_lora_checkpoint ( )
Tiny LoRA state_dict so desktop smoke can run without a real fine-tune.

Definition at line 49 of file weight_diff.py.

Referenced by run_weight_diff_from_args().

◆ run_llm_hf_weight_diff()

dict[str, Any] run_llm_hf_weight_diff ( str model_id,
str | Path checkpoint_path,
* ,
str checkpoint_name = "checkpoint" )

◆ run_llm_lora_weight_diff()

dict[str, Any] run_llm_lora_weight_diff ( str model_id,
dict[str, Any] state_dict,
* ,
str checkpoint_name = "checkpoint",
str checkpoint_path = "",
int | None step = None,
int lora_r = _DEFAULT_LORA_R,
float lora_alpha = _DEFAULT_LORA_ALPHA )

◆ run_weight_diff()

dict[str, Any] run_weight_diff ( str model_id,
str | Path checkpoint_path,
* ,
str | None checkpoint_name = None )

Definition at line 293 of file weight_diff.py.

References run_llm_hf_weight_diff().

Referenced by run_weight_diff_from_args().

◆ run_weight_diff_from_args()

dict[str, Any] run_weight_diff_from_args ( dict[str, Any] args)

Definition at line 310 of file weight_diff.py.

References ensure_smoke_lora_checkpoint(), and run_weight_diff().

Variable Documentation

◆ _DEFAULT_LORA_ALPHA

float aquin.compute.weight_diff._DEFAULT_LORA_ALPHA = 16.0
protected

Definition at line 23 of file weight_diff.py.

◆ _DEFAULT_LORA_R

int aquin.compute.weight_diff._DEFAULT_LORA_R = 8
protected

Definition at line 22 of file weight_diff.py.

◆ _LAYER_RE

aquin.compute.weight_diff._LAYER_RE = re.compile(r"(?:^|\.)(?:layers?|layer|block)\.?(\d+)(?:\.|$)", re.I)
protected

Definition at line 21 of file weight_diff.py.

◆ _SMOKE_LORA_PATH

str aquin.compute.weight_diff._SMOKE_LORA_PATH = Path.home() / ".aquin" / "smoke" / "weight-diff-lora.pt"
protected

Definition at line 24 of file weight_diff.py.