Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accelerate bug in specific versions #1007

Merged
merged 3 commits into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accelerate>=0.11.0
accelerate>=0.22.0
fire
flaky
future>=0.17.1
Expand Down
22 changes: 22 additions & 0 deletions skorch/tests/test_hf.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,10 +660,32 @@ def test_mixed_precision_save_load_params(
accelerator = accelerator_cls(mixed_precision=mixed_precision)
net = net_cls(accelerator=accelerator)
net.initialize()

filename = tmp_path / 'accel-net-params.pth'
net.save_params(f_params=filename)
net.load_params(f_params=filename)

@pytest.mark.parametrize('mixed_precision', ['fp16', 'bf16', 'no'])
def test_mixed_precision_inference(
self, net_cls, accelerator_cls, data, mixed_precision, tmp_path
):
from accelerate.utils import is_bf16_available

if (mixed_precision != 'no') and not torch.cuda.is_available():
pytest.skip('skipping AMP test because device does not support it')
if (mixed_precision == 'bf16') and not is_bf16_available():
pytest.skip('skipping bf16 test because device does not support it')

X, y = data
accelerator = accelerator_cls(mixed_precision=mixed_precision)
net = net_cls(accelerator=accelerator)
net.fit(X, y)
net.predict(X)
net.predict_proba(X)

Xt = torch.from_numpy(X).to(net.device)
net.forward(Xt)

def test_force_cpu(self, net_cls, accelerator_cls, data):
accelerator = accelerator_cls(device_placement=False, cpu=True)
net = net_cls(accelerator=accelerator)
Expand Down