Skip to content

hellas-ai/catena-lang

Repository files navigation

Catena: portable deterministic array programming

Catena is a deterministic array programming language:

  • Deterministic: Programs produce bitwise identical results on all platforms
  • Secure: It is safe to execute programs from third parties

⚠️ NOTE: Catena is alpha quality software⚠️

If you find that these promises don't hold, open an issue!

Catena is a key technical component enabling the Hellas Network, a decentralised platform for trustless AI compute:

  • Determinism enables verifiability: users can check code was faithfully executed
  • Secure means that arbitrary user programs can be run by compute providers

Usage

cargo install catena-lang

Catena is intended to be called as a library. here's how to run a program that adds two u64 values:

use catena_lang::{
    codegen::GpuDialect,
    runtime::{Runtime, Value},
    stdlib,
};

fn main() -> anyhow::Result<()> {
    // programs in hexpr notation: https://github.com/hellas-ai/hexpr
    let source = r#"
        (def program two-plus-two : [] -> (u64 val) = (
          ({u64.one u64.one} u64.add)
          {[two . two two]}
          u64.add
        ))
    "#;

    let runtime = Runtime::from_sources(stdlib::sources().chain([source]), GpuDialect::Hip)?;
    let [result] = runtime.exec("two-plus-two", [])?;
    let Value::U64(result) = result else {
        anyhow::bail!("two-plus-two returned non-u64 value: {result:?}");
    };

    println!("2 + 2 = {result}");
    assert_eq!(result, 4);
    Ok(())
}

The same example is available as catena-lang/examples/readme.rs:

cargo run -p catena-lang --example readme

NOTE: by default this will run using the HIP backend. With Nix, you can run the example with the required dependencies as follows:

nix develop --command cargo run -p catena-lang --example readme

About

catena: a categorical verifiable array language

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages