Lightning-AI / Lightning-AI/LitServe

Async task processing via TaskSpec — standalone package, interested in upstreaming?

Open
#668 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement spec
Dominant language
Python
Stars
3.9k
Forks
304
Avg merge
3d 13h
Merged PRs (30d)
6

Description

Hi, I have been working on adding async and polling task support for LitServe (related to #405 and #348). Instead of opening a large unsolicited PR right away, I built it as a small standalone package to explore the idea first.

In our research project we run a relatively small CPU-bound model, but the input preparation and processing pipeline can take a couple of minutes before inference even begins. Right now we use Celery together with FastAPI. That setup works, but as the project grows, with more models, possible GPU workloads, and higher scalability needs, we started looking at LitServe as a cleaner long-term direction.

Some inference workloads such as heavy preprocessing, large model generation, or video and audio processing can simply take too long for a synchronous HTTP response. Keeping a connection open for minutes is fragile and does not scale well. A task-based pattern lets clients submit work and receive a `task_id` immediately. They can then poll for status and fetch the result when it is ready. This fits naturally with async workflows and makes it easier to replace something like Celery without losing the fire-and-forget model.

The implementation adds four endpoints through a `TaskSpec(LitSpec)`:

| Method | Path | Description |
|------|------|-------------|
| POST | `/tasks` | Submit a task and return `{"task_id": "..."}` immediately |
| GET | `/tasks/{task_id}` | Poll task status |
| GET | `/tasks/{task_id}/result` | Fetch the completed result |
| DELETE | `/tasks/{task_id}` | Explicit cleanup |

Usage is straightforward:

```python
api = MyLitAPI(spec=TaskSpec())
```

The package is here:
https://github.com/dacrystal/litserve-tasks

**Disclaimer:** This is currently being tested in our research project at a small scale. It should be considered a proof of concept rather than production ready code.

Would this be something you might want to bring upstream? or open a PR if this direction makes sense.

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

Review the linked litserve-tasks proof of concept and its TaskSpec(LitSpec) entry point, then compare the four documented task endpoints with LitServe's current API design. Clarify whether upstream support is wanted and define production requirements for submission, polling, result retrieval, and cleanup before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
fastapi, python
Domain
ai, api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.