Inspect and verify adapter¶
Check saved adapter before shipping or after download. Downloaded adapter is untrusted input: what reading checks and what it does not (hash is not signature) in SECURITY.md.
Command line¶
| Exit code | Meaning |
|---|---|
| 0 | adapter reads, hashes match (or no manifest) |
| 1 | adapter reads, but problem: lines on stderr (for example hash mismatch) |
| 2 | not directory, missing adapter_config.json or adapter_model.safetensors, or unreadable |
On success prints base model, rank, module count, one row per module (out x in, |B|_F, |A|_F, |BA|_F), then manifest: ok or manifest: none.
Python¶
import numpy as np
from astro_weights.edits import Edit, rank1
from astro_weights.export import read_peft, save_peft, verify_peft
rng = np.random.default_rng(0)
delta = rank1(
"model.layers.1.mlp.down_proj", rng.standard_normal(16), rng.standard_normal(48)
)
save_peft(Edit(deltas=(delta,), base_model="org/tiny"), "my-edit")
problems = verify_peft("my-edit") # list of strings; empty when fine
edit, problems = read_peft("my-edit") # edit plus problems, one pass
print(problems, edit.base_model)
Prints:
read_peft raises ValueError on adapters it cannot represent:
peft_typenotLORA;use_dora,use_rsloraorfan_in_fan_outtrue.rank_pattern,alpha_patternormodules_to_saveset;biasother thannone.rnot int >= 1;lora_alphanot number, orlora_alpha / rnot finite.- tensors for module outside list-form
target_modules. - malformed JSON or manifest fields.
Hash problems come back in list. verify_peft never raises: every problem, structural or hash, comes back as string. load_peft raises when list not empty.