from pathlib import Pathimport torchfrom transformers import AutoModelForCausalLM, AutoTokenizer model_id = "YuechunSun/TopoVerus-32B"tokenizer = AutoTokenizer.from_pretrained(model_id)model = AutoModelForCausalLM.from_pretrained( model_id, torch_dtype=torch.bfloat16, device_map="auto")code = Path("program.rs").read_text()messages = [ { "role": "system", "content": ( "You are a Verus formal-verification expert. Repair only proof annotations. " "Preserve executable code, function contracts and specification functions. " "Respond with <think>...</think>, <counterexample> containing [State], " "[Execution Trace] and [Violation], <reasoning>...</reasoning>, then " "exactly one final Rust code fence. Do not use assume or admit." ), }, { "role": "user", "content": f"Repair this Verus program.\n\n[Buggy Code]\n```rust\n{code}\n```", },]text = tokenizer.apply_chat_template( messages, tokenize=False, add_generation_prompt=True)inputs = tokenizer(text, return_tensors="pt").to(model.device)with torch.inference_mode(): output = model.generate( **inputs, max_new_tokens=8192, do_sample=True, temperature=0.7, top_p=0.9, )print(tokenizer.decode( output[0, inputs.input_ids.shape[1]:], skip_special_tokens=True))