Skip to main content

Python API for the Τομί task-graph framework

Project description

Τομί (Tomii)

Task-graph framework for streaming pipelines, MIMO workloads, and agent-tuneable applications.

Tomii implements Tripartite Decoupling separating the three following artifacts: 1) Computation structure, 2) Kernel Implementation, 3) Runtime. Each artifact can be modified independently and Tomii is responsible for combining them at compile (transform kernels into tomii-suitable format) or execution time (parse computation structure description).

Tomii is not a general-purpose Taskflow or TBB replacement. For pure single-stream micro-task DAGs where dispatch overhead dominates, Taskflow is faster. Tomii's advantage is in workloads that benefit from concurrent streams, generational slot reuse, and structured graph surfaces — particularly MIMO-class packet-driven pipelines and agent-driven automated optimisation loops.

Each benchmark under bench/<name>/ is verifier-gated and reproducible from this repository — run the script in its directory; see bench/*/README.md for the topology, metric definition, and run instructions. Measured comparison numbers are published in the project documentation, not in these READMEs.


Python API (recommended)

import tomii as tm

app = tm.Graph()

buf_size    = app.var("buf_size", 100)
fft_planner = app.var("fft_planner", func="fft_planner", args=[buf_size])

gen_vec     = app.node("gen_vec",     func="generate_vector", factor=200, args=[buf_size])
compute_fft = app.node("compute_fft", func="compute_fft",     factor=200,
                       args=[fft_planner, gen_vec.out()])
vec_mat     = app.node("vec_mat",     func="vec_to_mat",      factor=200,
                       args=[gen_vec.out(), compute_fft.wait()])

app.build(func_path="plugin/src/lib.rs", plugin_manifest="plugin/Cargo.toml")
app.run(workers=4, slots=2, timing="timing.csv")

Install

python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"

Graph API

Method Description
app.var(name, value) Constant initialization
app.var(name, func=..., args=[...]) Computed initialization
app.node(name, func=..., args=[...], factor=...) Computation node; factor = parallel instances
app.post_node(...) Post-computation cleanup node
node.out(i) Data dependency on instance i ($res)
node.wait(i) Barrier — wait for instance i ($barrier)
('dep', node) Ordering-only dependency, no output ($dep)
app.network(**cfg) Configure UDP/TCP packet-driven dispatch
app.to_json() Export graph to JSON

Type system

tm.i32(-5) / tm.f32(3.14) / tm.String("hello") / tm.bool_(True)
tm.Complex64(1.0, -0.5) / tm.Vec("f32", [1.0, 2.0, 3.0])

Python intusize, floatf64 by default.

Loops and conditions

loop_node = app.node("proc", func="process", factor=200,
                     loop=Loop("iter", factor=loop_factor))

cond_node = app.node("filter", func="filter_fn", factor=200,
                     condition=Condition(operation="Eq", value=1, value_type="usize",
                                        func="check_fn", args=[some_var]))

Build options

app.build(func_path="plugin/src/lib.rs",      # Rust source — auto-generates wrappers
          # or func_path="include/plugin.h",  # C header with // @tomii_export annotations
          plugin_manifest="plugin/Cargo.toml",
          release=True)

Run options

app.run(workers=8, system_threads=2, slots=4, max_streams=100,
        timing="timing.csv", report="report.json",
        inline_continuation=True, coalesce_barriers=True)

Agent-native interfaces

Tomii exposes structured discovery and diagnostic interfaces designed for LLM agents.

Discovery

python -m tomii --list-knobs           # all graph.run() options
python -m tomii --list-knobs-json      # machine-readable JSON with search hints
python -m tomii --schema               # JSON schema for the graph construction API

Structured performance report

Pass report="report.json" to app.run() for a JSON performance report after each run:

Key Description
summary.avg_latency_us / p50 / p99 Stream latency statistics
summary.throughput_streams_per_sec End-to-end throughput
summary.scheduling_overhead_diagnostic overhead_pct, overhead_us, interpretation
per_node Per-node avg/p99 exec time, on_critical_path flag
optimization_suggestions Prioritised list: category, action, knob, estimated speedup

Agent Skills

SKILLS/ contains structured workflow skills covering the full optimisation lifecycle — from project discovery to graph coarsening:

Skill Purpose
project-discover Orient in an unknown project: topology, knob inventory, baseline
graph-build Translate a computation description into a graph + plugin stubs
run-validate Build, verify correctness, establish baseline
diagnose Classify bottleneck (scheduling / compute / imbalance)
knob-search 5-iteration search over scheduler knobs using per-knob hints
graph-coarsen Reduce task count when overhead_pct > 60%
plugin-author Write correct #[tomii_export] Rust/C plugin functions
./SKILLS/install-skills.sh            # installs to .claude/skills/ in CWD

Graph visualisation

python -m tomii --visualize examples/stream-analytics/graph.json       # browser view
python -m tomii --visualize examples/stream-analytics/graph.json --edit # browser edit
python -m tomii --visualize graph.json --ascii                          # terminal ASCII

The web UI renders a colour-coded DAG (Dagre layout): green for compute nodes, orange-bordered for conditional, gray for post-nodes. Edges are styled by type ($res solid blue, $dep dashed, $barrier thick orange). Export Python downloads a ready-to-run script from the current graph.


JSON + CLI workflow

cargo run -p tomii-core --bin main -- \
  --json graph.json --dylib plugin.so \
  --workers 4 --slots 2 --max-streams 100

Key flags: --workers, --slots, --system-threads, --timing, --report, --fifo, --custom, --inline-continuation, --coalesce-barriers, --resolution-strategy multi-slot-batch.

Full flag list: cargo run -p tomii-core --bin main -- --help


Pluggable scheduler

Implement the TaskScheduler trait (defined entirely in tomii-types — no tomii-core dependency required) and load it at runtime:

cargo build --release -p scheduler-plugin
cargo run -p tomii-core --bin main -- \
  --scheduler-plugin target/release/libscheduler_plugin.so \
  --json graph.json --dylib plugin.so

See examples/scheduler-plugin/ for a minimal FIFO example and tomii-core/PLUGIN_SCHEDULER_API.md for the stability contract.


Flagship examples

Example #1 — Public 4×4 MIMO uplink benchmark

cd bench/mimo-bench
# requires Intel MKL, Agora sender (see README)
python tomii/run_bench.py --workers 4 --slots 4 --streams 200
python taskflow/run_bench.py --workers 4 --slots 4 --streams 200

Tomii dispatches FFT tasks as each UDP packet arrives; Taskflow must collect all packets before submitting the full DAG. This packet-overlap is the structural advantage the benchmark measures. See bench/mimo-bench/README.md for topology and metric.

Example #2 — Multi-stream pipeline S-scaling

cd bench/pipeline-bench
python tomii/run_bench.py --workers 4 --slots 16 --streams 200
python taskflow/run_bench.py --workers 4 --slots 16 --streams 200

Sweeps concurrent-slot count (S) to show how per-stream scheduling overhead amortises as multi-slot reuse takes effect. Run run_bench.py to generate the sweep CSV locally (run outputs are not committed). See bench/pipeline-bench/README.md for the topology and metric.

Tomii runs use --custom --coalesce-barriers --inline-continuation (hardcoded in run_bench.py); these are the recommended flags for streaming workloads. Taskflow uses default tf::Executor.

Ergonomics #1 — Agent-native graph tuning

cd examples/agent-tuning
bash run_all.sh 50   # runs all 4 arms (random, Bayesian, grid, Claude)

Four optimisation arms (random, Bayesian, grid, Claude) compete over the stream-analytics knob space with the same budget (50 iterations) and verifier. The agent converges without being given source code or documentation; an edit that drops a barrier or removes a $dep edge fails the verifier and is rejected. See examples/agent-tuning/README.md.

Ergonomics #2 — Polyglot plugin showcase

The same DAG (FFT + matrix compute) runs with Rust, C, and Python kernels:

python examples/matrix-compute/run_bench.py --workers 4
python examples/matrix-compute-C/run_bench.py --workers 4
python examples/matrix-compute-python/run_bench.py --workers 4

No source changes to the runtime — the plugin boundary is a C ABI, language-agnostic by design. See examples/README.md for the full capability matrix.


Architecture

Workspace crates:

  • tomii-core — runtime, scheduler, graph engine, network receiver
  • tomii-typesCmTypes enum + stable scheduler API types (SchedulerPriority, SchedulerWorkerRange, CoreSpec)
  • tomii-converter — code-generation: wraps Rust/C plugin headers into wrappers.rs/reg.rs
  • tomii-macro — procedural macros for plugin wrapping (WIP)
  • tomii/ — Python API package

Key runtime modules (tomii-core/src/runtime/):

  • resolution_loop.rs — main resolution loop, batch draining
  • batch_resolution.rs — four-phase batch processing (Phases 1–3)
  • resolution_strategy.rsResolutionStrategy trait + MultiSlotBatchStrategy
  • task_execution.rs — worker task execution, inline-continuation fast path
  • successor.rs — successor collection and dependency propagation
  • shared_data.rsSharedData, SlotData, borrow bundles
  • slot_lifecycle.rs — slot completion detection
  • ARCHITECTURE.md — detailed threading model, memory ordering, invariants

Threading model:

  • Worker threads (Rayon or custom pool) with CPU affinity — kernel execution
  • System thread(s) — dependency propagation and slot lifecycle
  • Network receiver threads — low-latency UDP/TCP packet ingestion (feature network)
  • Async recorder thread — non-blocking timing output

See tomii-core/src/runtime/ARCHITECTURE.md for the performance envelope (intrinsic costs, target workload classes, and workloads Tomii explicitly does not target).


Build

cargo build --release
make schema   # regenerate Python bindings after changing json_structs.rs

Note for bench/mimo-bench/ builds: the MIMO bench links Intel MKL and Agora libs. Run source examples/mimolib/scripts/export.sh before building to set the required library paths. See bench/mimo-bench/README.md for the full dependency list.

Environment variables

  • FUNC_PATH — path to plugin header or Rust source (required for tomii-converter)
  • WRAP_PATH / REG_PATH — wrapper/registry files (optional, auto-generated)

License

Apache License 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tomii_rt-1.0.0.tar.gz (70.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tomii_rt-1.0.0-cp313-cp313-manylinux_2_34_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

tomii_rt-1.0.0-cp312-cp312-manylinux_2_34_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

tomii_rt-1.0.0-cp311-cp311-manylinux_2_34_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

tomii_rt-1.0.0-cp310-cp310-manylinux_2_34_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

tomii_rt-1.0.0-cp39-cp39-manylinux_2_34_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

File details

Details for the file tomii_rt-1.0.0.tar.gz.

File metadata

  • Download URL: tomii_rt-1.0.0.tar.gz
  • Upload date:
  • Size: 70.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tomii_rt-1.0.0.tar.gz
Algorithm Hash digest
SHA256 d368d4a941d653f25dcba7b1a354ca8153cd8bce00646a3e2bbad8661d4165db
MD5 617d3e4e98cffe16dd9826d300499f5d
BLAKE2b-256 bc044b8d06e16cc939835aa26555a295e47f4eb553e3adc6599f233cdda96341

See more details on using hashes here.

Provenance

The following attestation bundles were made for tomii_rt-1.0.0.tar.gz:

Publisher: release.yml on Giotyp/Tomii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tomii_rt-1.0.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for tomii_rt-1.0.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 f8997212b894e40935412e149491e4bcbfe46b7587f6ebbfb19e9ccad60789ea
MD5 f50688322fee310a4a619cc6c0b13a84
BLAKE2b-256 f4dcf6f05537714abc61df420709de2f1ff1eef1b8f871c855b70d0d71fa0b2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for tomii_rt-1.0.0-cp313-cp313-manylinux_2_34_x86_64.whl:

Publisher: release.yml on Giotyp/Tomii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tomii_rt-1.0.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for tomii_rt-1.0.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 143d0849584cf8757de61c5707bb987911a9bcbb82461ec3e279f8ba4f2a20e2
MD5 51372f07d66439d2a4d22e04f3ddaaa2
BLAKE2b-256 7f0a4080771388b595ae989b07830914c036355b41b2a5dc0453d7e8ad8391cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for tomii_rt-1.0.0-cp312-cp312-manylinux_2_34_x86_64.whl:

Publisher: release.yml on Giotyp/Tomii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tomii_rt-1.0.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for tomii_rt-1.0.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 30556ff0906a14be766c543d808fca45c8a2028df8670d980993c82634532e6a
MD5 250aede36eb42693bc43241b2e283fb4
BLAKE2b-256 898dc94fdbeef5a19c1d79499b5fab154b78d13e74f697330765ffc7a35a73e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for tomii_rt-1.0.0-cp311-cp311-manylinux_2_34_x86_64.whl:

Publisher: release.yml on Giotyp/Tomii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tomii_rt-1.0.0-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for tomii_rt-1.0.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 0c37426a38b5fa8ff8f413800767df40f99349e8e49dc40150da6a838a64fb40
MD5 6499ea3ff4fe7b604c66766fd9a49af6
BLAKE2b-256 3333a597eac93c14ec54fcbbba69f852224aa453f297dacc387a7284f95c4f12

See more details on using hashes here.

Provenance

The following attestation bundles were made for tomii_rt-1.0.0-cp310-cp310-manylinux_2_34_x86_64.whl:

Publisher: release.yml on Giotyp/Tomii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tomii_rt-1.0.0-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for tomii_rt-1.0.0-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 50f6a46c2b845f87b06d1d28ab2c5d3171b267ead6b8de3ce6f735f40b35de8b
MD5 fba7b91ffe58368fbbd2c40698841c88
BLAKE2b-256 a774e064da26f3a127c905a2ff89065a227deb4c38e026fc10e71a029593a9a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for tomii_rt-1.0.0-cp39-cp39-manylinux_2_34_x86_64.whl:

Publisher: release.yml on Giotyp/Tomii

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page