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

Functions

str _get_model_id (dict ctx, dict args)
list[str] _as_str_list (Any value, *, list[str]|None fallback=None)
dict|None _as_json_dict (Any value)
list _as_json_list (Any value)
 _get_model (dict ctx)
dict _not_impl (str tool_name)
dict _run_steer_and_show (dict args, dict ctx)
dict _extract_steer_vector (dict args, dict ctx)
dict _run_multi_steer (dict args, dict ctx)
dict _run_consistency_eval (dict args, dict ctx)
dict _run_suppression_eval (dict args, dict ctx)
dict _run_boundary_eval (dict args, dict ctx)
dict _run_audit (dict args, dict ctx)
dict _run_benchmarks_on_top_feature (dict args, dict ctx)
dict _check_weights (dict args, dict ctx)
list[dict] _normalize_umap_points (list[dict] raw)
list[dict]|None _try_fetch_precomputed_umap (str model_id, int layer)
tuple[list[dict], int] _compute_umap_points (str model_id, int|None layer)
dict _ensure_umap_loaded (dict args, dict ctx)
dict _run_layer_analysis (dict args, dict ctx)
dict _run_sae_stats (dict args, dict ctx)
dict _run_weight_diff (dict args, dict ctx)
dict _run_merge_analysis (dict args, dict ctx)
dict _run_trajectory_analysis (dict args, dict ctx)
dict _run_residual_drift (dict args, dict ctx)
dict _run_confidence_analysis (dict args, dict ctx)
float _token_kl_divergence (clean_logits, perturbed_logits)
dict _run_perturbation_sensitivity (dict args, dict ctx)
dict _run_attention_routing (dict args, dict ctx)
dict _run_find_feature (dict args, dict ctx)
dict _dataset_generate (dict args, dict ctx)
str|None _session_sim_kind_filter (dict ctx)
dict _assemble_simulation_result (list[dict] events)
str _persist_simulation_run (list[dict] events, dict meta)
dict _load_simulation_result (str run_id)
dict _list_simulation_runs (dict args, dict ctx)
dict _load_simulation_run (dict args, dict ctx)
dict _compare_simulations (dict args, dict ctx)
str|None _simulation_error (list events)
dict _wrap_simulation_result (list events, dict final, dict meta)
dict _run_custom_eval (dict args, dict ctx)
dict _run_red_team (dict args, dict ctx)
dict _run_logit_lens (dict args, dict ctx)
dict _run_trace (dict args, dict ctx)
dict _run_prompt_attribution (dict args, dict ctx)
dict _run_full_inspection_bridge (dict args, dict ctx)
dict _get_feature_logits_bridge (dict args, dict ctx)
dict _get_feature_neighbors_bridge (dict args, dict ctx)
 _drain_queue (worker_fn, req, extra_kwargs=None, on_event=None)
 _build_simulate_req (dict args, dict ctx)
None _print_simulate_progress (dict ev)
dict _run_simulation (dict args, dict ctx)
dict call (str tool_name, dict args, dict ctx)

Variables

dict _SANDBOX_STATE = {}
dict TOOL_ROUTES

Function Documentation

◆ _as_json_dict()

dict | None _as_json_dict ( Any value)
protected
Parse topics and other object-shaped CLI flags.

Definition at line 62 of file bridge.py.

Referenced by _run_suppression_eval().

◆ _as_json_list()

list _as_json_list ( Any value)
protected
Parse JSON array CLI flags (capabilities, evals, etc.).

Definition at line 82 of file bridge.py.

◆ _as_str_list()

list[str] _as_str_list ( Any value,
* ,
list[str] | None fallback = None )
protected
Normalize CLI/API list flags :  never iterate a JSON string character-by-character.

Definition at line 41 of file bridge.py.

Referenced by _run_audit(), _run_boundary_eval(), _run_consistency_eval(), and _run_custom_eval().

◆ _assemble_simulation_result()

dict _assemble_simulation_result ( list[dict] events)
protected
Fold simulation SSE events into one result dict for compare/load.

Definition at line 1067 of file bridge.py.

Referenced by _persist_simulation_run(), and _wrap_simulation_result().

◆ _build_simulate_req()

_build_simulate_req ( dict args,
dict ctx )
protected

Definition at line 1546 of file bridge.py.

References _get_model_id().

Referenced by _run_simulation().

◆ _check_weights()

dict _check_weights ( dict args,
dict ctx )
protected

Definition at line 434 of file bridge.py.

References _get_model_id().

◆ _compare_simulations()

dict _compare_simulations ( dict args,
dict ctx )
protected
Compare two simulation runs.

Definition at line 1211 of file bridge.py.

References _load_simulation_result().

◆ _compute_umap_points()

tuple[list[dict], int] _compute_umap_points ( str model_id,
int | None layer )
protected
Project SAE decoder weights into 3D (matches /db precomputed UMAPs).

Definition at line 591 of file bridge.py.

Referenced by _ensure_umap_loaded().

◆ _dataset_generate()

dict _dataset_generate ( dict args,
dict ctx )
protected

Definition at line 1026 of file bridge.py.

◆ _drain_queue()

_drain_queue ( worker_fn,
req,
extra_kwargs = None,
on_event = None )
protected
Run worker_fn(req, queue, loop) in a thread. Drain the queue until a
sentinel {"__done__": True} payload arrives. Return (events, final_result).

Definition at line 1496 of file bridge.py.

Referenced by _run_simulation().

◆ _ensure_umap_loaded()

dict _ensure_umap_loaded ( dict args,
dict ctx )
protected

◆ _extract_steer_vector()

dict _extract_steer_vector ( dict args,
dict ctx )
protected

Definition at line 172 of file bridge.py.

References _get_model_id().

◆ _get_feature_logits_bridge()

dict _get_feature_logits_bridge ( dict args,
dict ctx )
protected

Definition at line 1423 of file bridge.py.

References _get_model_id().

◆ _get_feature_neighbors_bridge()

dict _get_feature_neighbors_bridge ( dict args,
dict ctx )
protected

Definition at line 1456 of file bridge.py.

References _get_model_id().

◆ _get_model()

_get_model ( dict ctx)
protected
Return the loaded model, loading it if necessary.

Definition at line 102 of file bridge.py.

◆ _get_model_id()

◆ _list_simulation_runs()

dict _list_simulation_runs ( dict args,
dict ctx )
protected

Definition at line 1132 of file bridge.py.

References _session_sim_kind_filter().

◆ _load_simulation_result()

dict _load_simulation_result ( str run_id)
protected

Definition at line 1118 of file bridge.py.

Referenced by _compare_simulations(), and _load_simulation_run().

◆ _load_simulation_run()

dict _load_simulation_run ( dict args,
dict ctx )
protected

Definition at line 1203 of file bridge.py.

References _load_simulation_result().

◆ _normalize_umap_points()

list[dict] _normalize_umap_points ( list[dict] raw)
protected
Map bridge output to web UMAPExplorer shape (feature_idx, x/y/z in 0-1).

Definition at line 522 of file bridge.py.

Referenced by _ensure_umap_loaded().

◆ _not_impl()

dict _not_impl ( str tool_name)
protected

Definition at line 115 of file bridge.py.

◆ _persist_simulation_run()

str _persist_simulation_run ( list[dict] events,
dict meta )
protected
Save simulation output under ~/.aquin/runs/<id> for list/compare.

Definition at line 1096 of file bridge.py.

References _assemble_simulation_result().

Referenced by _wrap_simulation_result().

◆ _print_simulate_progress()

None _print_simulate_progress ( dict ev)
protected
Print key simulation metrics as they arrive (CLI live output).

Definition at line 1585 of file bridge.py.

◆ _run_attention_routing()

dict _run_attention_routing ( dict args,
dict ctx )
protected

Definition at line 957 of file bridge.py.

References _get_model_id().

◆ _run_audit()

dict _run_audit ( dict args,
dict ctx )
protected

Definition at line 354 of file bridge.py.

References _as_str_list(), and _get_model_id().

◆ _run_benchmarks_on_top_feature()

dict _run_benchmarks_on_top_feature ( dict args,
dict ctx )
protected

Definition at line 378 of file bridge.py.

References _get_model_id().

◆ _run_boundary_eval()

dict _run_boundary_eval ( dict args,
dict ctx )
protected

Definition at line 334 of file bridge.py.

References _as_str_list(), and _get_model_id().

◆ _run_confidence_analysis()

dict _run_confidence_analysis ( dict args,
dict ctx )
protected

Definition at line 837 of file bridge.py.

◆ _run_consistency_eval()

dict _run_consistency_eval ( dict args,
dict ctx )
protected

Definition at line 302 of file bridge.py.

References _as_str_list(), and _get_model_id().

◆ _run_custom_eval()

dict _run_custom_eval ( dict args,
dict ctx )
protected

Definition at line 1277 of file bridge.py.

References _as_str_list(), and _get_model_id().

◆ _run_find_feature()

dict _run_find_feature ( dict args,
dict ctx )
protected

Definition at line 980 of file bridge.py.

References _get_model_id().

◆ _run_full_inspection_bridge()

dict _run_full_inspection_bridge ( dict args,
dict ctx )
protected
Delegates to pipelines.run_full_inspection (same logic as inspect.py handler).

Definition at line 1392 of file bridge.py.

References _get_model_id().

◆ _run_layer_analysis()

dict _run_layer_analysis ( dict args,
dict ctx )
protected

Definition at line 654 of file bridge.py.

References _get_model_id().

◆ _run_logit_lens()

dict _run_logit_lens ( dict args,
dict ctx )
protected

Definition at line 1333 of file bridge.py.

References _get_model_id().

◆ _run_merge_analysis()

dict _run_merge_analysis ( dict args,
dict ctx )
protected

Definition at line 738 of file bridge.py.

◆ _run_multi_steer()

dict _run_multi_steer ( dict args,
dict ctx )
protected

Definition at line 206 of file bridge.py.

References _get_model_id().

◆ _run_perturbation_sensitivity()

dict _run_perturbation_sensitivity ( dict args,
dict ctx )
protected

Definition at line 882 of file bridge.py.

References _get_model_id(), and _token_kl_divergence().

◆ _run_prompt_attribution()

dict _run_prompt_attribution ( dict args,
dict ctx )
protected

Definition at line 1367 of file bridge.py.

References _get_model_id().

◆ _run_red_team()

dict _run_red_team ( dict args,
dict ctx )
protected

Definition at line 1311 of file bridge.py.

References _get_model_id().

◆ _run_residual_drift()

dict _run_residual_drift ( dict args,
dict ctx )
protected

Definition at line 804 of file bridge.py.

◆ _run_sae_stats()

dict _run_sae_stats ( dict args,
dict ctx )
protected

Definition at line 672 of file bridge.py.

◆ _run_simulation()

dict _run_simulation ( dict args,
dict ctx )
protected
Full training simulation. Pass --dataset /path, --algo /path, or --topic.

Definition at line 1653 of file bridge.py.

References _build_simulate_req(), _drain_queue(), _get_model_id(), and _wrap_simulation_result().

◆ _run_steer_and_show()

dict _run_steer_and_show ( dict args,
dict ctx )
protected

Definition at line 123 of file bridge.py.

References _get_model_id().

◆ _run_suppression_eval()

dict _run_suppression_eval ( dict args,
dict ctx )
protected

Definition at line 319 of file bridge.py.

References _as_json_dict(), and _get_model_id().

◆ _run_trace()

dict _run_trace ( dict args,
dict ctx )
protected

Definition at line 1350 of file bridge.py.

References _get_model_id().

◆ _run_trajectory_analysis()

dict _run_trajectory_analysis ( dict args,
dict ctx )
protected

Definition at line 771 of file bridge.py.

◆ _run_weight_diff()

dict _run_weight_diff ( dict args,
dict ctx )
protected

Definition at line 705 of file bridge.py.

◆ _session_sim_kind_filter()

str | None _session_sim_kind_filter ( dict ctx)
protected
LLM sessions list LLM sims.

Definition at line 1063 of file bridge.py.

Referenced by _list_simulation_runs().

◆ _simulation_error()

str | None _simulation_error ( list events)
protected

Definition at line 1249 of file bridge.py.

Referenced by _wrap_simulation_result().

◆ _token_kl_divergence()

float _token_kl_divergence ( clean_logits,
perturbed_logits )
protected
KL(clean || perturbed) on a single token distribution :  stable at zero mass.

Definition at line 870 of file bridge.py.

Referenced by _run_perturbation_sensitivity().

◆ _try_fetch_precomputed_umap()

list[dict] | None _try_fetch_precomputed_umap ( str model_id,
int layer )
protected
Load precomputed 3D UMAP from the public SAE DB when available.

Definition at line 565 of file bridge.py.

Referenced by _ensure_umap_loaded().

◆ _wrap_simulation_result()

dict _wrap_simulation_result ( list events,
dict final,
dict meta )
protected

◆ call()

dict call ( str tool_name,
dict args,
dict ctx )
Dispatch a tool call to its compute implementation.
Returns a result dict. Never raises :  errors are returned as {"error": ...}.

Definition at line 1758 of file bridge.py.

Variable Documentation

◆ _SANDBOX_STATE

dict aquin.compute.bridge._SANDBOX_STATE = {}
protected

Definition at line 25 of file bridge.py.

◆ TOOL_ROUTES

dict aquin.compute.bridge.TOOL_ROUTES

Definition at line 1703 of file bridge.py.