bluegreencity-ki

LLM Setup and Configuration Guide

This guide covers setting up local LLM (Large Language Model) infrastructure on the workstation for AI-assisted development.

Primary solution: vLLM — a Docker container serving unsloth/Qwen3.8-27B-NVFP4 on port 8080. It replaces the earlier LM Studio, Ollama, and llama.cpp setups.

Estimated setup time: 30-45 minutes (vLLM is pre-configured in the repository)


Overview

This guide covers:


Part 1: vLLM Setup (primary)

vLLM is the primary local LLM server. It runs in a Docker container and serves the unsloth/Qwen3.8-27B-NVFP4 model via an OpenAI-compatible API on port 8080. It replaces the earlier LM Studio, Ollama, and llama.cpp setups.

1.1 Why vLLM

1.2 Prerequisites

1.3 Starting the vLLM Server

.\scripts\local-llm\start_vllm_server.ps1

The script:

API endpoint: http://localhost:8080/v1

1.4 Stopping the vLLM Server

docker rm -f vllm-qwen38-27b

1.5 Configuration

The server is configured in scripts/local-llm/docker-compose.vllm.yml. Key parameters:

Current configuration (2026-09-15):

Parameter Value Purpose
--max-model-len auto Auto-fit to available KV memory (→ 262k native on 96 GB @ 0.9)
--max-num-seqs 8 Max parallel sequences (recipe value for rtx_pro_6000)
--tensor-parallel-size 1 Single GPU
--gpu-memory-utilization 0.9 VRAM budget for weights + KV cache + CUDA graphs
--mm-encoder-tp-mode data Data-parallel vision encoder (recipe default)
--speculative-config mtp, 5 tokens MTP speculative decoding (recipe-verified for rtx_pro_6000 / dgx_spark_gb10)
--enable-auto-tool-choice — Tool-choice routing (active with the current VLLM_USE_RUST_FRONTEND=0)
--reasoning-parser qwen3 Parse thinking blocks
--tool-call-parser qwen3_coder Tool calling (official recipe parser)
--chat-template /opt/chat_templates/qwen3.8-froggeric-v22.3.jinja froggeric v22.3 fixed chat template (JSON-string tool args, empty-think poisoning)
--default-chat-template-kwargs enable_thinking: true, preserve_thinking: true, reasoning_effort: medium Server-wide thinking level (medium = model default; override per request)
--async-scheduling — Overlap request scheduling with GPU execution (recipe-verified for this GPU)

V1 defaults (not in compose): enable_prefix_caching and enable_chunked_prefill are on by default in vLLM V1. kv_cache_dtype resolves to fp8 (torch.float8_e4m3fn) automatically for this mixed-precision NVFP4 checkpoint (confirmed in the startup log). max_num_batched_tokens defaults to 8192 (matches the recipe value for this GPU).

Environment (compose environment): VLLM_USE_RUST_FRONTEND=0 — the experimental Rust frontend is disabled (since 2026-09-16): while it was enabled it produced weird/mangled model responses, so it was switched off for output quality. While enabled it had improved decode throughput but also lacked --hf-overrides support (see 1.6 long-context note); with =0, --hf-overrides is supported again. VLLM_WSL2_ENABLE_PIN_MEMORY=1 avoids the WSL2 pinned-memory issue.

The model is multimodal (text + image + video, vision_config in the checkpoint); audio is not supported. Image tokens count against the context length (~2.3k tokens per 1920×1200 image).

Per-request thinking override: pass chat_template_kwargs (e.g. {"reasoning_effort":"low"} or {"enable_thinking":false}).

1.6 Performance Tuning

Current setup (measured 2026-09-15) — 262k native / 8 seqs / MTP=5 / async-scheduling / reasoning_effort: xhigh; warm server, short prompts, RTX PRO 6000 Blackwell (96 GB VRAM). Measured with the Rust frontend enabled; it was disabled again on 2026-09-16 (see findings)

Change Result (short prompt, no thinking, ~300 tokens)
MTP=3, no async-scheduling (cold) ~109 tok/s
MTP=3 (warm) ~148–153 tok/s
MTP=5 (recipe-verified value for this GPU) ~200 tok/s
MTP=5 + --async-scheduling (current) ~230 tok/s

Earlier tuning (2026-08-19/21) — RTX PRO 6000 Blackwell (96 GB VRAM), 50k–225k-token prompts, 1–8 parallel requests:

Config KV Pool Generation Throughput MTP Acceptance
1M / 16 seqs (original) very small 0.2–0.5 tokens/s 0–75% (volatile, long 0% stretches)
512k / 8 seqs 1.89M tokens 125–161 tokens/s 41–58%
262k native / 8 seqs 1.82M tokens ~127 tokens/s 43–53%
1M / 6 seqs 1.92M tokens 85–120 tokens/s 65–66%
512k / 4 seqs (then) 1.89M tokens 30–76 tokens/s (long contexts) 60–95% (content-dependent)

Findings:

1.7 Monitoring

# Live engine metrics (throughput, KV-cache usage, MTP acceptance)
docker logs vllm-qwen38-27b 2>&1 | Select-Object -Last 10

# Prometheus metrics
curl -s http://localhost:8080/metrics

Key metrics to watch:

1.8 Logs

Startup and runtime logs are written to logs/vllm/vllm_start_YYYYMMDD_HHMMSS.log.

✓ Checkpoint: vLLM server is running at http://localhost:8080/v1

Legacy: LM Studio (superseded by vLLM)

The following LM Studio instructions are kept for reference only. vLLM (above) is the current primary local LLM server.

1.1 Installation

  1. Download LM Studio:
    • Visit https://lmstudio.ai/
    • Download the installer for Windows
    • Run the installer and follow the prompts
    • Default installation location: C:\Users\<YourUsername>\AppData\Local\Programs\LM Studio
  2. Launch LM Studio:
    • Start LM Studio from the Start Menu or desktop shortcut
    • Accept the terms of service on first launch

1.2 Downloading Models

LM Studio has a built-in model browser to download LLMs:

  1. Open the Model Browser:
    • Click on the 🔍 Search icon in the left sidebar
  2. Browse Available Models:
    • Explore the model browser to find models suitable for your hardware
    • Consider your available VRAM when selecting a model
    • See the “Recommended Models by Use Case” section (Part 8) for specific recommendations
  3. Download a Model:
    • Search for the model name (e.g., “DeepSeek-Coder”)
    • Click the Download button next to your preferred quantization:
      • Q4_K_M - Good balance (recommended for most users)
      • Q5_K_M - Higher quality, more memory
      • Q8_0 - Highest quality, requires significant memory
    • Wait for download to complete (models are 4-16 GB)

Note: Models are stored in: C:\Users\<YourUsername>\.cache\lm-studio\models

1.3 Loading and Configuring a Model

  1. Load a Model:
    • Click the 💬 Chat icon in the left sidebar
    • At the top, click “Select a model to load”
    • Choose your downloaded model from the list
    • Wait for the model to load into memory (10-30 seconds)
  2. Configure Model Parameters:

    Click the ⚙️ Settings icon (top-right of chat window) to adjust:

    Context Length:

    • Default: 2048 tokens
    • Recommended for code: 4096 - 8192 tokens
    • Higher = more context but slower inference
    • Check your model’s maximum context length

    Temperature:

    • Range: 0.0 (deterministic) to 2.0 (creative)
    • For code generation: 0.1 - 0.3 (more precise)
    • For creative writing: 0.7 - 1.0 (more varied)
    • Default: 0.7

    Top P (Nucleus Sampling):

    • Range: 0.0 to 1.0
    • Default: 0.95
    • Lower = more focused, Higher = more diverse

    Repeat Penalty:

    • Range: 1.0 (no penalty) to 1.5 (high penalty)
    • Default: 1.1
    • Prevents the model from repeating itself

    GPU Layers:

    • Default: Auto (recommended)
    • Manually set if you want to offload more/less to GPU
    • More layers = faster but uses more VRAM
  3. System Prompt (Optional):

    Configure the model’s behavior with a system prompt:

    You are an expert Python and geospatial data scientist. You help with 
    code for analyzing urban tree drought risk using GeoPandas, PostGIS, 
    and related libraries. Provide clear, well-documented code examples.
    

    Click “Save Preset” to reuse this configuration.

1.4 Starting the API Server

LM Studio includes an OpenAI-compatible API server:

  1. Open Server Tab:
    • Click the 🔌 Local Server icon in the left sidebar
  2. Configure Server:
    • Port: Default is 1234 (do not change unless needed)
    • CORS: Enable “Allow CORS requests” if accessing from web apps
    • API Key: Optional - leave empty for local development
  3. Select Model:
    • Choose the model to serve from the dropdown
    • Use the same model you loaded earlier
  4. Start Server:
    • Click the green “Start Server” button
    • Server URL: http://127.0.0.1:1234/v1
    • Keep LM Studio running while the server is active
  5. Test the Server:

    Open PowerShell and test with curl:

    curl http://127.0.0.1:1234/v1/models
    

    You should see a JSON response with your loaded model.

✓ Checkpoint: LM Studio server is running at http://127.0.0.1:1234/v1

1.5 Resources for LM Studio

Official Documentation:

Community Resources:

Understanding Model Parameters:


Part 2: GitHub Copilot Integration (15 minutes)

Connect GitHub Copilot in VSCode to use your local vLLM model instead of OpenAI.

Prerequisites:

2.1 Configure GitHub Copilot Chat

  1. Open VSCode Settings:
    • Press Ctrl+, (or Cmd+, on macOS)
    • Or: File → Preferences → Settings
  2. Search for Copilot Settings:
    • Type: github.copilot.chat.localhostChatModels
  3. Add Local Model Configuration:

    Click “Edit in settings.json” and add:

    {
      "github.copilot.advanced": {
        "debug.overrideEngine": "local"
      },
      "github.copilot.chat.localhostChatModels": [
        {
          "model": "vllm",
          "endpoint": "http://127.0.0.1:8080/v1/chat/completions",
          "name": "vLLM Qwen3.8-27B (Local)"
        }
      ]
    }
    
  4. Important: Use /v1 endpoint:
    • ✅ Correct: http://127.0.0.1:8080/v1/chat/completions
    • ❌ Wrong: http://127.0.0.1:8080/chat/completions
    • The /v1 is required for OpenAI API compatibility
  5. Reload VSCode:
    • Press Ctrl+Shift+P (or Cmd+Shift+P on macOS)
    • Type: “Developer: Reload Window”
    • Press Enter

2.2 Using Local LLM in Copilot

  1. Open Copilot Chat:
    • Click the Copilot icon in the Activity Bar (left sidebar)
    • Or press Ctrl+Shift+I (Windows/Linux) or Cmd+Shift+I (macOS)
  2. Select Local Model:
    • At the top of the chat panel, click the model dropdown
    • Select “vLLM Qwen3.8-27B (Local)”
  3. Test the Integration:

    Try a simple prompt:

    Explain how to read a GeoPackage with GeoPandas
    

    The response should come from your local vLLM model.

2.3 Limitations and Notes

Current Limitations:

Performance Tips:

Troubleshooting:

2.4 llama.cpp Server Autostart on Windows Boot (legacy)

Note: llama.cpp is superseded by vLLM (Part 1). The llama.cpp autostart task is kept for reference only. The vLLM container is managed via start_vllm_server.ps1 and does not require a Windows Scheduled Task.

For the shared workstation, the repository also supports a local llama.cpp server that starts automatically during Windows boot, even before a user signs in.

Why this setup exists:

Managed scripts in this repository:

Registration command:

pwsh -NoProfile -File scripts/local-llm/register_llama_server_startup.ps1

This creates the task BlueGreenCity-KI llama.cpp server with these properties:

VS Code tasks:

Operational details:

Verify registration:

Get-ScheduledTask -TaskName 'BlueGreenCity-KI llama.cpp server'

Manual test run:

Start-ScheduledTask -TaskName 'BlueGreenCity-KI llama.cpp server'
Get-ScheduledTaskInfo -TaskName 'BlueGreenCity-KI llama.cpp server'

Verification target:

Removal command:

pwsh -NoProfile -File scripts/local-llm/unregister_llama_server_startup.ps1

✓ Checkpoint: GitHub Copilot Chat uses the local vLLM model


Part 3: KiloCode Extension (Alternative) (10 minutes)

KiloCode is an alternative AI coding assistant that works with local LLM servers.

3.1 Installation

  1. Install KiloCode Extension:
    • Open VSCode Extensions (Ctrl+Shift+X)
    • Search for: “KiloCode”
    • Click Install
  2. Open KiloCode Settings:
    • Press Ctrl+, and search for kilocode
    • Or click the gear icon next to KiloCode in Extensions

3.2 Configuration

  1. Set OpenAI-Compatible Endpoint:

    In VSCode settings.json:

    {
      "kilocode.apiEndpoint": "http://127.0.0.1:8080/v1",
      "kilocode.model": "unsloth/Qwen3.8-27B-NVFP4",
      "kilocode.apiKey": "not-needed"
    }
    
  2. Configure Model Parameters (Optional):

    {
      "kilocode.temperature": 0.2,
      "kilocode.maxTokens": 2048
    }
    

3.3 Usage

  1. Open KiloCode Panel:
    • Click the KiloCode icon in the Activity Bar
    • Or use the command palette: Ctrl+Shift+P → “KiloCode: Open”
  2. Ask Questions:
    • Type your question or code request
    • Press Enter to submit
    • The local LLM will respond
  3. Code Actions:
    • Select code in editor
    • Right-click → KiloCode → Choose action:
      • Explain Code
      • Refactor
      • Add Comments
      • Generate Tests

✓ Checkpoint: KiloCode is configured and working with local LLM


Part 4: MCP Server Setup (20-25 minutes)

Model Context Protocol (MCP) allows LLMs to access external tools like databases.

4.1 Understanding MCP

What is MCP?

Architecture:

vLLM (LLM) ←→ MCP Client ←→ MCP Server ←→ Database/Tools

4.2 Installing Docker MCP Hub

Docker MCP Hub provides pre-configured MCP servers in containers.

  1. Prerequisites:
    • Docker Desktop for Windows installed
    • Docker running (check system tray for Docker icon)
    • Basic Docker knowledge
  2. Install Docker MCP Hub:

    Open PowerShell and run:

    # Clone the Docker MCP Hub repository
    git clone https://github.com/docker/mcp-hub.git
    cd mcp-hub
       
    # Start the hub
    docker-compose up -d
    
  3. Verify Installation:

    docker ps
    

    You should see MCP Hub containers running.

4.3 Setting Up Database MCP Server

Configure MCP to access the PostGIS database:

  1. Configure Database Connection:

    Create mcp-config.json in the MCP Hub directory:

    {
      "mcpServers": {
        "postgres": {
          "command": "docker",
          "args": [
            "run",
            "--rm",
            "-e", "POSTGRES_CONNECTION_STRING=postgresql://postgres:your_password@host.docker.internal:5432/bgcki",
            "mcp/postgres"
          ]
        }
      }
    }
    

    Replace your_password with the actual database password from .env

  2. Test Database Connection:

    # From the mcp-hub directory
    docker run --rm `
      -e "POSTGRES_CONNECTION_STRING=postgresql://postgres:your_password@host.docker.internal:5432/bgcki" `
      mcp/postgres test
    
  3. Available Database Operations:

    • Query tables
    • Read schemas
    • Execute SQL (read-only by default)
    • List available tables and views

4.4 Connecting the LLM to MCP

Note: vLLM exposes an OpenAI-compatible API but does not include a native MCP client. Use an MCP-capable front end (Claude Desktop, Open WebUI, or AnythingLLM) to connect the LLM to MCP servers.

Option A: Use Claude Desktop with MCP (Recommended)

{
  "mcpServers": {
    "postgres": {
      "command": "docker",
      "args": [
        "run", "--rm",
        "-e", "POSTGRES_CONNECTION_STRING=postgresql://postgres:password@host.docker.internal:5432/bgcki",
        "mcp/postgres"
      ]
    }
  }
}

Option B: Use AnythingLLM with MCP Bridge

✓ Checkpoint: MCP Server is running and accessible


Part 5: AnythingLLM and Open WebUI (15-20 minutes)

Web interfaces for interacting with local LLMs.

5.1 AnythingLLM Setup

AnythingLLM is a full-featured AI document chat and assistant application.

  1. Download and Install:
    • Visit: https://anythingllm.com/
    • Download the Windows installer
    • Install with default settings
  2. First Launch Configuration:
    • Launch AnythingLLM
    • Choose “OpenAI Compatible” as the LLM provider
    • Enter connection details:
      • Base URL: http://127.0.0.1:8080/v1
      • API Key: (leave empty)
      • Model: unsloth/Qwen3.8-27B-NVFP4
  3. Create a Workspace:
    • Click “New Workspace”
    • Name: “BlueGreenCity Development”
    • Configure:
      • LLM: Your vLLM model
      • Temperature: 0.7 (adjust as needed)
      • Context length: 4096
  4. Add Documents (Optional):
    • Click “Upload Documents”
    • Add project documentation, code files, or PDFs
    • AnythingLLM will create embeddings for semantic search
  5. Connect to Database (via MCP):
    • Settings → Integrations
    • Add MCP connection (if supported)
    • Or use SQL query plugin

5.2 Open WebUI Setup

Open WebUI (formerly Ollama WebUI) is a self-hosted ChatGPT-style interface.

  1. Install with Docker:

    docker run -d -p 3000:3000 `
      --name open-webui `
      -v open-webui:/app/backend/data `
      ghcr.io/open-webui/open-webui:main
    

    Note: Open WebUI’s internal port is 8080, which conflicts with the vLLM host port. Map it to host port 3000 instead.

  2. Access the Interface:
    • Open browser: http://localhost:3000
    • Create admin account on first launch
  3. Configure vLLM Connection:
    • Click Settings (gear icon)
    • Connections → Add Connection
    • Name: “vLLM”
    • API Base URL: http://host.docker.internal:8080/v1
    • API Key: (leave empty)
    • Save
  4. Select Model:
    • In chat interface, click model dropdown
    • Select unsloth/Qwen3.8-27B-NVFP4
    • Start chatting!
  5. Advanced Features:
    • Documents: Upload and chat with documents
    • Functions: Add custom tools and integrations
    • Prompt Library: Save and share prompts
    • Multi-user: Create accounts for team members

5.3 Comparison: AnythingLLM vs Open WebUI

Feature AnythingLLM Open WebUI
Installation Desktop app Docker container
Document Chat ✅ Excellent ✅ Good
UI/UX Clean, modern ChatGPT-like
Multi-model ✅ Yes ✅ Yes
Customization High Very High
Plugins Growing Extensive
Best for Document Q&A General chat

Recommendation: Use both!

✓ Checkpoint: Web UI is running and connected to the vLLM server


Part 6: Usage Workflows

Workflow 1: Code Assistance with VSCode

  1. Start the vLLM server (.\scripts\local-llm\start_vllm_server.ps1)
  2. Connect via SSH to workstation in VSCode
  3. Use GitHub Copilot Chat with the local vLLM model
  4. Ask for code help, explanations, or refactoring

Example Prompts:

Workflow 2: Document Q&A with AnythingLLM

  1. Upload project documentation to AnythingLLM
  2. Ask questions about the project
  3. Get answers grounded in your actual docs

Example:

Workflow 3: Database Queries with MCP

  1. Connect Claude Desktop or Open WebUI to MCP
  2. Ask questions about the database
  3. LLM generates and executes SQL queries

Example:

Workflow 4: Research and Exploration

  1. Use Open WebUI for general questions
  2. Test different models for quality comparison
  3. Save useful prompts to prompt library

Part 7: Best Practices

Model Selection

For Code:

For Chat/Docs:

Performance Optimization

Hardware:

Configuration:

Security Considerations

Local LLMs:

API Security:

Database Access:

Troubleshooting Common Issues

Issue: vLLM API not responding

Issue: VSCode can’t connect to local model

Issue: Slow inference

Issue: Out of memory / KV-cache exhaustion


Part 8: Resources and Further Reading

Official Documentation

vLLM:

Qwen3.8-27B (Unsloth NVFP4):

Model Context Protocol (MCP):

AnythingLLM:

Open WebUI:

Community Resources

Forums and Communities:

Model Leaderboards:

Learning Resources:

Code Generation:

  1. GPT-OSS-20B - High-quality open-source code generation
  2. GPT-OSS-120B - Enterprise-grade code generation (requires significant VRAM)
  3. DeepSeek-Coder-V2-Lite-Instruct (16B)
  4. CodeLlama-13B-Instruct
  5. Phind-CodeLlama-34B-v2

General Chat:

  1. Llama-3.1-8B-Instruct
  2. Mistral-7B-Instruct-v0.3
  3. Mixtral-8x7B-Instruct

Document Q&A:

  1. Llama-3.1-8B-Instruct
  2. Mistral-7B-Instruct-v0.3
  3. Zephyr-7B-Beta

Small/Fast (< 7B):

  1. Phi-3-Mini-Instruct (3.8B)
  2. TinyLlama-1.1B
  3. Gemma-2B-Instruct

Experimental:

  1. Apertus - Cutting-edge experimental model (may be unstable)

Appendix A: Quick Reference

vLLM

VSCode Copilot Configuration

{
  "github.copilot.chat.localhostChatModels": [
    {
      "model": "vllm",
      "endpoint": "http://127.0.0.1:8080/v1/chat/completions",
      "name": "vLLM Qwen3.8-27B (Local)"
    }
  ]
}

Docker Commands

# Start vLLM
.\scripts\local-llm\start_vllm_server.ps1

# Stop vLLM
docker rm -f vllm-qwen38-27b

# View vLLM logs
docker logs -f vllm-qwen38-27b

# Start Open WebUI (host port 3000 to avoid vLLM's 8080)
docker run -d -p 3000:3000 --name open-webui ghcr.io/open-webui/open-webui:main

Useful Ports


Appendix B: Alternative Setup - Ollama (legacy)

Note: Ollama is superseded by vLLM (Part 1). This appendix is kept for reference only.

For a more lightweight, CLI-focused approach, consider Ollama:

Installation

# Windows (native)
winget install Ollama.Ollama

# Or download from: https://ollama.com/download

Basic Usage

# Run a model
ollama run codellama

# List models
ollama list

# Pull a model
ollama pull mistral

# Serve API
ollama serve  # Runs on port 11434

Connect to VSCode

{
  "github.copilot.chat.localhostChatModels": [
    {
      "model": "ollama",
      "endpoint": "http://127.0.0.1:11434/v1/chat/completions",
      "name": "Ollama (Local)"
    }
  ]
}

When to use Ollama:


Support and Questions

For questions or issues:

  1. Check the troubleshooting section above
  2. Consult official documentation links
  3. Ask in the project’s internal communication channel
  4. Refer to Workstation_Remote_Development.md for SSH setup issues

Last updated: August 2026