[RFC] Define accelerator-agnostic backend boundaries for core MoE operations
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Área
- backend, machine-learning
Línea de trabajo
Comienza por la interfaz megablocks.ops existente que utilizan las capas MoE y sigue su enrutamiento, permutación y operaciones agrupadas de expertos. Revisa el comportamiento de referencia propuesto en pure-PyTorch y el alcance de las pruebas de conformidad antes de la implementación. Se considera terminado cuando los contratos de las operaciones y las pruebas de referencia estén definidos, dejando las implementaciones de dispatch y específicas de aceleradores como trabajo de seguimiento independiente.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
MegaBlocks already exposes megablocks.ops as the interface used by its MoE layers, but it does not currently have a consistent internal boundary between operation semantics and accelerator-specific implementations. Routing metadata operations depend on the megablocks_ops CUDA extension, token permutation uses Triton kernels, and grouped expert computation depends on the CUDA-specific grouped_gemm package.
This RFC proposes explicit internal contracts for core operations and grouped GEMM. A pure-PyTorch reference implementation would define device-independent correctness behavior, while optimized accelerator implementations could be developed and reviewed independently.
Motivation
- #97 requests AMD and ROCm support. A maintainer noted that the remaining CUDA kernels could be replaced with Torch operations or Triton kernels and welcomed contributions.
- #182 explores pure-PyTorch routing and permutation implementations for NPU tensors while preserving the CUDA paths.
- #187 explores ROCm support through HIPification and build-system changes.
These efforts require common decisions about operation semantics, dispatch, optional dependencies, and conformance testing. Defining those boundaries once would reduce duplication and make accelerator support easier to review and maintain.
Proposed direction
The existing megablocks.ops functions would remain the interface used by MoE layers. Their input, output, dtype, autograd, and edge-case behavior would be defined explicitly. An internal dispatch mechanism would select implementations from tensor device and runtime capabilities.
A pure-PyTorch backend would serve as the conformance reference. It would not replace optimized implementations by default. Existing CUDA kernels would remain the optimized CUDA path. Grouped GEMM would use a separate provider contract because its implementation and dependency requirements differ from routing and permutation operations. The existing grouped and sparse choices would continue to describe algorithms rather than accelerator platforms.
Contribution approach
I will drive the implementation. If this direction is acceptable, I would begin with a change defining operation contracts and pure-PyTorch reference tests. Dispatch, dependency separation, and accelerator-specific implementations would follow as independent pull requests.
Feedback requested
Before implementation, I would appreciate the maintainers' feedback on whether these backend boundaries fit the intended direction of MegaBlocks and whether the proposed incremental contribution approach is suitable
AI tool use
- Grammarly was used to improve grammar and phrasing.
- Cursor was used to inspect this repository, trace accelerator-specific dependencies, and review the claims of this issue.
I reviewed the final content and take responsibility for the proposal and any subsequent contributions.
- Lenguaje dominante
- Python
- Estrellas
- 1.6k
- Forks
- 228
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Incluye un Dockerfile o un archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
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.
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
huggingface/smolagents#3106 ·
Los mantenedores suelen responder en 2 días
-
area:scripts area:tests bug priority:later
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Ikalus1988/MisakaNet#4358 ·
Los mantenedores suelen responder en 1 día
-
Discovered ports from service discovery are never propagated to modules in Module.load()Posiblemente ocupada @vishalmore90 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
OWASP/Nettacker#1828 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
aws-samples/sample-per-model-bedrock#708 ·
Los mantenedores suelen responder en 1 día
-
maintenance
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100