Releases: mlverse/torch
Releases · mlverse/torch
v0.13.0
Breaking changes
- lantern is now distributed over a different URL (https://torch-cdn.mlverse.org).
For most users this shouldn't have any effect, unless you need special authorization
to access some URL's. (#1162)
New features
- Added support for a private
$finalize_deep_clone()
method fornn_module
which
allows to run some code after cloning a module. - A
compare_proxy
method for thetorch_tensor
type was added
it allows to compare torch tensors usingtestthat::expect_equal()
. - Converting torch tensor to R array works when tensor has 'cuda' device (#1130)
Bug fixes
- Fix a bug on using input projection initialization bias in
nnf_multi_head_attention_forward
(#1154 @cregouby) - Bugfix: calling
$detach()
on a tensor now preserves attributes (#1136) - Make sure deep cloning of tensor and nn_module preserves class attributes and the requires_grad field. (#1129)
- Fixed that parameters and buffers of children of nn_modules were not cloned
- Cloned objects no longer reference the object from which they were cloned
- Fixed bug where nn_module's patched clone method was invalid after a call to
the internalcreate_nn_module_callable()
- Printing of
grad_fn
now appends a new line at the end. - Make sure deep cloning preserve state dict attributes. (#1129)
- Added separate setter and unsetter for the autocast context instead of only allowing
local_autocast()
. (#1142) - Fixed a bug in
torch_arange()
causing it to return 1:(n-1) values when specific requestdtype = torch_int64()
(#1160)
v0.12.0
Breaking changes
- New
torch_save
serialization format. It's ~10x faster and since it's based on safetensors, files can be read with any safetensors implementation. (#1071) - Updated to LibTorch 2.0.1. (#1085)
torch_load
no longer supportsdevice=NULL
to load weights in the same device they were saved. (#1085)- Lantern binaries and torch pre-built binaries are now built on Ubuntu 20.04. (#1124)
New features
Bug fixes
- fix printer of torch device (add new line at the end)
as.array
now moves tensors to the cpu before copying data into R. (#1080)- Fixed segfault caused by comparing a
dtype
with aNULL
. (#1090) - Fixed incorrect naming of complex data type names, such as
torch_cfloat64
. (#1091) - Fixed name of the
out_features
attribute in thenn_linear
module. (#1097) - Fixed issues when loading the state dict of optimizers and learning rate schedulers. (#1100)
- Fixed bug when cloning
nn_module
s with empty state dicts. (#1108) distr_multivariate_normal
now correctly handles precision matrix's. (#1110)- Moved
length.torch_tensor
implementation to R7 to avoid problems when a torch dataset has thetorch_tensor
class. (#1111) - Fixed problem when deep cloning a
nn_module
. (#1123)
v0.11.0
Breaking changes
load_state_dict()
for optimizers now default to cloning the tensors in the state dict, so they don't keep references to objects in the dict. (#1041)
New features
- Added
nn_utils_weight_norm
(#1025) - Added support for reading from ordered state dicts serialized with PyTorch. (#1031)
- Added
jit_ops
allowing to access JIT operators. (#1023) - Added
with_device
andlocal_device
to allow temporarily modify the default device tensors get initialized. (#1034) nnf_gelu()
andnn_gelu()
gained theapproximate
argument. (#1043)- Implemented
!=
for torch devices. (#1042) - Allows setting the dtype with a string. (#1045)
- You can now create a named list of modules using
nn_module_dict()
. (#1046) - Faster
load_state_dict()
, also using less memory. It' possible to use the legacy implementation if required, see PR. (#1051) - Export helpers for handling RNG state, and temprarily modifying it. (#1057)
- Added support for converting half tensors into R with
as.numeric()
. (#1056) - Added new
torch_tensor_from_buffer()
andbuffer_from_torch_tensor()
that allow low level creation of torch tensors. (#1061, #1062)
Documentation
- Improved documentation for LBFGS optimizer. (#1035)
- Added a message asking the user to restart the session after a manual installation with
install_torch()
. (#1055)
Bug fixes
- Fixed bug related to handling of non-persistent buffers. They would get added to the
state_dict()
even if they should not. (#1036) - Fixed a typo in the
optim_adamw
class name. - Fixed
nn_cross_entropy_loss
class name. (#1043) - Fixed bug in LBFGS w/ line search. (#1048)
- Correctly handle the installation when
RemoteSha
is a package version. (#1058)
Internal
- Started building LibLantern on macOS 11 instead of macOS12 for maximum compatibility. (#1026)
- Added
CXXSTD
to Makevars to enable C+11 compilation options. - Refactored codepath for TensorOptions and now all tensors initialization are handled by the same codepath. (#1033)
- Added internal argument
.refer_to_state_dict
to theload_state_dict()
nn_module()
method. Allows loading the state dict into the model keeping parmaters as references to that state dict. (#1036)
v0.10.0
Breaking changes
- Updated to LibTorch v1.13.1 (#977)
New features
- Provide pre-built binaries for torch using a GH Action workflow. (#975)
- Added
nn_silu()
andnnf_silu()
. (#985) - Added support for deep cloning
nn_module
s. (#986) - Added
local_no_grad()
andlocal_enable_grad()
as alternatives for thewith_
functions. (#990) - Added
optim_adamw
optimizer. (#991) - Added support for automatic mixed precision (#996)
- Added functionality to temporarily modify the torch seed. (#999)
- Support for creating torch tensors from raw vectors and back. (#1003)
Bug fixes
- Dataloaders now preserve the batch dimension when
batch_size=1
is used. (#994)
Internal
v0.9.1
Breaking changes
torch_where
now returns 1-based indices when it's called with thecondition
argument only. (#951, @skeydan)
New features
- Added support for nonABI builds on CUDA 11.6. (#919)
- The
torch_fft_fftfreq()
function is now exported. (#950, @skeydan)
Bug fixes
- Fixed bug that caused
distr_normal$sample()
not being able to generate reproducible results after setting seeds. (#938) torch_cat
error message now correctly reflects 1-based indexing. (#952, @skeydan)
Internal
- Fixed warnings in R CMD Check generated by the unsafe use of
sprintf
. (#959, @shikokuchuo) - Import, not suggest
glue
(#960)
v0.9.0
Breaking changes
- Updated to LibTorch v1.12.1. (#889, #893, #899)
torch_bincount
is now 1-based indexed. (#896)torch_movedim()
and$movedim()
are now both 1-based indexed. (#905)
New features
- Added
cuda_synchronize()
to allow synchronization of CUDA operations. (#887) - Added support for M1 Macs, including creating Tensors in the MPS device. (#890)
- Added support for CUDA 11.6 on Linux. (#902)
- Added
cuda_empty_cache()
to allow freeing memory from the caching allocator to the system. (#903) - Added
$is_sparse()
method to check wether a Tensor is sparse or not. (#903) dataset_subset
now adds a class to the modified dataset that is the same as the original dataset classes postfixed with_subset
. (#904)- Added
torch_serialize()
to allow creating a raw vector from torch objects. (#908)
Bug fixes
- Fixed bug in
torch_arange
that was causing theend
value not getting included in the result. (#885, @skeydan) - Fixed bug in window functions by setting a default dtype. (#886, @skeydan)
- Fixed bug when using
install_torch(reinstall = TRUE)
. (#883) - The
dims
argument intorch_tile()
is no longer modified, as it's not meant to be the a 1-based dimension. (#905) nn_module$state_diict()
now detaches output tensors by default. (#916)
Internal
- Re-implemented the
$
method for R7 classes in C/C++ to improve speed when calling methods. (#873) - Re-implemented garbage collection logic when calling it from inside a
backward()
call. This improves speed because we no longer need to call GC
everytime backward is called. (#873) - We now use a thread pool instead of launching a new thread for backward calls. (#883)
- Implemented options to allow configuring the activation of garbage collection when allocating more CUDA memory. (#883)
- Some
nnf_
functions have been updated to use a singletorch_
kernel instead of the custom implementation. (#896) - Improved performance of dataloaders. (#900)
- We now let LibTorch query the default generator, this allows one to use
torch_bernoulli()
withdevice="gpu"
. (#906)
v0.8.1
Breaking changes
- We now prompt the user before installing torch additional dependencies in interactive environments. This was requested by CRAN maintainers. (#864)
New features
- Dataloaders can now handle logical values. (#858, @ryan-heslin)
- We now provide builds for Pre CXX11 ABI version of LibTorch. They can be used by setting the environment variable
PRECXX11ABI=1
. This can be useful in environments with older versions of GLIBC. (#870)
Bug fixes
- Fixed the way errors are passed from dataloaders workers to the main process. Now using new rlang error chaining. (#864)
Internal
v0.8.0
Breaking changes
- Serialization is now much faster because we avoid base64 encoding the serialized tensors. As a result, files serialized with newer versions of torch can't be opened with older versions of torch. Set
options(torch.serialization_version = 1)
if you want your file to be readable by older versions. (#803) - Deprecated support for CUDA 10.2 on Windows. (#835)
linalg_matrix_rank
andlinalg_pinv
gainedatol
andrtol
arguments while deprecatingtol
andrcond
. (#835)
New features
- Improved auto-detection of CUDA version on Windows. (#798, @SvenVw)
- Improved parallel dataloaders performance by using a socket conection to transfer data between workers and the main process. (#803)
keep_graph
now defaults to the value ofcreate_graph
when calling$backward()
. We also renamed it toretain_graph
to match PyTorch. (#811)- Optimizers created with
optimizer
now carry the classname in the generator and in instances. Optimizer generators now have the classtorch_optimizer_generator
. The class of torch optimizers has been renamed fromtorch_Optimizer
totorch_optimizer
. (#814) - New utility function
nn_prune_head()
to prune top layer(s) of a network (#819 @cregouby) torch_kron()
is now exported (#818).- Added
nn_embedding_bag
. (#827, @egillax) nn_multihead_attention
now supports thebatch_first
option. (#828, @jonthegeek)- It's now possible to modify the gradient of a tensor using the syntax
x$grad <- new_grad
. (#832) sampler()
is now exported allowing to create custom samplers that can be passed todataloader()
. (#833)- Creating
nn_module
s without ainitialize
method is now supported. (#834) - Added
lr_reduce_on_plateau
learning rate scheduler. (#836, @egillax) torch_tensor(NULL)
no longer fails. It now returns a tensor with no dimensions and no data. (#839)- Improved complex numbers handling, including better printing and support for casting from and to R. (#844)
Bug fixes
- Fixed bug in weight decay handling in the Adam optimizer. (#824, @egillax)
- Fixed bug in
nn_l1_loss
. (#825, @sebffischer)
Documentation
- Nice error message when
embed_dim
is not divisible bynum_heads
innn_multihead_attention
. (#828)