Repository navigation
Description
Personal tracking issue for the SPy-side prerequisites to a paper on SPy as a basis for the scientific Python ecosystem. Potentially targeting MPLR 2027 (Prague), work-in-progress research paper track?
The same content can be presented at EuroPython/EuroScipy 2027.
Scientific/technical question. Can SPy — a statically-compilable subset of Python — serve as the implementation language for the basis of the scientific Python ecosystem (NumPy/SciPy-like array libraries), rather than requiring a C/C++/Cython/Rust layer underneath?
Content. Demonstrations of SPy's suitability for numerical-kernel implementation:
- metaprogramming (blue, metafunc, blue unroll, variadic
*args) as the mechanism behind array-API-style generic functions; - loop fusion of array expressions;
- SIMD vectorization via
vectorize, itself written in pure SPy rather than hand-written intrinsics; - a short section on simple parallelism.
We do NOT want loop fusion itself landed in SPy, only what loop fusion needs.
See the existing checklist for the loop-fusion demo itself:
https://github.com/paugier/spy-demos/tree/loop-fusion/loop-fusion
Use more generic classes
-
nonlocal A = ndarray[DTYPE, NDIM]syntax for generic struct (see draft: Generic class type alias spylang/spy#529)
Less repetitions
-
__add__ = make_add_metafunc(DTYPE, NDIM)?
Of course, we could also use Protocol but it has to be supported by SPy.
Cleaner redshift output
- Redshift: no current module name in FQN by default? spylang/spy#590
- format rs output
UnrollFor (blue unroll)
- Blue unroll scoping improvements (Antonio, done in Better scoping rules spylang/spy#678 )
- Blue unroll itself (Antonio, next)
Metaprogramming loc and get_src
- MetaArg: add loc attribute and loc.get_src() spylang/spy#708
-
args_m.loc, W_MetaArgs for args_m.loc, args_m.types and STATIC_TYPE(args_m[0]) == MetaArg spylang/spy#729
Starred / SpliceUnroll (*args)
Design: https://fluiddyn.pages.heptapod.net/spy-book/design-more-metaprog/
-
args_m.typesW_MetaArgs for args_m.loc, args_m.types and STATIC_TYPE(args_m[0]) == MetaArg spylang/spy#729 -
Starredin the parser and inastcompileGeneral support for Starred syntax in the parser + support for few simple cases in blue functions spylang/spy#710 - Blue-interpreted consumption of
Starred(in blue functions):[*iter],bfunc(*iter),Tuple[*types]General support for Starred syntax in the parser + support for few simple cases in blue functions spylang/spy#710 -
def func(*args: *types)for red functions (depends on General support for Starred syntax in the parser + support for few simple cases in blue functions spylang/spy#710) -
SpliceUnroll(depends onUnrollFor, relatively big but shouldn't need months once
UnrollForis done)
Use new meta programming in stdlib/array.spy
- Nicer implementation of array (multidimensional with metaprog)
SIMD / vectorize
- Aligned pointers and pointer reinterpret-cast spylang/spy#676
- align_cast[N] spylang/spy#686
- align_offset (https://github.com/paugier/spy/tree/align_offset)
- ptr._debug_get_length spylang/spy#690
- Support mod.metafunc() call spylang/spy#691
- Unwrap SPy tuples into Python tuples spylang/spy#692
- Clean SIMD implementation with the discussed API (draft MRs mostly exist);
shouldn't take months once aligned pointers are merged
Parallelism
I don't think the paper should include a demo on parallelism but it can be discussed in the conclusions/perspectives. There is an AI generated plan for simple parallelism strategy (not yet discussed with Antonio).
Activity