# llama_cpp.llama_cpp.LlamaError: Model file 'model.gguf' is not a valid GGUF file or is corrupted. Expected magic number 0x46554747, got 0x00000000.

- **ID:** `llm/llama-cpp-gguf-model-mismatch`
- **Domain:** llm
- **Category:** install_error
- **Error Code:** `LLAMA-CPP-ERR-0003`
- **Verification:** ai_generated
- **Fix Rate:** 92%

## Root Cause

The GGUF model file is either incomplete (truncated download), corrupted during transfer, or is not actually a GGUF file (e.g., a PyTorch checkpoint or a different format renamed to .gguf).

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| llama-cpp-python==0.2.60 | active | — | — |
| llama-cpp-python==0.2.70 | active | — | — |
| llama.cpp==b2775 | active | — | — |

## Workarounds

1. **Verify the GGUF file integrity using the sha256 checksum provided by the model source (e.g., Hugging Face). Re-download the file if the checksum doesn't match: `sha256sum model.gguf` then compare with the published hash. Example: `curl -L -o model.gguf https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.2-GGUF/resolve/main/mistral-7b-instruct-v0.2.Q4_K_M.gguf`.** (98% success)
   ```
   Verify the GGUF file integrity using the sha256 checksum provided by the model source (e.g., Hugging Face). Re-download the file if the checksum doesn't match: `sha256sum model.gguf` then compare with the published hash. Example: `curl -L -o model.gguf https://huggingface.co/TheBloke/Mistral-7B-Instruct-v0.2-GGUF/resolve/main/mistral-7b-instruct-v0.2.Q4_K_M.gguf`.
   ```
2. **Use the `convert.py` script from llama.cpp to convert a PyTorch checkpoint to GGUF: `python convert.py --outfile model.gguf /path/to/pytorch/model`.** (85% success)
   ```
   Use the `convert.py` script from llama.cpp to convert a PyTorch checkpoint to GGUF: `python convert.py --outfile model.gguf /path/to/pytorch/model`.
   ```
3. **Check the first few bytes of the file to confirm it's a GGUF: `head -c 4 model.gguf | od -A x -t x1z`. Expected output: `000000 47 47 55 46 >GGUF<`. If it shows zeros or other values, the file is corrupted or not GGUF.** (90% success)
   ```
   Check the first few bytes of the file to confirm it's a GGUF: `head -c 4 model.gguf | od -A x -t x1z`. Expected output: `000000 47 47 55 46 >GGUF<`. If it shows zeros or other values, the file is corrupted or not GGUF.
   ```

## Dead Ends

- **** — The error is in the model file, not the library. Reinstalling the package does not repair a corrupted or invalid GGUF file. (98% fail)
- **** — llama.cpp only supports GGUF format. Changing the extension doesn't convert the file; the library will still try to parse it as GGUF and fail. (95% fail)
- **** — The quantization level is embedded in the GGUF file itself. You cannot change the quantization by renaming or modifying metadata; you need the correct GGUF file for that quantization. (85% fail)
