Files
OBLITERATUS/scripts/qwen38_campaign_arms.py
Joseph Magly 2104e19cd9 feat(campaign): add a matched causal control
Compare the composite concept arm with an explicit CausalLM arm using the same recipe, inputs and seed. Keep checkpoint ownership, receipts, interrupted resumes and raw failed metrics separate.

Refs #383, #333
2026-10-28 22:42:52 -04:00

52 lines
2.4 KiB
Python

"""Identify load-path edit arms and their matched-recipe concept provenance."""
from __future__ import annotations
EDIT_LOADERS = {"refusal": "composite", "concept": "composite", "concept-causal": "causal"}
def selected_arms(options):
return ("refusal", "concept", "concept-causal") if options.get("loadpath_causal_control") else (
"refusal", "concept")
def edit_loader(arm):
if arm not in EDIT_LOADERS:
raise ValueError(f"unknown load-path edit arm: {arm}")
return EDIT_LOADERS[arm]
def reload_loaders(arm):
# A native CausalLM export has no vision weights or composite configuration.
return ("causal",) if edit_loader(arm) == "causal" else ("causal", "composite")
def edit_provenance(arm, target):
return {
"schema_version": 1, "arm": arm, "edit_loader": edit_loader(arm), "seed": 0,
"pipeline_method": "basic" if target is not None else "qwen38_e03",
"concept_id": target.id if target is not None else None,
"recipe": target.recipe.to_dict() if target is not None else None,
"concept_input_sha256": target.activation_identity() if target is not None else None,
}
def control_evidence(arms, options):
"""Check matched inputs without interpreting quality outcomes as path parity."""
if not options.get("loadpath_causal_control"):
return {"mode": "not_requested", "path_independence": "not_established"}
composite = arms["concept"]["edit"]["edit_provenance"]
causal = arms["concept-causal"]["edit"]["edit_provenance"]
for arm, evidence in (("concept", composite), ("concept-causal", causal)):
if (evidence.get("schema_version") != 1 or evidence.get("arm") != arm
or evidence.get("edit_loader") != edit_loader(arm)):
raise ValueError("concept control loader/arm provenance does not match")
for key in ("concept_id", "recipe", "concept_input_sha256", "seed", "pipeline_method"):
if composite.get(key) is None or composite.get(key) != causal.get(key):
raise ValueError(f"concept control inputs do not match: {key}")
return {"mode": "matched_recipe_causal", "arms": ["concept", "concept-causal"],
"matched_inputs": True, "path_independence": "not_established",
"scope": "Same concept inputs, recipe and seed; inspect both raw quality outcomes. "
"This control does not establish edited-logit parity or 27B qualification."}