Hi,
I'm trying to build a simple demagnification (100x e.g.) but the system is trying to allocate sth like 130 G in the conv2d_fft function. That seems too high for what it does?
import torchoptics as tp
from torchoptics import SpatialCoherence
from torchoptics.profiles import gaussian_schell_model
spacing = 10e-6
wavelength = 460e-9
tp.set_default_spacing(spacing)
tp.set_default_wavelength(wavelength)
low_coh = SpatialCoherence(
gaussian_schell_model(10, waist_radius=5e-3, coherence_width=10e-6)
)
f1 = 0.2
f2 = 0.004
system = tp.System(
tp.elements.AmplitudeModulator(tp.profiles.checkerboard(100, tile_length=100e-6, num_tiles=2), z=0),
tp.elements.Lens(800, f1, z=f1),
# aperture
# tp.elements.AmplitudeModulator(circle(1_000, radius=1e-3), z=2 * f1),
tp.elements.Lens(800, f2, z=2 * f1 + f2),
)
measurements = [
system.measure_at_z(low_coh, z=i) for i in [0, f1, 2 * f1, 2 * f1 + f2, 2 * f1 + 2 * f2]
]
backtrace:
File "/nix/store/5i6ki0hphgyv2iclwnix70yww70jr2ci-python3-3.13.12-env/lib/python3.13/site-packages/torchoptics/functional/functional.py", line 109, in wrapper
evolved = evolution_func(field, *args, **kwargs)
File "/nix/store/5i6ki0hphgyv2iclwnix70yww70jr2ci-python3-3.13.12-env/lib/python3.13/site-packages/torchoptics/fields.py", line 102, in propagate
return propagator(self, shape, z, spacing, offset, propagation_method, asm_pad, interpolation_mode)
File "/nix/store/5i6ki0hphgyv2iclwnix70yww70jr2ci-python3-3.13.12-env/lib/python3.13/site-packages/torchoptics/propagation/propagator.py", line 81, in propagator
field = dim_propagation(field, propagation_plane, propagation_method)
File "/nix/store/5i6ki0hphgyv2iclwnix70yww70jr2ci-python3-3.13.12-env/lib/python3.13/site-packages/torchoptics/propagation/direct_integration_method.py", line 32, in dim_propagation
propagated_data = conv2d_fft(impulse_response, field.data, fft_padding=1)
File "/nix/store/5i6ki0hphgyv2iclwnix70yww70jr2ci-python3-3.13.12-env/lib/python3.13/site-packages/torchoptics/functional/functional.py", line 65, in conv2d_fft
weight_fr = fft2(weight.flip(-1, -2).conj(), s=fft_size)
RuntimeError: [enforce fail at alloc_cpu.cpp:124] err == 0. DefaultCPUAllocator: can't allocate memory: you tried to allocate 129600000000 bytes. Error code 12 (Cannot allocate memory)
Hi,
I'm trying to build a simple demagnification (100x e.g.) but the system is trying to allocate sth like 130 G in the
conv2d_fftfunction. That seems too high for what it does?backtrace: