scverse / scverse/scanpy

[RFC] Proposal: Architecture Modernization – Native Kernels, Model Hub & Lazy Dependencies

Open
#3,934 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area – Performance 🐌 Needs info❔
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 torch or 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.