Skip to content
adaptPublic

About

Inkling 2 Mini, Bonsai 2.5, and Amazon Ergo inference engine

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

111 Commits

Folders and files

Repository files navigation

rink

rink runs models locally on Apple silicon and NVIDIA GPUs. It started with Inkling 2 Mini. Each model has its own Rust crate, configuration, and accelerator kernels.

Model Input Tools
Inkling 2 Mini Text and images Bash and file reading
Bonsai 2.5 27B Text Bash and file reading
Amazon Ergo Text Bash and file reading

Inkling and Bonsai use the same forward pass and paged KV cache on Metal and CUDA. Full-model throughput and long-context attention timings are available for both platforms. NVIDIA A100 · Apple M4 Max

Requirements

  • macOS on Apple silicon, or Linux with an NVIDIA GPU of compute capability 8.0 or newer.
  • On Linux, install a C++ compiler and Python 3 for the build, and the NVIDIA driver and CUDA 12 NVRTC library for execution. The GPU selects the native instruction set when the model loads.
  • A Rust toolchain with support for edition 2024.
  • The Hugging Face CLI (hf) to download the model files.
  • About 20 GB of disk space for Inkling. Bonsai needs 8.6 GB. Ergo needs 626 GB for its weights.

Use a Mac with 48 GB or more unified memory for the default chat settings. For a 32 GB Mac, use the smaller context below.

Run

Download the original Inkling model files:

hf download thinkingmachines/Inkling-2-Mini \
  --revision 1fb4134b9a74f9681054f4ef82e4bf1f458a2337 \
  --local-dir checkpoints/inkling-2-mini \
  --include config.json tokenizer.json model.safetensors.index.json model-00001-of-00001.safetensors

Start a chat:

cargo run --release -- chat

For a 32 GB Mac, start with a smaller context and reply limit:

cargo run --release -- chat --context 4096 --max-tokens 1024

To use Bonsai 2.5, download its MLX pack and select its directory:

hf download prism-ml/Ternary-Bonsai-2.5-27B-mlx-2bit \
  --revision aa432fd0e17612f6684e728d4d3c42b6656bcabb \
  --local-dir checkpoints/bonsai-2.5-27b \
  --include config.json tokenizer.json model.safetensors
cargo run --release -- chat --model checkpoints/bonsai-2.5-27b

The Bonsai download needs 8.6 GB of disk space. rink reads its packed weights directly. Python and MLX are not needed to run it. See the Bonsai notes for supported features and validation.

Run Amazon Ergo on CUDA

The published checkpoint fits on a single eight-H200 machine. Rink shards the attention heads, dense projections, vocabulary, and routed experts across the visible GPUs. Install the NVIDIA driver, CUDA 12 NVRTC and cuBLAS, and NCCL 2. The checkpoint stores routed experts in MXFP4. Rink reads the packed weights directly and uses BF16 for the dense projections and KV cache.

hf download Amazon-FMR/Ergo \
  --revision 5700ec7df58ec686f71aff5705e640c03aa530f9 \
  --include 'config.json' 'tokenizer.json' 'model*.safetensors' 'model.safetensors.index.json' \
  --local-dir checkpoints/Ergo
export RINK_API_KEY="$(openssl rand -hex 32)"
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 cargo run --release -- serve \
  --model checkpoints/Ergo --context 262144 --max-active 2

Use Ergo as the API model ID. Chat Completions returns Ergo's thinking in reasoning_content and its final answer in content, including in streaming deltas. Clients can replay both fields in the assistant message on later turns. Eight-H200 throughput and validation

Serve concurrent chats

Select one checkpoint when starting the server. Set RINK_API_KEY to require a shared key on every request. The same command runs on Metal and CUDA.

export RINK_API_KEY="$(openssl rand -hex 32)"
cargo run --release -- serve --model checkpoints/bonsai-2.5-27b

Point an OpenAI Chat Completions client at http://127.0.0.1:8080/v1. The model ID is the checkpoint directory name and is returned by GET /v1/models. Set the client's api_key or OPENAI_API_KEY to the same value. Both the model list and chat completions require Authorization: Bearer <key>. Missing or incorrect credentials receive HTTP 401. Bearer authentication

curl -N http://127.0.0.1:8080/v1/chat/completions \
  -H "Authorization: Bearer $RINK_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"model":"bonsai-2.5-27b","messages":[{"role":"user","content":"Hello!"}],"stream":true}'

The server also accepts --api-key KEY. The environment variable keeps the key out of the server's command line. Restart with a new key to rotate it. With both settings omitted, local clients can use any placeholder key. Rink binds to loopback by default. For remote access, use an SSH tunnel or HTTPS.

Multiple clients can stream concurrently. Each request supplies its own message history and ends with a user message or the results of an assistant's tool calls. The server supports greedy decoding, JSON or SSE responses, max_completion_tokens (also max_tokens), and streaming usage counts. The default reply allowance is 16,384 tokens or the remaining context, whichever is smaller. Set reasoning_effort to none (default), low, medium, or high.

Inkling accepts images in user messages, including earlier turns. Send a content array with {"type":"text","text":"What is this?"} and an image_url part such as {"type":"image_url","image_url":{"url":"data:image/png;base64,..."}}. Supply inline 8-bit PNG or JPEG data. Parts are processed in order and each 40-by-40-pixel tile counts as one prompt token, including partial edge tiles. A cached prefix containing an image is reused only for identical image bytes.

Pass OpenAI-style function definitions in tools. With tool_choice: "auto" (default), the model can answer directly or return calls with finish_reason: "tool_calls". The client executes each call and sends its result as a tool message with the matching tool_call_id. Use tool_choice: "none" to disable calls for a turn. Forced calls and strict schemas are unsupported.

The default context is 262,144 tokens, the same as interactive chat. The model keeps a pool of full-attention keys and values in GPU memory. Each chat takes 128-token pages as its history grows and returns them on completion or disconnect. Its output allowance counts toward its logical limit. Two chats can use interleaved pages in the same buffers. Local attention and recurrent state stay private to each chat.

The server automatically reuses exact token prefixes across requests to the loaded model. It checkpoints complete pages around the system instructions and tool declarations, near the end of the prompt, and at matching prefixes learned from earlier requests. Concurrent chats can read the same full-attention pages. Each restores its own sliding-window and recurrent state from a bounded host cache (up to 16 checkpoints and 512 MiB). Active chats can reclaim all GPU pages under memory pressure. Restarting the server clears the cache.

usage.prompt_tokens counts the whole input. Subtract usage.prompt_tokens_details.cached_tokens to get the tokens that needed prefill. Streaming clients can request these counts with "stream_options": {"include_usage": true}. The server also logs the three counts at admission, before generation starts. Chat responses include an x-request-id header. Inference failures are logged with that ID, the error chain, slot, and token counts, including errors after streaming has begun. A prefill_complete event reports elapsed milliseconds since slot admission.

After loading the weights and warming the inference workspace, the server sizes the pool from available VRAM on CUDA or the recommended working set on Metal. The startup line reports its size. Set --kv-pool-tokens to choose a size in tokens, rounded up to a whole page. When pages get scarce, the scheduler lets a chat finish and release its pages before granting growth that would leave every chat waiting. A request whose prompt and reply allowance cannot fit on their own receives HTTP 503.

By default up to two active chats share the weights. When a chat is decoding, Ergo processes up to 192 prompt tokens between pairs of decode steps. Inkling and Bonsai default to 32 prompt tokens between individual decode steps. When every active chat is prefilling, the worker rotates through them using the model's native batch size. Another 16 requests can wait. Use --max-active, --context, --prefill-chunk, and --max-queued to adjust these limits. Increasing active chats or context requires more GPU memory. When all active and waiting slots are occupied, the server returns HTTP 429. Disconnecting releases a chat's slot at the next scheduling boundary.

Chat

Enter one message per line. Replies appear as the model generates them.

Command Action
/help Show the commands.
/image PATH Attach a PNG or JPEG to the next message.
/image clear Remove the pending image.
/continue Continue a reply that reached the token limit.
/reset Clear the conversation.
/quit Exit.

Chat uses a 262,144-token context, a 16,384-token reply limit, and effort 0.9 by default. The reply limit includes reasoning tokens. The context limit covers the full conversation. Chat, generate, bench, and serve share each model’s paged KV implementation. A single conversation draws pages from a pool sized for its configured context. Every full-attention read and write uses the same page-table kernels, including when all its pages happen to be consecutive. /reset returns its pages for reuse. The default KV precision is FP16. See the paged cache measurements. Inkling prefill uses batches of up to 1,024 tokens. This targets about 30 GiB of Metal memory at 256K context. Use --prefill-batch 128 to reduce memory use. See the performance measurements.

To ask about a picture, enter /image /path/to/picture.png, then enter your question. Each message can have one image. Images must use 8-bit channels and can be up to 16,384 pixels on each side. rink keeps the original image size. Large images use more memory and take longer to process. Chat shows progress and separate times for image encoder loading, image encoding, prompt prefill, and generation. It also shows when the model is thinking. Progress goes to stderr. Use --show-thinking to read the reasoning text.

Use cargo run --release -- chat --help to see all options.

The Inkling configuration allows up to 1,048,576 tokens. This context does not fit in 48 GB of unified memory.

Tools

All three models support Bash and text file reading. Inkling also supports image reading.

Enable file reading and Bash:

cargo run --release -- chat --tool read,bash --cwd /path/to/project
# Use Bonsai:
cargo run --release -- chat --model checkpoints/bonsai-2.5-27b \
  --tool read,bash --cwd /path/to/project

Ask the model to read a file by path. read returns UTF-8 text with line numbers, or, with Inkling, adds a PNG or JPEG directly to the model's image context. Relative paths use --cwd; ~/ uses your home directory. Use --tool read to enable file reading alone. PDFs and other binary formats are not supported.

For text, the model can select start_line (starting at 1) and max_lines (200 by default, up to 2,000). Long results include a continuation line or a truncation message. --tool-output-bytes sets the text byte limit. Images use the same pixel limits and processing as /image, with a 2 GiB limit on the encoded file. Images must fit as complete inputs in the remaining context. They are processed one at a time. Temporary image snapshots are removed after use.

Enable Bash so the model can run commands:

cargo run --release -- chat --tool bash --cwd /path/to/project

Commands run directly with your user permissions. There is no approval prompt or sandbox. Each call starts a new shell in --cwd (the current directory by default). Shell variables and directory changes do not carry over to the next call. Commands cannot read terminal input. Background processes in the command's process group stop when the call ends. Chat shows each command and its output.

The defaults are a 120-second tool timeout, 16 KiB of text per call (Bash splits this between stdout and stderr), and eight tool rounds per user message. Set these with --tool-timeout-ms, --tool-output-bytes, and --max-tool-rounds. Press Ctrl-C during a command to cancel it. Use /continue to let the model read the result. /continue also resumes a reply that reached its token limit. Tool results use context space. The reply limit includes thinking and tool calls.

AI disclosure

The vast majority of this code was written by GPT 6 Astra with human guidance.

About

Inkling 2 Mini, Bonsai 2.5, and Amazon Ergo inference engine

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages