Skip to content

firstbatchxyz/dkn-compute-node

Repository files navigation

logo

Dria Compute Node

Dria Compute Node serves the computation results within Dria Knowledge Network.

License: Apache-2.0 Workflow: Tests Downloads Docker Version Discord

About

Compute nodes can technically do any arbitrary task, from computing the square root of a given number to finding LLM outputs from a given prompt, or validating an LLM's output with respect to knowledge available on the web accessed via tools.

  • Heartbeats: Every few seconds, a heartbeat ping is published into the network, and every compute node responds with a digitally-signed pong message to indicate that they are alive, along with additional information such as which nodes they are running & how many tasks they have so far.

  • Workflows: Each task is given in the form of a workflow. Every workflow defines an agentic behavior for the chosen LLM, all captured in a single JSON file, and can represent things ranging from simple LLM generations to iterative web searching & reasoning.

Running a Node

Use the Dria Compute Launcher to run a compute node with many more features!

Releases

For production images:

  • Versioned: With each release, a versioned image is deployed on Docker hub with the version tag :vX.X.X.
  • Latest: The latest production image is always under the :latest tag.

For development images:

  • Master: On each push to master branch, a new image is created with the tag master-<commit>-<timestamp>.
  • Unstable: The latest development image is always under the :unstable tag.

You can see the list of deployed images on Docker Hub.

Development

If you have a feature that you would like to add with respect to its respective issue, or a bug fix, feel free to fork & create a PR!

If you would like to run the node from source (which is really handy during development), you can use our shorthand scripts within the Makefile. You can see the available commands with:

make help

You probably have already but in case you don't, you will need OpenSSL installed, see shorthand commands here.

cargo run

# specify custom .env file
DKN_COMPUTE_ENV=./path/to/.env cargo run

If you have a valid .env file, you can run the latest Docker image via compose as well:

docker compose up

# Ollama without any GPUs
docker compose --profile=ollama-cpu up
# Ollama for NVIDIA gpus
docker compose --profile=ollama-cuda up
# Ollama for AMD gpus
docker compose --profile=ollama-rocm up

Note that we are very dependent on Ollama packages, and it is important to check their versions if relevant:

cat Cargo.lock | grep "https://github.com/andthattoo/ollama-workflows"
cat Cargo.lock | grep "https://github.com/andthattoo/ollama-rs"

Testing

You can the tests as follows:

cargo test --workspace

We also have some benchmarking and profiling scripts, see node performance for more details.

Documentation

You can view the entire crate-level documentation with:

cargo doc --open --no-deps --document-private-items

Styling

Lint and format with:

cargo clippy --workspace
cargo fmt -v

Profiling

We have scripts to profile both CPU and Memory usage. A special build is created for profiling, via a custom profiling feature, such that the output inherits release mode but also has debug symbols.

Furthermore, the profiling build will exit automatically after a certain time, as if CTRL+C has been pressed. This is needed by the memory profiling tool in particular.

CPU Profiling: To create a flamegraph of the application, the command below will create a profiling build that inherits release mode, except with debug information:

DKN_EXIT_TIMEOUT=120 cargo flamegraph --root --profile=profiling --bin dkn-compute

Note

CPU profiling may require super-user access.

Memory Profiling: To profile memory usage, we make use of cargo-instruments:

DKN_EXIT_TIMEOUT=120 cargo instruments --profile=profiling -t Allocations --bin dkn-compute

Tip

You can adjust the profiling duration via the DKN_EXIT_TIMEOUT variable, which takes a number of seconds until termination.

License

This project is licensed under the Apache License 2.0.