8000 feat(aiengine): model pool, lifecycle hooks & dynamic model registration by tinyAdapter · Pull Request #45 · neurdb/neurdb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(aiengine): model pool, lifecycle hooks & dynamic model registration #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 5, 2025

Conversation

tinyAdapter
Copy link
Contributor

Summary

This PR is the first step towards a more extensible AI engine. It implements three mechanisms:

  • A model pool, which is a map that holds all available model architectures. The user can specify different model architecture names to train/inference on different types of models on the fly.
  • Lifecycle hooks. This adds flexible runtime behaviors to the AI engine. Currently, only one hook is implemented: neurdb_on_start(), which is called when the AI engine starts.
  • Dynamic model registration. Based on lifecycle hooks, a Python module exposing specific functions can register itself to the model pool, and gets called when a new prediction task comes.

Usage

Take ARM-Net as an example to show how to add a model architecture to the AI engine.

Package the model architecture

Put the code implementing the model architecture under the neurdbrt.model module. The file tree will look like:

neurdbrt
├── model
│   ├── armnet    <- here
│   ├── mlp_clf

Register the model by using lifecycle hook

For example, the code in model/armnet/__init__.py looks like:

...

from neurdbrt.model import register_model

def neurdb_on_start():
    register_model("armnet", ARMNetModelBuilder)

It uses the register_model() function provided by the AI engine to register itself to the model pool. Then, when the user sets NrModelName as armnet, AI engine will instantiate ARMNetModelBuilder and call its interfaces such as train() or inference() to do the actual job.

Hooks are automatically called to register the model architecture

This is done in server.py:

from neurdbrt.hook import exec_hooks_on_start, register_hooks
...

register_hooks()
exec_hooks_on_start()

As a first step, neurdb_on_start() hook is implemented to support registering ARM-Net to the model pool.
@zhanhaozhao zhanhaozhao merged commit de45544 into neurdb:dev May 5, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0