Metadata-Version: 2.4
Name: nlsq
Version: 0.8.1
Summary: GPU/TPU accelerated nonlinear least-squares curve fitting using JAX
Author: Lucas Hofer (Original JAXFit), Milan Krstajić (Original JAXFit), Robert P. Smith (Original JAXFit)
Author-email: Wei Chen <wchen@anl.gov>
Maintainer-email: Wei Chen <wchen@anl.gov>
License-Expression: MIT
Project-URL: Homepage, https://github.com/imewei/NLSQ
Project-URL: Documentation, https://nlsq.readthedocs.io
Project-URL: Repository, https://github.com/imewei/NLSQ.git
Project-URL: Issues, https://github.com/imewei/NLSQ/issues
Project-URL: Changelog, https://github.com/imewei/NLSQ/blob/main/CHANGELOG.md
Keywords: curve-fitting,optimization,least-squares,jax,gpu,tpu,scientific-computing,machine-learning
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=2.2
Requires-Dist: scipy>=1.16.0
Requires-Dist: jax>=0.8.0
Requires-Dist: jaxlib>=0.8.0
Requires-Dist: optax>=0.2.6
Requires-Dist: matplotlib>=3.10.0
Requires-Dist: psutil>=7.2.0
Requires-Dist: tqdm>=4.67.0
Requires-Dist: h5py>=3.15.0
Requires-Dist: xxhash>=3.6.0
Requires-Dist: pyyaml>=6.0.3
Requires-Dist: evosax>=0.2.0
Provides-Extra: gui
Requires-Dist: PySide6>=6.10.0; extra == "gui"
Requires-Dist: pyqtgraph>=0.14.0; extra == "gui"
Provides-Extra: gpu-cuda13
Requires-Dist: jax-cuda13-plugin>=0.8.0; extra == "gpu-cuda13"
Requires-Dist: jax-cuda13-pjrt>=0.8.0; extra == "gpu-cuda13"
Provides-Extra: gpu-cuda12
Requires-Dist: jax-cuda12-plugin>=0.8.0; extra == "gpu-cuda12"
Requires-Dist: jax-cuda12-pjrt>=0.8.0; extra == "gpu-cuda12"
Dynamic: license-file

<div align="center">
<img src="https://raw.githubusercontent.com/imewei/NLSQ/main/docs/_static/NLSQ_logo.png" alt="NLSQ logo" width="400">

# NLSQ: GPU-Accelerated Curve Fitting

**Drop-in replacement for `scipy.optimize.curve_fit`, built on JAX for CPU and GPU, with fits to 100M+ points**

[![PyPI version](https://badge.fury.io/py/nlsq.svg)](https://badge.fury.io/py/nlsq)
[![Documentation](https://readthedocs.org/projects/nlsq/badge/?version=latest)](https://nlsq.readthedocs.io/)
[![Python 3.12+](https://img.shields.io/badge/python-3.12+-blue.svg)](https://www.python.org/downloads/)
[![JAX ≥0.8.0](https://img.shields.io/badge/JAX-≥0.8.0-green.svg)](https://github.com/google/jax)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

[**Documentation**](https://nlsq.readthedocs.io/) | [**Examples**](examples/) | [**API Reference**](https://nlsq.readthedocs.io/en/latest/api/index.html) | [**ArXiv Paper**](https://doi.org/10.48550/arXiv.2208.12187)

</div>

---

## What is NLSQ?

NLSQ is a nonlinear least squares curve fitting library built on [JAX](https://github.com/google/jax). It provides:

- **SciPy-compatible API** - Same function signatures as `scipy.optimize.curve_fit`
- **GPU/TPU acceleration** - JIT-compiled kernels via XLA
- **Automatic differentiation** - No manual Jacobian calculations needed
- **Large dataset support** - Handles 100M+ data points with streaming optimization
- **Interactive GUI** - Native Qt desktop application for no-code curve fitting

## Installation

### Basic Installation (CPU-only)

```bash
pip install nlsq
```

This installs the core library with CPU-only JAX (works on all platforms: Linux, macOS, Windows).

### Conda Installation

```bash
conda install -c imewei -c conda-forge nlsq
```

Package published at [anaconda.org/imewei/nlsq](https://anaconda.org/imewei/nlsq).

### GPU Installation (Linux + System CUDA)

**Performance Impact:** for NLSQ itself, the GPU was slower than the CPU up to 10K points and 4.9-20.7x faster from 1M to 100M points; see [Performance](#performance)

**Prerequisites:**
- NVIDIA GPU with SM >= 5.2 (Maxwell or newer)
- System CUDA 12.x or 13.x installed
- `nvcc` in PATH

<details>
<summary><b>Verify Prerequisites</b></summary>

```bash
# Check CUDA installation
nvcc --version
# Should show: Cuda compilation tools, release 12.x or 13.x

# Check GPU
nvidia-smi --query-gpu=name,compute_cap --format=csv,noheader
# Should show: GPU name and SM version (e.g., "8.9" for RTX 4090)
```

</details>

#### Option 1: Quick Install via Makefile (Recommended)

```bash
git clone https://github.com/imewei/NLSQ.git
cd NLSQ

# Auto-detect system CUDA version and install matching JAX
make install-jax-gpu

# Or explicitly choose CUDA version:
make install-jax-gpu-cuda13  # Requires system CUDA 13.x + SM >= 7.5
make install-jax-gpu-cuda12  # Requires system CUDA 12.x + SM >= 5.2
```

#### Option 2: Manual Installation

```bash
# For System CUDA 13.x (Turing and newer GPUs):
pip uninstall -y jax jaxlib
pip install "jax[cuda13-local]"

# For System CUDA 12.x (Maxwell and newer GPUs):
pip uninstall -y jax jaxlib
pip install "jax[cuda12-local]"

# Verify
python -c "import jax; print('Backend:', jax.default_backend())"
# Should show: Backend: gpu
```

<details>
<summary><b>GPU Compatibility Guide</b></summary>

| GPU Generation | Example GPUs | SM Version | CUDA 13 | CUDA 12 |
|----------------|--------------|------------|---------|---------|
| Blackwell | B100, B200 | 10.0 | Yes | Yes |
| Hopper | H100, H200 | 9.0 | Yes | Yes |
| Ada Lovelace | RTX 40xx, L40 | 8.9 | Yes | Yes |
| Ampere | RTX 30xx, A100 | 8.x | Yes | Yes |
| Turing | RTX 20xx, T4 | 7.5 | Yes | Yes |
| Volta | V100, Titan V | 7.0 | No | Yes |
| Pascal | GTX 10xx, P100 | 6.x | No | Yes |
| Maxwell | GTX 9xx, Titan X | 5.x | No | Yes |
| Kepler | GTX 7xx, K80 | 3.x | No | No |

**Recommendation:** SM >= 7.5 (RTX 20xx or newer): Install CUDA 13 for best performance

</details>

<details>
<summary><b>GPU Troubleshooting</b></summary>

**Issue: "nvcc not found"**
```bash
# Option 1: Install CUDA toolkit
sudo apt install nvidia-cuda-toolkit  # Ubuntu/Debian

# Option 2: Add existing CUDA to PATH
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
```

**Issue: "CUDA version mismatch"**
```bash
# Check your system CUDA version
nvcc --version

# Reinstall with correct package
pip uninstall -y jax jaxlib
pip install "jax[cuda12-local]"  # or cuda13-local
```

</details>

### With GUI Support

The desktop application (PySide6, pyqtgraph) is an optional extra; `pip install nlsq` installs the core library only:

```bash
pip install "nlsq[gui]"
nlsq-gui            # Launch the desktop application
```

## Quick Start

```python
import numpy as np
import jax.numpy as jnp
from nlsq import curve_fit


# Define model function (use jax.numpy for GPU acceleration)
def exponential(x, a, b, c):
    return a * jnp.exp(-b * x) + c


# Generate data
x = np.linspace(0, 4, 1000)
y = 2.5 * np.exp(-0.5 * x) + 1.0 + 0.1 * np.random.randn(len(x))

# Fit - same API as scipy.optimize.curve_fit
popt, pcov = curve_fit(exponential, x, y, p0=[2.0, 0.5, 1.0])

print(f"Parameters: a={popt[0]:.3f}, b={popt[1]:.3f}, c={popt[2]:.3f}")
print(f"Uncertainties: {np.sqrt(np.diag(pcov))}")
```

## Graphical User Interface

NLSQ includes an interactive GUI for curve fitting without writing code. Install the `gui` extra and
launch it as shown under [With GUI Support](#with-gui-support) (`nlsq-gui` or `nlsq gui`). It provides:
- **Data Loading**: Import CSV, ASCII, NPZ, or HDF5 files, or paste from clipboard
- **Model Selection**: Choose from 8 built-in models, polynomials, or custom Python functions
- **Fitting Options**: Guided presets (Fast/Robust/Quality) or advanced parameter control
- **Interactive Results**: GPU-accelerated pyqtgraph plots with confidence bands and residuals
- **Export**: Session bundles (ZIP), JSON/CSV results, and reproducible Python code

See the [GUI User Guide](https://nlsq.readthedocs.io/en/latest/gui/index.html) for detailed documentation.

## Key Features

| Feature | Description |
|---------|-------------|
| **Automatic Jacobians** | JAX's autodiff eliminates manual derivatives |
| **Bounded optimization** | Trust Region Reflective; exact Levenberg-Marquardt for full-data streaming fits |
| **Large datasets** | `curve_fit_large` runs an exact full-data streaming fit by default from 1M points (100M+ supported); chunked and hybrid streaming fits via `strategy=` |
| **Multi-start** | Global optimization with LHS/Sobol sampling |
| **Workflow system** | 3 smart workflows: `auto`, `auto_global`, `hpc` with memory-aware strategy |
| **CLI interface** | YAML-based workflows with `nlsq fit` and `nlsq batch` |
| **Interactive GUI** | No-code curve fitting with Qt desktop application |
| **Model Diagnostics** | Identifiability analysis, gradient health monitoring, sloppy model detection |

## Architecture

NLSQ is organized into well-separated layers (~83,400 lines):

```
┌─────────────────────────────────────────────────────────────────────────────┐
│                               USER INTERFACES                               │
├─────────────────────────────────────────────────────────────────────────────┤
│ Qt GUI (nlsq[gui] extra)  CLI (argparse)             Python API             │
│ ├── 5-page workflow       ├── fit, batch, info       ├── curve_fit(), fit() │
│ └── pyqtgraph plots       └── config, gui            └── curve_fit_large()  │
├─────────────────────────────────────────────────────────────────────────────┤
│                           ENTRY POINTS AND ROUTING                          │
├─────────────────────────────────────────────────────────────────────────────┤
│ fit(workflow=auto|auto_global|hpc) curve_fit_large(strategy=Auto)           │
│ └── MemoryBudgetSelector:          ├── < size_threshold: in memory          │
│     standard / chunked / streaming ├── ≥ size_threshold: exact LM (default) │
│                                    └── Chunked / Hybrid on request          │
├─────────────────────────────────────────────────────────────────────────────┤
│                             OPTIMIZATION ENGINES                            │
├─────────────────────────────────────────────────────────────────────────────┤
│ Global optimization        Exact streaming LM      Hybrid (opt-in)          │
│ ├── CMAESOptimizer         ├── exact_lm.py         ├── 0: Normalization     │
│ ├── MultiStartOrchestrator └── J^T J, J^T r over   ├── 1: L-BFGS warmup     │
│ ├── TournamentSelector         data chunks         ├── 2: Gauss-Newton      │
│ └── LHS/Sobol/Halton                               └── 3: Denormalization   │
├─────────────────────────────────────────────────────────────────────────────┤
│                           CORE OPTIMIZATION ENGINE                          │
├─────────────────────────────────────────────────────────────────────────────┤
│ curve_fit() ─→ CurveFit ─→ prepare_problem() ─→ LeastSquares                │
│   ─→ TrustRegionReflective (Python loop over JIT kernels) ─→ pcov           │
├─────────────────────────────────────────────────────────────────────────────┤
│                              SUPPORT SUBSYSTEMS                             │
├─────────────────────────────────────────────────────────────────────────────┤
│ stability/                         precision/                               │
│ ├── NumericalStabilityGuard        ├── AlgorithmSelector                    │
│ ├── SVD fallback, recovery         ├── BoundsInference, ParameterNormalizer │
│ └── FallbackOrchestrator           └── parameter estimation                 │
│ caching/                           diagnostics/                             │
│ ├── UnifiedCache                   ├── IdentifiabilityAnalyzer              │
│ └── MemoryManager                  ├── GradientMonitor, ModelHealthReport   │
│                                    └── PluginRegistry                       │
├─────────────────────────────────────────────────────────────────────────────┤
│                                INFRASTRUCTURE                               │
├─────────────────────────────────────────────────────────────────────────────┤
│ config.py (singleton)              Security                                 │
│ ├── JAXConfig, MemoryConfig        ├── safe_serialize, model_validation     │
│ └── LargeDatasetConfig             └── resource limits, audit log           │
├─────────────────────────────────────────────────────────────────────────────┤
│                            JAX RUNTIME (>=0.8.0)                            │
│ x64 enabled │ JIT compilation │ Autodiff │ CPU, GPU or TPU backend          │
└─────────────────────────────────────────────────────────────────────────────┘
```

See [Architecture Documentation](https://nlsq.readthedocs.io/en/latest/developer/architecture.html) for detailed design.

## Performance

Every comparison below is made on one device: CPU results against CPU results, GPU results against GPU results.
SciPy and lmfit have no GPU path, so they appear only in the CPU table. Times are warm medians of end-to-end fits
of a 3-parameter exponential decay (`a*exp(-b*x) + c`), measured once on an Intel i9-13900H and an
NVIDIA RTX 4090 Laptop GPU, with all libraries at a tolerance of 1e-8. SciPy ran `method="trf"` (its faster default `lm` is covered below) and lmfit ran MINPACK `leastsq`; stopping rules differ between libraries. **Bold** marks the fastest entry in a row.
`curve_fit_large` runs exact full-data streaming at and above 1M points; `—` means not run at that size.

### CPU

| Points | SciPy (`trf`) | lmfit | NLSQ `curve_fit` | NLSQ `curve_fit_large` | JAXopt | Optimistix |
|---|---|---|---|---|---|---|
| 1,000 | 1.1 ms | 4.6 ms | 4.0 ms | — | **0.4 ms** | 0.5 ms |
| 10,000 | 3.9 ms | 3.8 ms | 11.8 ms | — | **1.4 ms** | 3.8 ms |
| 100,000 | 111.2 ms | 24.5 ms | 44.4 ms | — | **8.6 ms** | 19.3 ms |
| 1,000,000 | 1.14 s | 464.0 ms | 362.3 ms | 90.8 ms | **82.8 ms** | 159.7 ms |
| 10,000,000 | 5.26 s | 4.45 s | — | 977.2 ms | **945.4 ms** | 2.25 s |
| 100,000,000 | 65.94 s | 53.46 s | — | **6.08 s** | 7.70 s | 12.91 s |

### GPU

| Points | NLSQ `curve_fit` | NLSQ `curve_fit_large` | JAXopt | Optimistix |
|---|---|---|---|---|
| 1,000 | 24.8 ms | — | **2.0 ms** | 3.0 ms |
| 10,000 | 30.9 ms | — | 5.0 ms | **3.9 ms** |
| 100,000 | 48.0 ms | — | **4.1 ms** | 11.1 ms |
| 1,000,000 | 140.5 ms | 18.5 ms | **11.6 ms** | 62.6 ms |
| 10,000,000 | — | 78.1 ms | **77.3 ms** | 657.0 ms |
| 100,000,000 | — | **618.1 ms** | 801.0 ms | fails |

### What the numbers show

- **CPU, versus SciPy and lmfit:** SciPy (`method="trf"`) was faster than NLSQ up to 10K points. NLSQ was 2.5x faster at 100K points
  and 5-13x faster from 1M to 100M points on this model. Across four models the range from 1M points up is
  2.4-12.6x versus SciPy and 1.4-10.8x versus lmfit.
- **SciPy's default method:** the table above uses SciPy `trf`. In a separate spot check on this model, SciPy's
  default `lm` was faster than NLSQ `curve_fit` from 1K to 1M points (3.0x at 100K, 1.8x at 1M) and slower than
  `curve_fit_large` at 1M points (2.3x) and 10M points (4.2x); see
  [`benchmarks/baselines/2026-11-14-scipy-lm-spot-check.md`](benchmarks/baselines/2026-11-14-scipy-lm-spot-check.md).
- **JAXopt and Optimistix:** both were faster than NLSQ on small problems, on CPU and GPU. JAXopt stayed
  faster or level through 10M points on this model. NLSQ was faster at 100M points (1.3-1.9x on GPU, across
  three models). NLSQ was 1.8-14.7x faster than Optimistix from 1M points, and Optimistix fails on GPU at 100M points.
- **NLSQ on its own CPU versus its own GPU:** the GPU was slower below 100K points and 4.9-20.7x faster from
  1M points (across four models, `curve_fit_large`).
- **Not like for like:** JAXopt and Optimistix return no covariance matrix and do not support bounds; NLSQ
  supports bounds and returns a covariance matrix. NLSQ's case is the SciPy-compatible interface, bounds, and fits to datasets that do not fit in memory,
  not the fastest time on small problems.

> **Caveats.** One run on a laptop whose load average was 10-30 during the run; treat differences under about
> 25% as ties and compare entries within one table only. First-call compilation is not included (the persistent
> JAX cache at `~/.cache/nlsq/jax_cache` reduces it on later runs). The full tables for four models,
> methodology, limitations and reproduction commands are in
> [Performance Benchmarks](https://nlsq.readthedocs.io/en/latest/api/performance_benchmarks.html) and in
> [`benchmarks/baselines/2026-11-13-library-comparison-1k-100M.md`](benchmarks/baselines/2026-11-13-library-comparison-1k-100M.md).

See the [Performance Optimization guide](https://nlsq.readthedocs.io/en/latest/howto/optimize_performance.html) for tuning advice.

## Large Dataset Example

```python
from nlsq import fit
import numpy as np
import jax.numpy as jnp


def model(x, a, b, c):
    return a * jnp.exp(-b * x) + c


# 50 million points
x = np.linspace(0, 10, 50_000_000)
y = 2.0 * np.exp(-0.5 * x) + 0.3 + np.random.normal(0, 0.05, len(x))

# Auto-selects optimal strategy (chunked/streaming) based on memory
popt, pcov = fit(model, x, y, p0=[2.5, 0.6, 0.2], show_progress=True)
```

## Advanced Usage

<details>
<summary><b>Multi-start global optimization</b></summary>

```python
from nlsq import curve_fit

popt, pcov = curve_fit(
    model,
    x,
    y,
    p0=[1, 1, 1],
    bounds=([0, 0, 0], [10, 5, 10]),
    multistart=True,
    n_starts=20,
    sampler="lhs",
)
```

</details>

<details>
<summary><b>CMA-ES global optimization</b></summary>

For multi-scale parameter problems (parameters spanning >1000x scale ratio):

```python
from nlsq.global_optimization import CMAESOptimizer, CMAESConfig

# Basic usage with BIPOP restart strategy
optimizer = CMAESOptimizer()
result = optimizer.fit(model, x, y, bounds=bounds)

# Memory-efficient configuration for large datasets (>10M points)
config = CMAESConfig(
    population_batch_size=4,  # Batch population evaluation
    data_chunk_size=50000,  # Stream data in chunks
)
optimizer = CMAESOptimizer(config=config)
```

</details>

<details>
<summary><b>Workflows</b></summary>

`fit()` offers three workflows:

```python
from nlsq import fit

# workflow="auto" (default) - memory-aware local optimization
result = fit(model, x, y, p0=[1, 1, 1])

# workflow="auto_global" - memory-aware global optimization (requires bounds)
result = fit(
    model, x, y, p0=[1, 1, 1], workflow="auto_global", bounds=([0, 0, 0], [10, 5, 10])
)

# workflow="hpc" - auto_global plus cluster detection that is logged for diagnostics
# (reads $PBS_NODEFILE, else counts local GPUs; it does not change the fit)
result = fit(model, x, y, p0=[1, 1, 1], workflow="hpc", bounds=([0, 0, 0], [10, 5, 10]))

# hpc + checkpoint/resume needs the CMA-ES route explicitly, plus run_id/model_id/seed
# result = fit(..., workflow="hpc", method="cmaes", cmaes_config=CMAESConfig(restart_strategy="none"),
#              checkpoint_dir="/scratch/checkpoints", run_id="exp-42", model_id="exp_decay_v1", seed=42)
```

| Workflow | Bounds | Use Case |
|----------|--------|----------|
| `auto` | Optional | Default. Local optimization with auto memory strategy |
| `auto_global` | Required | Multi-modal problems, unknown initial guess |
| `hpc` | Required | Long-running HPC jobs; CMA-ES route supports checkpoint/resume ([docs](docs/tutorials/routine/three_workflows/hpc_workflow.rst)) |

</details>

<details>
<summary><b>Memory-based strategy selection</b></summary>

```python
from nlsq.core.workflow import MemoryBudget, MemoryBudgetSelector

# Compute memory budget for your dataset
budget = MemoryBudget.compute(n_points=10_000_000, n_params=10)
print(f"Peak memory: {budget.peak_gb:.2f} GB")
print(f"Fits in memory: {budget.fits_in_memory}")

# Let selector choose strategy
selector = MemoryBudgetSelector(safety_factor=0.75)
strategy, config = selector.select(
    n_points=10_000_000,
    n_params=10,
    memory_limit_gb=16.0,  # Optional override
)
print(f"Selected: {strategy}")  # "streaming", "chunked", or "standard"
```

</details>

<details>
<summary><b>Numerical stability</b></summary>

```python
from nlsq import curve_fit

# Auto-detect and fix numerical issues
popt, pcov = curve_fit(model, x, y, p0=p0, stability="auto")
```

</details>

<details>
<summary><b>Memory management</b></summary>

```python
from nlsq import MemoryConfig, memory_context, CurveFit

config = MemoryConfig(memory_limit_gb=8.0)

with memory_context(config):
    cf = CurveFit()
    popt, pcov = cf.curve_fit(model, x, y, p0=p0)
```

</details>

<details>
<summary><b>Command-line interface</b></summary>

```bash
# Launch GUI
nlsq gui

# Copy configuration templates
nlsq config

# Single workflow
nlsq fit experiment.yaml

# Output results to stdout (for piping)
nlsq fit experiment.yaml --stdout | jq '.popt'

# Batch processing
nlsq batch configs/*.yaml --summary results.json --workers 4

# System info
nlsq info
```

See [CLI Reference](https://nlsq.readthedocs.io/en/latest/reference/cli.html) for full documentation.

</details>

<details>
<summary><b>Model health diagnostics</b></summary>

```python
from nlsq.diagnostics import (
    DiagnosticsConfig,
    IdentifiabilityAnalyzer,
    GradientMonitor,
    ParameterSensitivityAnalyzer,
    create_health_report,
)

# Analyze parameter identifiability from Jacobian
config = DiagnosticsConfig(condition_threshold=1e8, correlation_threshold=0.95)
analyzer = IdentifiabilityAnalyzer(config)
report = analyzer.analyze(result.jac)

print(f"Condition number: {report.condition_number:.2e}")
print(f"Numerical rank: {report.numerical_rank}/{report.n_params}")

# Monitor gradient health during optimization
monitor = GradientMonitor(config)
callback = monitor.create_callback()
result = curve_fit(model, x, y, p0=p0, callback=callback)
grad_report = monitor.get_report()

# Analyze parameter sensitivity spectrum
sensitivity_analyzer = ParameterSensitivityAnalyzer(config)
sensitivity_report = sensitivity_analyzer.analyze(result.jac)
print(f"Is sloppy: {sensitivity_report.is_sloppy}")
print(f"Effective dimensionality: {sensitivity_report.effective_dimensionality:.1f}")

# Create aggregated health report
health_report = create_health_report(
    identifiability=report,
    gradient_health=grad_report,
    sloppy_model=sensitivity_report,
)
print(health_report.summary())
```

See [Diagnostics API](https://nlsq.readthedocs.io/en/latest/api/nlsq.diagnostics.html) for complete documentation.

</details>

See [Advanced User Guide](https://nlsq.readthedocs.io/en/latest/advanced_guide.html) for complete documentation.

## Examples

Start with the [Interactive Tutorial](https://colab.research.google.com/github/imewei/NLSQ/blob/main/examples/notebooks/01_getting_started/nlsq_interactive_tutorial.ipynb) on Google Colab.

**By topic:**
- [Getting Started](examples/notebooks/01_getting_started/) - Basic usage and quickstart
- [Core Tutorials](examples/notebooks/02_core_tutorials/) - Large datasets, bounded optimization
- [Advanced](examples/notebooks/03_advanced/) - GPU optimization, streaming, checkpointing
- [Applications](examples/notebooks/09_gallery_advanced/) - Physics, chemistry, biology, engineering

See [examples/README.md](examples/README.md) for the full index.

## Requirements

- Python 3.12+
- JAX 0.8.0+
- NumPy 2.2+
- SciPy 1.16.0+

**GUI requirements**: PySide6 6.10.0+, pyqtgraph 0.14.0+

**GPU support** (Linux only): CUDA 12.x-13.x, NVIDIA driver >= 525

## Citation

If you use NLSQ in your research, please cite:

```bibtex
@software{nlsq2025,
  title={NLSQ: Nonlinear Least Squares Curve Fitting for GPU/TPU},
  author={Chen, Wei and Hofer, Lucas R and Krstaji{\'c}, Milan and Smith, Robert P},
  year={2025},
  url={https://gitlab.osti.gov/wchen/nlsq}
}

@article{jaxfit2022,
  title={JAXFit: Trust Region Method for Nonlinear Least-Squares Curve Fitting on the {GPU}},
  author={Hofer, Lucas R and Krstaji{\'c}, Milan and Smith, Robert P},
  journal={arXiv preprint arXiv:2208.12187},
  year={2022}
}
```

## Acknowledgments

NLSQ is an enhanced fork of [JAXFit](https://github.com/Dipolar-Quantum-Gases/JAXFit) by Lucas R. Hofer, Milan Krstajic, and Robert P. Smith. We gratefully acknowledge their foundational work.

## License

MIT License - see [LICENSE](LICENSE) for details.
