Skip to content

Commit 068c08e

Browse files
authored
[QNN] Fix DiT checkpoint loading (#23718)
### Summary The QNN DiT export test fails while loading `microsoft/dit-base-finetuned-rvlcdip`: an upstream model-card update made Transformers reject the existing safetensors conversion, and requesting a fresh conversion returns HTTP 405 and raises `KeyError: 'event_id'`. See the [failing main job](https://github.com/pytorch/executorch/actions/runs/38305497935/job/114998525268). Set `use_safetensors=False` to load the model's published `pytorch_model.bin` directly, removing the synchronous conversion dependency from model loading. ### Test plan With PyTorch `2.13.0+cpu` and CI's pinned Transformers `5.0.0rc1`, the real checkpoint loads and CPU inference produces finite logits with shape `(1, 16)`. The loading check can be repeated with: ```bash DISABLE_SAFETENSORS_CONVERSION=true python - <<'PY' import torch from transformers import AutoModelForImageClassification model = AutoModelForImageClassification.from_pretrained( "microsoft/dit-base-finetuned-rvlcdip", use_safetensors=False ).eval() with torch.inference_mode(): logits = model(torch.rand(1, 3, 224, 224)).logits assert logits.shape == (1, 16) assert torch.isfinite(logits).all() print(logits.shape) PY ``` Also verified that loading succeeds with the default background-conversion settings when `spawn_conversion` is mocked to raise the same `KeyError`. `python -m black --check examples/qualcomm/oss_scripts/dit.py` and `git diff --check` passed. Full QNN export was not rerun locally. Authored with AI assistance using OpenAI Codex. cc @cbilgin @psiddh
1 parent dfc4730 commit 068c08e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • examples/qualcomm/oss_scripts

‎examples/qualcomm/oss_scripts/dit.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ def main(args):
7171

7272
module = (
7373
AutoModelForImageClassification.from_pretrained(
74-
"microsoft/dit-base-finetuned-rvlcdip"
74+
"microsoft/dit-base-finetuned-rvlcdip",
75+
use_safetensors=False,
7576
)
7677
.eval()
7778
.to("cpu")

0 commit comments

Comments
 (0)