Skip to content

Commit 17c7675

Browse files
Release 0.15.0 (#1014)
* Update VERSION * Remove code for backwards compatibility with v0.11 * Update CHANGES.md Since skorch nets pickled with <= v0.11 can no longer be unpickled, I added an entry on how to transition these pickle files. Release text: This is a smaller release, but it still contains changes which will be interesting to some of you. We added the possibility to store weights using safetensors. This can have several advantages, listed here. When calling net.save_params and net.load_params, just pass use_safetensors=True to use safetensors instead of pickle. Moreover, there is a new argument on NeuralNet: You can now pass use_caching=False or True to disable or enable caching for all callbacks at once. This is useful if you have a lot of scoring callbacks and don't want to toggle caching on each individually. Finally, we fixed a few issues related to using skorch with accelerate. Thanks Zach Mueller (@ muellerzr) for his first contribution to skorch.
1 parent 7fd4b6e commit 17c7675

4 files changed

Lines changed: 15 additions & 56 deletions

File tree

CHANGES.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,24 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
9+
910
### Added
10-
- Add the option to globally override the use of caching in scoring callbacks on the net by setting the `use_caching` argument on the net (this overrides the settings of individual callbacks)
11-
- Add support for saving and loading parameters with [safetensors](https://github.com/huggingface/safetensors/); use `net.save_params(..., use_safetensors=True)` and `net.load_params(..., use_safetensors=True)` (requires to install the `safetensors` library)
11+
### Changed
12+
### Fixed
13+
14+
## [0.15.0] - 2023-09-04
15+
16+
### Added
17+
- Add the option to globally override the use of caching in scoring callbacks on the net by setting the `use_caching` argument on the net (this overrides the settings of individual callbacks) (#971)
18+
- Add support for saving and loading parameters with [safetensors](https://github.com/huggingface/safetensors/); use `net.save_params(..., use_safetensors=True)` and `net.load_params(..., use_safetensors=True)` (requires to install the `safetensors` library) (#970)
1219

1320
### Changed
21+
- Nets pickled with skorch version 0.11 can no longer be loaded in version 0.15 (see #880); to transition these nets, pickle them in a skorch version between 0.12 and 0.14, then load them in 0.15
22+
1423
### Fixed
1524

16-
- Fixed a couple of issues when saving and loading parameters while using accelerate (via `AccelerateMixin`) in a multi-GPU setting (#1008)
25+
- Fixed a couple of issues when saving and loading parameters while using accelerate (via `AccelerateMixin`) in a multi-GPU setting, and some other minor accelerate issues (#1008, #1009)
26+
- Installing skorch with the `[testing]` option now installs all dev requirements (#1015)
1727

1828
## [0.14.0] - 2023-06-24
1929

@@ -333,3 +343,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
333343
[0.12.1]: https://github.com/skorch-dev/skorch/compare/v0.12.0...v0.12.1
334344
[0.13.0]: https://github.com/skorch-dev/skorch/compare/v0.12.1...v0.13.0
335345
[0.14.0]: https://github.com/skorch-dev/skorch/compare/v0.13.0...v0.14.0
346+
[0.15.0]: https://github.com/skorch-dev/skorch/compare/v0.14.0...v0.15.0

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.14.1dev0
1+
0.15.0

skorch/net.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2219,24 +2219,6 @@ def __getstate__(self):
22192219
return state
22202220

22212221
def __setstate__(self, state):
2222-
# TODO remove after 2023-09
2223-
# in skorch 0.11 -> 0.12, we made a change to parameter validation. We
2224-
# don't store key/vals in self._kwargs anymore, as the values were
2225-
# redundant and were not considered as possibly CUDA dependent. Instead,
2226-
# we now use the attribute '_params_to_validate', which only stores
2227-
# keys. The code below is to make the net backwards compatible.
2228-
if '_kwargs' in state:
2229-
if '_params_to_validate' in state:
2230-
# there should not be _kwargs AND _params_to_validate
2231-
raise ValueError(
2232-
"Something went wrong here. Please open an issue on "
2233-
"https://github.com/skorch-dev/skorch/issues detailing what "
2234-
"caused this error and the used skorch version."
2235-
)
2236-
kwargs = state.pop('_kwargs')
2237-
params_to_validate = set(kwargs.keys())
2238-
state['_params_to_validate'] = params_to_validate
2239-
22402222
# get_map_location will automatically choose the
22412223
# right device in cases where CUDA is not available.
22422224
map_location = get_map_location(state['device'])

skorch/tests/test_net.py

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -441,40 +441,6 @@ def test_pickle_load(self, cuda_available, pickled_cuda_net_path):
441441
with open(pickled_cuda_net_path, 'rb') as f:
442442
pickle.load(f)
443443

444-
def test_load_net_with_kwargs_attribute_to_net_without(self, net_pickleable):
445-
# TODO remove after 2023-09
446-
# in skorch 0.11 -> 0.12, we made a change to parameter validation. We
447-
# don't store key/vals in self._kwargs anymore, as the values were
448-
# redundant and were not considered as possibly CUDA dependent, which
449-
# can cause errors when loading to CPU. Since we remove one attribute
450-
# and add a new one ('_params_to_validate'), we have to take extra steps
451-
# to ensure that old models can still be loaded correctly.
452-
453-
# emulate old net:
454-
del net_pickleable._params_to_validate
455-
net_pickleable._kwargs = {'foo': 123, 'bar__baz': 456}
456-
457-
# after loading, behaves like new net
458-
net_loaded = pickle.loads(pickle.dumps(net_pickleable))
459-
assert net_loaded._params_to_validate == {'foo', 'bar__baz'}
460-
assert not hasattr(net_loaded, '_kwargs')
461-
462-
def test_load_net_with_both_kwargs_and_params_to_validate_attributes_raises(
463-
self, net_pickleable
464-
):
465-
# TODO remove after 2023-09
466-
# Check test_load_net_with_kwargs_attribute_to_net_without for more
467-
# details
468-
net_pickleable._kwargs = {'foo': 123}
469-
net_pickleable._params_to_validate = {'foo'}
470-
msg = (
471-
"Something went wrong here. Please open an issue on "
472-
"https://github.com/skorch-dev/skorch/issues detailing what "
473-
"caused this error and the used skorch version."
474-
)
475-
with pytest.raises(ValueError, match=msg):
476-
pickle.loads(pickle.dumps(net_pickleable))
477-
478444
@pytest.mark.parametrize('device', ['cpu', 'cuda'])
479445
def test_device_torch_device(self, net_cls, module_cls, device):
480446
# Check if native torch.device works as well.

0 commit comments

Comments
 (0)