semsynth.torch_compat
Compatibility helpers for optional PyTorch features.
Functions
Patch |
|
Ensure torch.nn exposes RMSNorm on versions that predate it. |
|
Ensure numpy and scipy expose |
- semsynth.torch_compat.ensure_npsum_compat() None
Patch
numpy.sumso it accepts generators (removed in NumPy ≥ 2).Synthcity’s ctgan plugin calls
np.sum(some_generator)which raises aTypeErrorunder NumPy 2. Wrappingnp.sumto materialise generators vialist()before delegation preserves the original behaviour.
- semsynth.torch_compat.ensure_torch_rmsnorm() None
Ensure torch.nn exposes RMSNorm on versions that predate it.
- semsynth.torch_compat.ensure_trapz_compat() None
Ensure numpy and scipy expose
trapz(renamed totrapezoidin newer versions).Some optional dependencies (e.g. xgbse used by synthcity) import
numpy.trapzandscipy.integrate.trapzwhich were removed in NumPy ≥ 2 / SciPy ≥ 1.14.