Troubleshooting¶
Common issues and solutions.
ImportError after Installation¶
Problem: Cannot import gp4c after running pip install.
Solution: Rebuild the Cython extension:
Or reinstall:
Cholesky Decomposition Failed¶
Problem: Error message like "Cholesky decomposition failed" or "Matrix not positive definite".
Causes:
- Very small length scales
- Duplicate or very close evaluation points
- Numerical precision issues
Solutions:
Increase Jitter¶
Edit gp4c/_sampler.c and increase jitter:
Rebuild:
Use Larger Length Scale¶
# Instead of
result = sample_prior(spec, ell=0.05) # Too small
# Use
result = sample_prior(spec, ell=0.2) # Better
Check Evaluation Points¶
Ensure points are not duplicated:
Numerical Issues with Derivatives¶
Problem: Unstable or extreme values in derivative samples.
Explanation: Derivative kernel has variance \(O(1/\ell^2)\):
- Small \(\ell\) → Very large derivative variance
- Can exceed numerical precision
Solutions:
Use Larger Length Scale¶
Increase Derivative Jitter¶
The implementation uses higher jitter (1e-6) for derivative blocks. If still unstable, increase further in _sampler.c.
Avoid Boundaries¶
Sample derivatives at interior points:
x = np.linspace(0, 5, 100)
x_interior = x[5:-5] # Drop boundary points
spec = SamplingSpec(x_f=x, x_h=x_interior)
GSL Not Found¶
Problem: Installation fails with "GSL not found".
Solution: Install GSL first:
Slow Performance¶
Problem: Sampling takes too long.
Solutions:
- Use coarser grids - Especially for integrals
- Sample only what you need - Skip unused quantities
- Batch samples - Generate multiple samples in one call
- Larger length scales - Reduces required grid resolution
See Performance Guide for details.
Memory Issues¶
Problem: Out of memory for large grids.
Solution: Memory usage is \(O(n^2)\) for covariance matrix.
For grid size \(n > 1000\):
- Use coarser grids where possible
- Split problem into smaller regions
- Consider sparse/low-rank approximations
Posterior Doesn't Interpolate¶
Problem: Posterior mean doesn't pass through training points.
Causes:
- High observation noise
- Poor length scale choice
- Mismatched observation locations
Solutions:
Reduce Noise¶
# Instead of
obs = Observations(x_f=x_train, y_f=y_train, noise_f=0.1)
# Use
obs = Observations(x_f=x_train, y_f=y_train, noise_f=0.001)
Tune Length Scale¶
Try different values:
for ell in [0.5, 1.0, 2.0]:
result = sample_posterior(obs, spec, ell=ell, n_samples=5)
# Evaluate fit quality
Verify Observation Points¶
# Check observations are in prediction range
assert np.all(obs.x_f >= spec.x_f.min())
assert np.all(obs.x_f <= spec.x_f.max())
Build Errors on Windows¶
Problem: Compilation fails on Windows.
Solution: gp4c is primarily tested on Linux/macOS. For Windows:
- Use WSL (Windows Subsystem for Linux)
- Install GSL via vcpkg
- Use MinGW with GSL
Or use pre-built Docker container (if available).
Reproducibility Issues¶
Problem: Different results with same seed.
Causes:
- Different NumPy/GSL versions
- Floating point operations depend on BLAS backend
- Platform differences
Solutions:
- Pin package versions
- Use same BLAS library
- Accept small numerical differences (\(< 10^{-10}\))
Getting Help¶
If issues persist:
- Check GitHub Issues
- Provide minimal reproducible example
- Include versions:
pip list | grep -E 'gp4c|numpy|scipy' - Include platform:
uname -a(Linux/macOS) orver(Windows)
Next Steps¶
- Testing Guide - Validate installation
- Performance Tips - Optimization
- Contributing - Report bugs