Different behaviour for NSF between versions
bug
### Description
I'm observing different outputs between `v1.5.0` and `v.1.4.1` for the same inputs when using models (such as `flows.NSF`) that use `AutoregressiveTransform` internally. When using these models, our rough evaluation sequence is to transform to latent space, flip a boolean context value and then transform back in order to map from one context (simulation) to another (real data). Due to a change in the default value of the `slope` parameter [here](https://github.com/probabilists/zuko/compare/1.4.1...1.5.0#diff-ebd6c72181891f49eb19248d9a7a211dd76012e45796d35cd8348c12941aaef8L442), the results differ between the two versions. The `slope` parameter doesn't appear to be exposed to the user, so currently our solution to use older models with newer versions of `zuko` is to pin the package to the version used in training.
As this is somewhat brittle and would prevent future updates, would it be possible to make such options available to the user?
### Reproduce
```python
import torch
import zuko
print(f"zuko v{zuko.__version__}")
FLIP_CONDITIONAL = True
flow = zuko.flows.NSF(features=2, context=2, transforms=1)
flow = flow.type(torch.float64)
x = torch.tensor([[1., 2.]], dtype=torch.float64)
c = torch.tensor([[1., 0.]], dtype=torch.float64)
transform = flow(c).transform
with torch.no_grad():
# To latent space
y = transform(x)
# Flip condition
c2 = c.clone()
if FLIP_CONDITIONAL:
c2[:, -1] = 1.0 - c2[:, -1]
# Back to data space
transform2 = flow(c2).transform
x_back = transform2.inv(y)
print(f"x: {x}")
print(f"y = transform(x): {y}")
print(f"c: {c}")
print(f"c2 (used for inverse): {c2}")
print(f"x_back = transform.inv(y): {x_back}") # Different values between v1.4.1 and v.1.5.0
```
### Expected behavior
Consistent behaviour between to versions differing only in their `MINOR` versions, as in https://semver.org/
### Causes and solution
Change to the default value of `slope` [here](https://github.com/probabilists/zuko/compare/1.4.1...1.5.0#diff-ebd6c72181891f49eb19248d9a7a211dd76012e45796d35cd8348c12941aaef8L442). When creating a `flows.NSF` object, this parameter isn't exposed to the user so the value is effectively hardcoded.
### Environment
* Zuko version: 1.4.1 and 1.5.0
* PyTorch version: 2.10.0+cu128
* Python version: 3.12.12
* OS: Observed on Fedora 43, Rocky 9.7, RHEL 9.7
1 条评论