Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tests/models/testing_utils/quantization.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ def _test_quantization_training(self, config_kwargs):
# Step 3: run forward and backward pass
inputs = self.get_dummy_inputs()

with torch.amp.autocast(torch_device, dtype=torch.float16):
# Use bfloat16 instead of float16 to avoid gradient underflow with quantized layers
with torch.amp.autocast(torch_device, dtype=torch.bfloat16):
out = model(**inputs, return_dict=False)[0]
out.norm().backward()

Expand Down
Loading