# RuntimeError: gradient_checkpointing requires use_cache=False

- **ID:** `huggingface/gradient-checkpointing-disable-error`
- **Domain:** huggingface
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 93%

## Root Cause

Gradient checkpointing is incompatible with the key-value cache used during generation; use_cache must be disabled to enable gradient checkpointing.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| transformers>=4.25.0 | active | — | — |

## Workarounds

1. **Disable use_cache before enabling gradient checkpointing.** (95% success)
   ```
   Disable use_cache before enabling gradient checkpointing.
   ```
2. **Use the Trainer with gradient_checkpointing=True argument, which handles this automatically.** (90% success)
   ```
   Use the Trainer with gradient_checkpointing=True argument, which handles this automatically.
   ```

## Dead Ends

- **** — The two features are mutually exclusive during training; use_cache is only for inference. (98% fail)
- **** — The model configuration is checked at runtime; manual deletion does not bypass the check. (95% fail)
