Skip to content

apr finetune --task classify fails on tied-embedding .apr models — lm_head.weight is a 0-byte placeholder #2441

Description

@noahgift

Surfaced while fixing #2374 (train-family), and confirmed by that agent to be a distinct pre-existing defect, not a regression from the fix.

apr finetune --task classify <model>.apr used to pass the model file's parent directory to from_pretrained, so it silently trained whatever sibling SafeTensors happened to sit next to the named .apr. That was finding 3 of #2374 and is fixed in #2436 — the named file is now actually loaded.

With the file genuinely loaded, the real load path fails:

$ apr finetune qwen2.5-coder-0.5b-instruct.apr --task classify
error: Shape mismatch for 'lm_head.weight': expected 136134656 elements, got 0

That is tied word embeddings: the .apr stores lm_head.weight as a 0-byte placeholder because it is tied to embed_tokens, and Transformer::from_apr does not untie it.

The sibling-directory load was masking this — the wrong model loaded successfully, so nobody saw the right one fail.

This is closely related to #2309 (apr run: inference fails on tied-embedding .apr models, lm_head 0-byte placeholder not tied to embed_tokens) — plausibly the same root cause in a second consumer. Worth checking whether one fix covers both.

Filed separately so #2374 can close on its own coverage.

Audit epic: #2373

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High prioritybugSomething isn't workingdogfood-0.63.0Found by the 2026-08-09 crates.io dogfood audit of apr 0.63.0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions