Skip to content

fix(lora): load_adapter_peft checks dtype, converts bf16/f16, sorts weights (PMAT-7024) - #7067

Merged
noahgift merged 1 commit into
mainfrom
PMAT-7024-fix
Nov 15, 2026
Merged

noahgift merged 1 commit into
mainfrom
PMAT-7024-fix

Conversation

@noahgift

Copy link
Copy Markdown
Member

What

load_adapter_peft checks the tensor dtype instead of reading every tensor as f32.

  • F32, BF16 and F16 are decoded to f32; any other dtype, or a byte length that is not a multiple of the element size, returns AdapterError::PeftFormatError naming the tensor.
  • Weights are returned sorted by name.
  • F32 is read with f32::from_le_bytes, so the cast no longer depends on buffer alignment.

crates/aprender-train/src/lora/adapter/io.rs only (+97/-1). No workflow, gate, script or contract change.

Measured (build host, scratch copy of the branch at e875bc4)

  • With the dtype check reverted: cargo test -p aprender-train --lib lora::adapter::io exit 101; test_peft_bf16_and_f16_convert_to_f32 and test_peft_unsupported_dtype_is_error fail.
  • With the fix: cargo test -p aprender-train --lib lora::adapter 58 passed, 0 failed.
  • cargo clippy -p aprender-train --lib -- -D warnings 0; cargo fmt --all -- --check 0.

Not measured

  • test_peft_weights_sorted_by_name also passed with the sort reverted (three keys can come out of a HashMap in sorted order), so it does not prove the sort.
  • The full workspace suite and the cuda feature; CI is the first full run.

ont-delta: none (a loader refuses or converts dtypes it used to misread; no surface, contract or ontology row changes)
Closes #7024
Pmat-Ticket: PMAT-7024

🤖 Generated with Claude Code

…-7024)

F32/BF16/F16 are decoded to f32; any other dtype or a misaligned byte
length returns PeftFormatError naming the tensor. Weights are sorted by
name instead of HashMap order. Tests: bf16/f16 values, I64/F64 rejected,
sorted order.

Pmat-Ticket: PMAT-7024
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@noahgift noahgift added the fix-set GHC-001 cap-exempt fix label Nov 15, 2026
@github-actions

Copy link
Copy Markdown

§13.11 rung 1 — quorum shadow verdict

S13-SHADOW pr=7067 head=e875bc47b372ddb074d98f68868a8eb1648a29a8 verdict=REFUSE class=Q1 arm_rc=1

Shadow mode: this records a verdict and merges nothing. A refusal
to arm is not a block (§13 adds zero rows to §7) — the pull request is
exactly as green as it was.

@noahgift
noahgift enabled auto-merge (squash) November 15, 2026 09:53
@noahgift
noahgift merged commit 259abd2 into main Nov 15, 2026
19 checks passed
@noahgift
noahgift deleted the PMAT-7024-fix branch November 15, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix-set GHC-001 cap-exempt fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FT-21 (re-filed from #6549): load_adapter_peft reads bf16/f16 tensors as f32 with no dtype check

1 participant