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

Functions

torch.Tensor _cosine_distance_rows (torch.Tensor a, torch.Tensor b)
list[dict[str, Any]] _layer_drift_rows (dict[int, torch.Tensor] base_acts, dict[int, torch.Tensor] ft_acts, int n_layers)
list[dict[str, Any]] _per_probe_rows (dict[int, torch.Tensor] base_acts, dict[int, torch.Tensor] ft_acts, list[dict[str, Any]] layer_rows, list[str] probes)
dict[str, Any] _finalize_payload (*, str model_id, str mode, str activation_mode, str checkpoint_name, str checkpoint_path, list[str] prompts, list[dict[str, Any]] layer_profile, list[dict[str, Any]] per_probe, int|None step=None)
dict[str, Any] run_llm_residual_drift (str model_id, str|Path checkpoint_path, list[str] prompts, *, str checkpoint_name="checkpoint")
dict[str, Any] run_residual_drift (str model_id, str|Path checkpoint_path, list[str]|None prompts=None, *, str|None checkpoint_name=None)
dict[str, Any] run_residual_drift_from_args (dict[str, Any] args)

Function Documentation

◆ _cosine_distance_rows()

torch.Tensor _cosine_distance_rows ( torch.Tensor a,
torch.Tensor b )
protected
Per-row cosine distance. a, b: (n, d).

Definition at line 19 of file residual_drift.py.

Referenced by _layer_drift_rows(), and _per_probe_rows().

◆ _finalize_payload()

dict[str, Any] _finalize_payload ( * ,
str model_id,
str mode,
str activation_mode,
str checkpoint_name,
str checkpoint_path,
list[str] prompts,
list[dict[str, Any]] layer_profile,
list[dict[str, Any]] per_probe,
int | None step = None )
protected

Definition at line 81 of file residual_drift.py.

Referenced by run_llm_residual_drift().

◆ _layer_drift_rows()

list[dict[str, Any]] _layer_drift_rows ( dict[int, torch.Tensor] base_acts,
dict[int, torch.Tensor] ft_acts,
int n_layers )
protected

Definition at line 26 of file residual_drift.py.

References _cosine_distance_rows().

Referenced by run_llm_residual_drift().

◆ _per_probe_rows()

list[dict[str, Any]] _per_probe_rows ( dict[int, torch.Tensor] base_acts,
dict[int, torch.Tensor] ft_acts,
list[dict[str, Any]] layer_rows,
list[str] probes )
protected

Definition at line 48 of file residual_drift.py.

References _cosine_distance_rows().

Referenced by run_llm_residual_drift().

◆ run_llm_residual_drift()

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

Definition at line 116 of file residual_drift.py.

References _finalize_payload(), _layer_drift_rows(), and _per_probe_rows().

Referenced by run_residual_drift().

◆ run_residual_drift()

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

Definition at line 163 of file residual_drift.py.

References run_llm_residual_drift().

Referenced by run_residual_drift_from_args().

◆ run_residual_drift_from_args()

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

Definition at line 183 of file residual_drift.py.

References run_residual_drift().