@@ -111,7 +111,7 @@ def __init__(self, max_l: int, max_n: int = 5, cutoff: float = 5.0, smooth: bool
111111 self .register_buffer ("cutoff" , torch .tensor (cutoff ))
112112 self .smooth = smooth
113113 if smooth :
114- self .funcs = self ._calculate_smooth_symbolic_funcs ()
114+ self .funcs = self ._calculate_smooth_symbolic_funcs (cutoff )
115115 else :
116116 self .funcs = self ._calculate_symbolic_funcs ()
117117 # Pre-compute non-smooth basis constants once. ``roots_slice`` holds
@@ -138,13 +138,14 @@ def _calculate_symbolic_funcs(self) -> list:
138138 funcs = [sympy .expand_func (sympy .functions .special .bessel .jn (i , x )) for i in range (self .max_l + 1 )]
139139 return [sympy .lambdify (x , func , torch ) for func in funcs ]
140140
141- def _calculate_smooth_symbolic_funcs (self ) -> list :
142- # ``self.cutoff`` is a buffer whose dtype follows the ambient default;
143- # feeding the tensor into the symbolic builder makes ``cutoff**1.5``
144- # a float32 op under the default dtype, rounding the basis prefactor
145- # once and scaling every generated coefficient by 1 + 2.6e-8. The
146- # non-smooth branch already guards this with ``float(cutoff)``.
147- return _get_lambda_func (max_n = self .max_n , cutoff = float (self .cutoff ))
141+ def _calculate_smooth_symbolic_funcs (self , cutoff : float ) -> list :
142+ # Use the Python float passed to ``__init__`` rather than the
143+ # ``self.cutoff`` buffer: the buffer's dtype follows the ambient
144+ # default, so feeding it into the symbolic builder makes ``cutoff**1.5``
145+ # a float32 op, rounding the basis prefactor once and scaling every
146+ # generated coefficient by 1 + 2.6e-8. The non-smooth branch already
147+ # guards this with ``float(cutoff)``.
148+ return _get_lambda_func (max_n = self .max_n , cutoff = float (cutoff ))
148149
149150 def forward (self , r : torch .Tensor ) -> torch .Tensor :
150151 """Compute the spherical Bessel function values.
0 commit comments