feat(api): explicit distributed-backend selection (MDLABackend / IGGBackend), mirroring AbstractJVPBackend
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Tranquilo
- Stack tecnológico
- julia
Línea de trabajo
Start with src/operators/linearize.jl to follow the existing explicit-backend pattern, then inspect the distributed entry point in ext/MatrixFreeOperatorsMDLAExt.jl and DESIGN.md §10.4. Review the relationship with #46 and the existing distributed tests. Done means the core tags and fallback, the MDLA implementation, unloaded-backend error test, documentation distinction from KernelAbstractions devices, and the IGG integration are all covered.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Problem
There is no way to choose a distributed backend. prepare_distributed is exported from the core, but its only method is defined inside ext/MatrixFreeOperatorsMDLAExt.jl:
function prepare_distributed(L0::AbstractOperator, nparts::Integer; devices=nothing)
So today the backend is whatever extension happens to be loaded, selected implicitly. Two consequences:
- Calling it without MDLA loaded gives a bare
MethodErroron an exported symbol, with no hint that the fix isusing MultiDeviceLinearAlgebra. - It does not survive a second backend. Once the IGG halo lands (#46), two extensions would define competing methods with the same
(operator, integer)signature. That is an ambiguity, and disambiguating it by keyword is worse.
Selection should be explicit and declarative, the way choosing an AD backend or a KernelAbstractions device is.
Proposal — mirror AbstractJVPBackend
We already have exactly this pattern in-repo, and it should be the model rather than inventing a second convention. src/operators/linearize.jl defines the abstract type and both concrete tags in the core, exports them, and lets the extension implement the behaviour:
abstract type AbstractJVPBackend end
struct FiniteDifferenceJVP <: AbstractJVPBackend end
struct EnzymeJVP <: AbstractJVPBackend end # core-defined; Enzyme ext implements
Its docstring already states the principle we want here — "Selecting the backend is deliberately explicit rather than ambient: the backends differ in ... which operations they support, so which one you get must not depend on load order." That reasoning applies verbatim to MDLA vs IGG.
This is also the ADTypes/DifferentiationInterface model the request pointed at: AutoEnzyme() lives in ADTypes, not in Enzyme, so you can name and dispatch on a backend you have not loaded.
Sketch:
# core
abstract type AbstractDistributedBackend end
struct MDLABackend <: AbstractDistributedBackend # single-node multi-GPU, slab decomposition
nparts::Int
devices::Union{Nothing,Vector{Int}}
end
struct IGGBackend <: AbstractDistributedBackend # multi-node MPI, 3D blocking
dims::NTuple{3,Int}
periodic::NTuple{3,Bool}
end
prepare_distributed(L, backend::AbstractDistributedBackend; kwargs...)
with a core fallback whose whole job is a good error:
prepare_distributed(::AbstractOperator, b::AbstractDistributedBackend; kwargs...) =
error("no distributed method for $(nameof(typeof(b))) — load the backing package (e.g. `using MultiDeviceLinearAlgebra`)")
Extensions then implement prepare_distributed(L, ::MDLABackend) / (L, ::IGGBackend) against the existing _dist_scatter! / _dist_reduce! seam. Nothing about the seam itself changes.
Constraints
- Tags must be config-only and free of backend types. An
MDLABackendholding aPartitionSpec, or anIGGBackendholding an MPI communicator, would drag the dependency into the core and defeat the point. Ints, tuples, symbols only. - This is orthogonal to the KernelAbstractions device, and the docs must say so explicitly — the analogy that motivates the API is also the easiest thing for a reader to conflate. The KA backend answers which device runs the kernel; this answers how partitions talk to each other. A real run picks both (
CUDABackend()device +IGGBackend()distribution), andCartesianGrid'sDevparameter is the former, not the latter. - Construction-time only. Like
EnzymeJVP, the tag selects behaviour when the prepared operator is built and must not leak into the operator tree or themul!hot path. - Does not change
prepare's contract — still stateful and single-threaded, one per concurrent solve.
Decisions to make while implementing
- Whether the existing
prepare_distributed(L, nparts::Integer; devices)stays as a deprecated shim forwarding toMDLABackend(nparts; devices), or goes away outright. It is unregistered and pre-v1, so removing it is defensible; a shim is cheap. - Whether
AbstractJVPBackendandAbstractDistributedBackendget documented together as one "explicit backend selection" concept in the docs, since they now share a rationale. Recommend yes — one section, two axes. - Whether a trivial
SerialBackend()is worth having so single-rank code paths are expressible withoutnothing.
Done when
-
AbstractDistributedBackend+MDLABackend+IGGBackenddefined and exported from core -
prepare_distributed(L, backend; …)is the documented entry point; core fallback errors with a "load X" message - MDLA extension implements its tag; existing tests pass through the new entry point
- Requesting an unloaded backend is tested for the error message, not just the throw
- Docs state the KA-device vs distributed-backend distinction explicitly
- #46's IGG extension implements
IGGBackendagainst this API rather than adding another entry point
Related: #46 (IGG halo backend), DESIGN.md §10.4.
🤖 Written by Claude — Kyle pointed at the shape, I filled in the paperwork.
- Lenguaje dominante
- Julia
- Estrellas
- 3
- Forks
- 1
- Merge medio
- 1 d 28 min
- PR fusionados (30 d)
- 6
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de RallypointOne/MatrixFreeOperators.jl
-
Roadmap: open-issue priorityAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 45/100
-
enhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
-
performance
Dificultad 5/5 Más de una semana Aptitud para principiantes 45/100
-
perf(forest): thread the reference BlockForest path — leaf sweeps and exchange descriptor loopsAbiertoperformance
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
-
enhancement
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
Todos los issues de RallypointOne/MatrixFreeOperators.jl
Issues similares
-
io
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
-
docs
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
JuliaGPU/GPUArrays.jl#837 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día