Communication APIs
MORI provides three communication layers, each targeting different use cases.
MORI-EP (Expert Parallelism)
Dispatch and combine kernels for MoE expert parallelism.
Imports:
from mori.ops import (
EpDispatchCombineConfig,
EpDispatchCombineOp,
EpDispatchCombineKernelType,
)
Kernel Types:
Type |
Value |
Use Case |
|---|---|---|
|
0 |
Single-node EP via XGMI |
|
1 |
Multi-node baseline |
|
2 |
Multi-node optimized bandwidth |
|
3 |
Multi-node low-latency |
|
4 |
Async low-latency with pipelining |
EpDispatchCombineOp methods:
Method |
Description |
|---|---|
|
Route tokens to expert ranks. Returns (output, weights, scales, indices, recv_count). |
|
Combine expert outputs back. Returns (output, weights). |
|
Split dispatch for overlapping communication with computation. |
|
Split combine for overlapping communication with computation. |
|
Reset internal state between iterations. |
|
Get source positions of dispatched tokens (for verification). |
|
Get pre-registered zero-copy combine buffer. |
See MORI-EP Guide for full API reference.
MORI Shmem (Symmetric Memory)
OpenSHMEM-style APIs for GPU memory management and RDMA.
Imports:
import mori.shmem
Initialization:
Function |
Description |
|---|---|
|
Init from PyTorch process group (recommended) |
|
Init with broadcast unique ID |
|
Cleanup shmem resources |
Query:
Function |
Description |
|---|---|
|
Get current PE (rank) ID |
|
Get total number of PEs |
|
Get RDMA queue pairs per PE |
Memory Management:
Function |
Description |
|---|---|
|
Allocate symmetric GPU memory |
|
Aligned symmetric allocation |
|
Free symmetric memory |
|
Register existing buffer for RDMA |
|
Deregister buffer |
Communication:
Function |
Description |
|---|---|
|
Translate pointer to P2P address on remote PE |
|
Global barrier across all PEs |
See Shmem Guide for full API reference.
MORI-IO (Point-to-Point I/O)
RDMA-based P2P communication for KVCache transfer.
Imports:
from mori.io import (
IOEngine, IOEngineSession, IOEngineConfig,
BackendType, MemoryLocationType, StatusCode, PollCqMode,
RdmaBackendConfig, XgmiBackendConfig,
EngineDesc, MemoryDesc,
set_log_level,
)
IOEngine methods:
Method |
Description |
|---|---|
|
Get engine descriptor for remote registration |
|
Create RDMA/XGMI/TCP backend |
|
Register a remote engine |
|
Register a PyTorch tensor for transfers |
|
One-sided read (remote → local) |
|
One-sided write (local → remote) |
|
Create reusable session for repeated transfers |
Enums:
BackendType:Unknown,XGMI,RDMA,TCPStatusCode:SUCCESS,INIT,IN_PROGRESS,ERR_INVALID_ARGS,ERR_NOT_FOUND,ERR_RDMA_OP,ERR_BAD_STATE,ERR_GPU_OP
See MORI-IO Guide for full API reference.
MORI-IR (Device Bitcode Integration)
Framework-agnostic device bitcode and ABI metadata for integrating MORI shmem into GPU kernel frameworks (Triton, FlyDSL, MLIR, custom HIP, etc.).
Imports:
from mori.ir import (
find_bitcode,
get_bitcode_path,
MORI_DEVICE_FUNCTIONS,
SIGNAL_SET,
SIGNAL_ADD,
)
# Triton-specific (reference backend)
from mori.ir.triton import get_extern_libs, install_hook
Host-side API (framework-agnostic):
Function / Constant |
Description |
|---|---|
|
Locate |
|
Dict of all device function ABI metadata (symbol, args, ret types) |
|
Signal operation constants for put-with-signal (values 9, 10) |
Triton-specific API (reference backend):
Function |
Description |
|---|---|
|
Returns dict for Triton |
|
Install Triton compilation hook for automatic bitcode linking |
Key device functions (available as extern "C" symbols in bitcode):
Category |
Functions |
Description |
|---|---|---|
Query |
|
Get PE rank and total PE count |
P2P |
|
Translate pointers across PEs |
Put |
|
Non-blocking put at thread/warp/block scope |
Put + Signal |
|
Put with signal notification |
Atomics |
|
Atomic operations on remote memory |
Wait |
|
Spin-wait on remote memory values |
Sync |
|
Ordering and synchronization |
See MORI-IR Guide for full device function table and integration examples.