Poly is a production-grade execution engine for AI pipelines. It allows you to mix Python, Rust, C++, and JavaScript in a single pipeline file with shared memory, automatic orchestration, and zero glue code.
Most AI companies struggle with a painful split:
- Research Team: Writes Python (PyTorch/Jupyter). Slow, hard to deploy.
- Infra Team: Re-writes everything in C++/Rust/JS for production.
Poly eliminates this rewrite. You can keep your research logic in Python and swap out just the heavy data processing steps to Rust or C++ without rewriting the entire pipeline or wrapping everything in microservices.
- Zero-Copy Performance: Using Apache Arrow, data is shared in memory between Python, Rust, C++, and JS. No slow JSON serialization.
- Infrastructure as Code: Replace 5 Docker containers and airflow DAGs with one file.
- True Polyglot: First-class support for 4 languages: Python (ML), Rust (Data), C++ (Compute), JavaScript (IO/Web).
- Python 3.9+
- Dependencies:
pip install click lark networkx pyarrow rich pandas numpy - Optional Dependencies:
pip install torch(Required for GPU Hardware Awareness)
I included a master demo that runs a mixed-language pipeline.
python -m poly.cli.main run examples\master_demo.polyWhat happens?
- Python loads data from CSV.
- Rust normalizes the data (Mocked if valid DLL not found).
- C++ extracts features (Mocked if valid DLL not found).
- Python trains a model using Numpy/Pandas.
- JavaScript sends the model to an API (Mocked/NodeIPC).
- Poly saves the final result to
final_out.arrow.
Write your pipelines in a .poly file. The syntax is simple:
variable = namespace.function(arguments)
py.: Call Python functions.rs.: Call Rust functions (via FFI).cpp.: Call C++ functions (via FFI).js.: Call JavaScript functions (via IPC).poly.: Built-in runtime utils.
# Load data using Python
raw_data = py.load_csv("data.csv")
# Clean using Rust (High performance)
clean_data = rs.clean_dataset(raw_data)
# Train model in Python (Ecosystem)
model = py.train(clean_data)
# Save output
poly.save(model, "result.arrow")Poly allows you to bring your own code in any supported language.
- Location:
examples/functions.py(or any python file in your working dir). - How it works: Poly dynamically imports this module.
- Signature: Functions receive generic arguments. If an argument is a data reference (Arrow file), Poly automatically loads it as an Arrow Table/RecordBatch for you? Currently: Adapters handle file paths, but Python adapter auto-converts to PyArrow Table/Pandas DataFrame.
- Location:
examples/rust_kernel/. - Compilation:
cargo build --release cp target/release/poly_functions.dll functions_rs.dll
- Signature: Must be
extern "C"and accepted*const c_char.#[no_mangle] pub extern "C" fn my_func(path: *const c_char) -> *mut c_char { ... }
- Location:
examples/cpp_kernel/. - Compilation:
g++ -shared -o functions_cpp.dll examples/cpp_kernel/functions.cpp
- Signature:
extern "C" __declspec(dllexport) const char* my_func(const char* input);
Poly uses Apache Arrow IPC (Memory Mapped Files) to pass data between languages.
- Zero-Copy: Large datasets are not copied between processes; they are mapped into memory.
- Type Safety: Arrow schemas ensure data consistency across Rust, C++, and Python.
The core engine (poly/runtime/engine.py) builds a Directed Acyclic Graph (DAG) of your pipeline, handles topological sorting, and dispatches execution to the appropriate language adapter.
- Docker/Kubernetes Executors.
- WASM Adapter.
- Visual DAG Editor.
Aarav Mehta