Skip to content

Make baked GPT-2 weights readable by the Lambda user - #7

Merged
m-messer merged 1 commit into
mainfrom
fix/gpt2-weights-permissions
Nov 4, 2026
Merged

m-messer merged 1 commit into
mainfrom
fix/gpt2-weights-permissions

Conversation

@m-messer

@m-messer m-messer commented Nov 4, 2026

Copy link
Copy Markdown
Member

Problem

gpt2_infer failed on AWS with:

Could not run the GPT-2 language model.
No such file or directory: /app/hf_models/gpt2/model.safetensors

The file was in the image. safetensors 0.8 saves via a tempfile + rename (safetensors/src/tensor.rs), which leaves model.safetensors as mode 0600, owned by root. Lambda runs as a non-root user, so open() fails, and safetensors reports every open failure as "No such file or directory" (bindings/python/src/lib.rs). Tokenizer/config files are written normally, which is why only the weights failed.

Fix

chmod -R a+rX "${GPT2_MODEL_DIR}" after the download in the Dockerfile.

Testing

  • Deployed this branch to staging (run 41873269047); the GPT-2 layer was rebuilt with the chmod.
  • POST /evaluate with "model": "gpt2_infer" returned 200 in ~0.5–0.7s with generated text; the same seed gave identical output.

Not in this PR

The first request after a cold start returns 503 at 30s (API Gateway timeout) while torch and GPT-2 load. That will be handled separately.

🤖 Generated with Claude Code

safetensors 0.8 saves model.safetensors via a tempfile+rename, leaving it
mode 0600 owned by root. Lambda runs as a non-root user, so opening it
failed (reported by safetensors as "No such file or directory").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@m-messer
m-messer merged commit fbce17b into main Nov 4, 2026
10 checks passed
@m-messer
m-messer deleted the fix/gpt2-weights-permissions branch November 4, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant