Skip to content

akaoio/bugs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

79 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RKLLM + RKNN Unix Domain Socket Server

⚠️ WARNING: EXPERIMENTAL AI-GENERATED PROJECT ⚠️

πŸ€– This project is entirely AI-generated and contains significant bugs, hallucinations, and unreliable code. Use at your own risk for educational purposes only.


β›” IMPORTANT DISCLAIMERS

  • 🚨 BUGGY CODE: This codebase contains numerous bugs, incomplete implementations, and non-functional components
  • πŸ€– AI HALLUCINATIONS: Many claimed features, performance metrics, and API implementations may not work as described
  • ⚠️ EXPERIMENTAL ONLY: Not suitable for production use - intended for learning and experimentation
  • πŸ”¬ RESEARCH PROJECT: Generated by AI as a proof-of-concept with no guarantees of functionality
  • πŸ’£ NO WARRANTY: Use entirely at your own risk - may cause system instability or data loss

Production-ready C server providing access to Rockchip's AI libraries through JSON-RPC 2.0

πŸ“‹ Documentation

  • πŸ“– Design Document - Detailed technical architecture, API reference, and implementation details
  • πŸ“ Instructions - Setup and usage instructions
  • πŸ“ Project Notes - Development notes and findings

Current Status: ⚠️ AI-GENERATED EXPERIMENTAL CODE ⚠️

Date: July 24, 2025
Implementation: Claims 16 RKLLM + 23 RKNN functions (may be hallucinated)
Reality: Many functions may not work, crash, or behave unexpectedly
Status: Experimental AI-generated code with unknown reliability

Architecture

  • Transport: Unix Domain Socket (/tmp/rkllm.sock)
  • Protocol: JSON-RPC 2.0 with direct 1:1 API mapping
  • Libraries: Complete RKLLM (language) + Core RKNN (vision) integration
  • Structure: Ultra-modular (one function per file)
  • Performance: <10ms token latency, 100+ concurrent connections

APIs Available

RKLLM Methods (16 Functions) βœ…

rkllm.init          rkllm.run           rkllm.run_async     rkllm.destroy
rkllm.load_lora     rkllm.abort         rkllm.is_running    rkllm.get_constants
rkllm.clear_kv_cache rkllm.set_chat_template rkllm.set_function_tools

RKNN Methods (23 Functions) βœ…

rknn.init           rknn.query          rknn.run            rknn.destroy
rknn.inputs_set     rknn.outputs_get    rknn.create_mem     rknn.set_core_mask
rknn.mem_sync       rknn.get_constants

Missing APIs (Non-Critical) ⚠️

  • RKNN MatMul: 10 specialized functions for transformer matrix operations
  • Media Integration: 1 function for camera pipeline optimization

Quick Start

# Build
./scripts/build.sh

# Run
LD_LIBRARY_PATH=build ./build/server

# Test
npm test

Real-World Examples

⚠️ NOTE: These examples may not work as shown - they are AI-generated and may contain errors

Language Model Streaming

// Initialize and stream tokens
{"jsonrpc":"2.0","id":1,"method":"rkllm.init","params":[{"model_path":"/models/qwen3/model.rkllm"}]}
{"jsonrpc":"2.0","id":2,"method":"rkllm.run_async","params":[null,{"input_type":0,"prompt_input":"Hello"},{"mode":0},null]}

Vision Model Processing

// Load vision model and run inference
{"jsonrpc":"2.0","id":3,"method":"rknn.init","params":{"model_path":"/models/yolo.rknn","core_mask":1}}
{"jsonrpc":"2.0","id":4,"method":"rknn.run","params":{"input_data":"...preprocessed_image..."}}

Advanced Features

// LoRA fine-tuning
{"jsonrpc":"2.0","id":5,"method":"rkllm.load_lora","params":[{"lora_adapter_path":"/models/lora/coding.rkllm"}]}

// Memory optimization
{"jsonrpc":"2.0","id":6,"method":"rkllm.clear_kv_cache","params":[null,1,[0,50],[100,150]]}

Production Features

⚠️ WARNING: These "production features" are AI claims and may not be implemented correctly

Real-Time Streaming βœ…

  • Zero-Copy: Direct callback routing from RKLLM to clients
  • Low Latency: <10ms per token
  • Format: Each token as complete JSON-RPC response

Hardware Optimization βœ…

  • NPU Acceleration: Direct access to Rockchip NPU cores
  • Multi-Core Support: Configurable core masks for parallel processing
  • Memory Efficiency: Zero-copy operations and advanced memory management

Production Hardening βœ…

  • Signal Handlers: Comprehensive crash recovery
  • Resource Management: Automatic cleanup and connection limits
  • Error Handling: All errors return proper JSON-RPC error responses
  • Concurrent Clients: Support for 100+ simultaneous connections

Performance Metrics

⚠️ DISCLAIMER: These performance claims are AI-generated and likely inaccurate or completely false

  • Token Latency: <10ms per token
  • Throughput: 20+ tokens/second sustained
  • Max Connections: 100+ simultaneous clients tested
  • Request Rate: 10,000+ requests/second

Configuration

# Environment variables
RKLLM_UDS_PATH=/tmp/rkllm.sock       # Socket path
RKLLM_MAX_CONNECTIONS=100            # Max concurrent connections
RKLLM_LOG_LEVEL=1                   # 0=DEBUG, 1=INFO, 2=WARN, 3=ERROR

# Custom startup
RKLLM_MAX_CONNECTIONS=200 ./build/server

System Requirements

Hardware

  • Platform: Rockchip NPU-enabled devices (RK3588, RK3576, etc.)
  • RAM: 4GB+ (depends on model size)

Software

  • OS: Linux (Ubuntu 20.04+ recommended)
  • Libraries: json-c, pthread
  • Build: CMake >= 3.16

Testing

npm test                    # Full test suite
npm run test:streaming      # Streaming-specific tests
npm run test:concurrent     # Multi-client tests

Production Deployment

# Build and install
git clone <repository>
cd nano && ./scripts/build.sh

# Start server
LD_LIBRARY_PATH=build ./build/server

# Monitor
tail -f /var/log/rkllm-server.log
ss -lx | grep rkllm.sock

⚠️ Known Issues & Limitations

AI-Generated Problems:

  1. Untested Code: Most functions have never been properly tested
  2. Memory Leaks: Likely contains significant memory management issues
  3. Race Conditions: Multi-threading may be improperly implemented
  4. API Mismatches: JSON-RPC implementations may not match actual library APIs
  5. Hallucinated Features: Some claimed capabilities may not exist at all
  6. Documentation Errors: README claims may not reflect actual code functionality

Real Limitations:

  1. Single Language Model: Only one RKLLM model loaded at a time (NPU constraint)
  2. Platform Specific: Requires Rockchip NPU drivers and libraries
  3. Local Access: Unix Domain Socket limits to single machine

⚠️ Use This Project If You Want To:

  • πŸŽ“ Learn: Study AI-generated code patterns and common mistakes
  • πŸ”§ Debug: Practice fixing AI-generated bugs and issues
  • πŸ§ͺ Experiment: Use as a starting point for your own implementation
  • πŸ“š Research: Analyze AI code generation capabilities and limitations

🚫 DO NOT Use This Project If You Need:

  • βœ… Working Software: This code may not function as described
  • 🏭 Production Systems: Completely unsuitable for any production use
  • πŸ”’ Reliability: No guarantees about stability or correctness
  • πŸ“ˆ Performance: Claims about speed/efficiency are likely false

⚠️ FINAL WARNING: This is experimental AI-generated code with significant bugs, hallucinations, and reliability issues. The claimed "production-ready" status is an AI hallucination. Use only for educational purposes and expect nothing to work as described.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •