Add AGENTS paper registry and backend-selectable estimation path (CPU/CUDA/MLX/OpenCL) - #51
seonghobae with Copilot wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an in-repo paper registry for traceability and introduces a backend-selectable estimation path (CPU/CUDA/MLX/OpenCL) by threading a compute_backend choice through configuration, CLI, fit execution, and result serialization.
Changes:
- Added
docs/agents_papers.mdas an in-repo registry of the AGENTS.md paper list. - Introduced
FitConfig.compute_backendplus CLI--device {cpu,cuda,mlx,opencl}, and persisted the chosen backend intoFitResultand JSON outputs. - Implemented backend-aware objective/linear predictor code paths and backend availability checks (new
python/fast_mlsirm/backend.py), with tests updated accordingly.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_fit_pipeline.py | Asserts FitResult.compute_backend is reported (CPU in smoke test). |
| tests/test_config.py | Adds validation test for invalid compute_backend values. |
| tests/test_cli.py | Exercises --device and asserts JSON payload includes compute_backend. |
| README.md | Documents backend selection and includes --device in example command. |
| python/fast_mlsirm/types.py | Extends FitResult to carry compute_backend. |
| python/fast_mlsirm/objective.py | Adds backend-aware execution paths for linear_predictor and neg_loglik_and_grad. |
| python/fast_mlsirm/io.py | Persists compute_backend into fit_summary.json. |
| python/fast_mlsirm/fit.py | Validates backend availability once per fit and threads selection through optimization. |
| python/fast_mlsirm/config.py | Adds compute_backend to FitConfig and validates allowed values. |
| python/fast_mlsirm/cli.py | Adds --device flag to relevant commands and reports backend in JSON output. |
| python/fast_mlsirm/backend.py | New module for backend normalization and availability checks. |
| pyproject.toml | Adds optional gpu extras for CUDA/MLX/OpenCL dependencies. |
| docs/agents_papers.md | New paper registry document. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def _backend_module(backend: str): | ||
| """Return the array module and a converter that materializes arrays to NumPy.""" | ||
| if backend == "cuda": | ||
| cp = importlib.import_module("cupy") | ||
| return cp, cp.asnumpy | ||
| if backend == "mlx": | ||
| mx = importlib.import_module("mlx.core") | ||
| return mx, _mlx_to_numpy | ||
| if backend == "opencl": | ||
| # OpenCL backend runs in compatibility mode (platform/device validated at fit start) | ||
| # to preserve formula parity until dedicated OpenCL kernels are added. | ||
| return np, np.asarray | ||
| return np, np.asarray |
| This repository task stores the paper set listed in `/home/runner/work/fast-mlsirm/fast-mlsirm/AGENTS.md` | ||
| for traceable model/diagnostics work. |
|
Superseded by #109. Per maintainer direction, GPU support is implemented as GPGPU inside the Rust core (wgpu, MIT/Apache-2.0) exposed as a device sub-option of the existing |
|
Closing as superseded and stale. GPU/backend half → superseded by #109. Per maintainer direction (see the note already on this PR), GPU support is being implemented as GPGPU inside the Rust core (wgpu, MIT/Apache-2.0) exposed as a device sub-option of the existing Paper-registry half → already in-repo. The full AGENTS.md reference list (Kang & Jeon 2025, Jeon et al. 2021, Molenaar & Jeon 2026, etc., with DOIs) already lives in No unique un-merged value remains. Tracking GPU work in #109. |
This PR addresses two requests: persist the AGENTS.md paper set in-repo, and extend the current estimation workflow with selectable GPU-capable backends while preserving the existing simple-structure MLS2PLM contract. It introduces backend-aware execution wiring for supported models/optimizers and CLI-level device selection.
Paper registry (AGENTS.md traceability)
docs/agents_papers.mdwith the full AGENTS.md reference list and DOI links.Backend selection in fit configuration
compute_backendtoFitConfigwith allowed values:cpu,cuda,mlx,opencl.python/fast_mlsirm/backend.py:cupymlx.corepyopencland platform presenceBackend-aware estimation/objective plumbing
fit()and objective evaluation (neg_loglik_and_grad,linear_predictorpaths).FitResultnow carriescompute_backend; fit summary serialization includes it.CLI/API surface updates
--device {cpu,cuda,mlx,opencl}to:fast-mlsirm fitfast-mlsirm diagnose-dimensionsDependency metadata and coverage updates
gpuextras inpyproject.tomlfor CUDA/MLX/OpenCL ecosystems.