[BUG]: ovl.py verify --weights crashes with AttributeError on checkpoint .pt files

Open Beginner friendly
#387 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@Anurag1428 is already working on this.

Since Nov 26, 2026.

  • #388 by @Anurag1428 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, pytorch

Research direction

Read load_weights() and cmd_verify in simple/ovl.py (the issue identifies lines 579–585 and 655–657). Check how the loaded object is passed to model_digest, then run the CPU reproduction from the issue with a checkpoint and an empty dict. Done when invalid inputs exit cleanly with is not a model state dict and valid model state dicts still verify.

Written by the indexing model from the issue text.

Description

Summary

In simple/ovl.py, load_weights() returns the raw object loaded by torch.load(..., weights_only=True) (or safetensors.torch.load_file(...)) without verifying that it is a non-empty state dict of tensors.

Passing a training checkpoint (e.g., ckpt-00001.pt, which is {"control": ..., "model": ..., "opt": ...}) or an empty dict to ovl.py verify --weights passes straight into model_digest(sd) and crashes with an unhandled AttributeError: 'dict' object has no attribute 'detach' (or returns a bogus digest for {}).

Source

  • simple/ovl.py (load_weights, lines 579–585; cmd_verify, lines 655–657)

Reproduction (CPU)

import hashlib, json, os, subprocess, sys, tempfile
from pathlib import Path
import torch

with tempfile.TemporaryDirectory() as tmp:
    d = Path(tmp)
    e0 = {"index": 0, "kind": "initial", "state": "0" * 64, "model": "0" * 64, "previous": None}
    h0 = hashlib.sha256(json.dumps(e0, sort_keys=True).encode()).hexdigest()
    e1 = {"index": 1, "kind": "final", "state": "1" * 64, "model": "1" * 64, "previous": h0}
    (d / "chain.jsonl").write_text(json.dumps(e0) + "\n" + json.dumps(e1) + "\n")

    ckpt = d / "ckpt-00001.pt"
    torch.save({"control": {"phase": "wikipedia"}, "model": {"w": torch.zeros(2)}, "opt": {}}, ckpt)

    res = subprocess.run(
        [sys.executable, "simple/ovl.py", "verify", "--run", str(d), "--no-anchor", "--weights", str(ckpt)],
        capture_output=True, text=True, env={**os.environ, "OVL_DEVICE": "cpu"},
    )
    print("rc:", res.returncode)
    print(res.stderr)

Expected Behavior

load_weights() should validate that the loaded object is a non-empty dict whose values are all tensors, and exit cleanly with is not a model state dict otherwise.

Dominant language
Python
Stars
27
Forks
72
Avg merge
2d 19h
Merged PRs (30d)
45

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AOSSIE-Org/OpenVerifiableLLM

All issues in AOSSIE-Org/OpenVerifiableLLM

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.