# RuntimeError: parameter group's learning rate is not a float or a tensor of scalar type

- **ID:** `pytorch/tensor-requires-grad-and-optimizer-param-group`
- **Domain:** pytorch
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 75%

## Root Cause

Passing a non-float or non-scalar tensor as learning rate in optimizer parameter groups, often due to using a list or array instead of a single value.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.10 | active | — | — |
| 1.11 | active | — | — |
| 1.12 | active | — | — |
| 1.13 | active | — | — |
| 2.0 | active | — | — |
| 2.1 | active | — | — |
| 2.2 | active | — | — |
| 2.3 | active | — | — |

## Workarounds

1. **Ensure each parameter group's 'lr' is a single float or a torch scalar tensor. For example, when creating optimizer with per-parameter options, use a float value directly.** (85% success)
   ```
   Ensure each parameter group's 'lr' is a single float or a torch scalar tensor. For example, when creating optimizer with per-parameter options, use a float value directly.
   ```
2. **If using a learning rate scheduler that returns a tensor, convert it to a float before assigning to param_groups.** (80% success)
   ```
   If using a learning rate scheduler that returns a tensor, convert it to a float before assigning to param_groups.
   ```

## Dead Ends

- **** — This only changes the data type but doesn't fix the root cause if the value is still a collection. (40% fail)
- **** — This may hide the error but leads to unexpected behavior if the list is not reduced. (60% fail)
