[RFC] Proposal: Architecture Modernization – Native Kernels, Model Hub & Lazy Dependencies
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.6k
- Forks
- 779
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 27
Description
What kind of feature would you like to request?
Additional function parameters / changed functionality / changed defaults?
Please describe your wishes
I propose three architectural enhancements for Scanpy:
1. Native C++ Backends (It is painless now)
I propose moving high-performance kernels to Native C++.
- Feasibility: In the modern CI/CD era (GitHub Actions +
cibuildwheel), cross-platform binary distribution is fully automated. - Maintenance: With AI-assisted coding, writing C++ kernels is no longer a burden. We can focus on algorithm design while automating the implementation.
- Proof: In
PerturbLab/kernels, I implemented sparse matrix operators in pure C++ that significantly outperform Numba.
2. Dependency Hygiene: Lazy Imports & Vendoring
- Lazy Loading: Heavy submodules (especially those requiring
torchor specific plotting libs) should use lazy imports. - Vendoring: Small utility functions should be "vendored" (inlined) rather than adding full package dependencies.
- Benefit: This keeps the core lightweight and prevents "dependency hell."
3. A "Transformers-like" Model Hub
I propose adding a standardized sc.models interface.
- In
perturblab/models, I implemented a unified registry to manage, download, and deploy models (e.g., scGPT, Gears) with a consistent API (config,model,io). - Scanpy is the ideal place to standardize this for the community.
Alternative Solutions
Continuing to rely solely on Numba/Python for everything limits the potential for extreme optimization and restricts the ecosystem from effectively utilizing low-level hardware acceleration (CUDA/C++).
Additional Context
My repository krkawzq/PerturbLab serves as a proof-of-concept for this architecture. It demonstrates that a strictly typed, high-performance (C++ backed), and modular system can be built rapidly.
I am happy to discuss contributing the C++ kernels or the Model Hub design to help push this initiative forward. "The lower the level, the better the performance."
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names no Scanpy files or tests; start by reviewing its three proposals and the linked PerturbLab proof of concept. Done requires an agreed, bounded scope with specific entry points, acceptance criteria, and a decision on which architectural proposal to pursue; the issue currently provides none.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python, pytorch
- Domain
- backend, build-system, machine-learning, performance
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100