On-Premises AI Coding Platform: Architecture and Implementation Guide

    AI coding assistants boost developer productivity, but calling cloud-based LLM APIs raises concerns about code leakage, latency, and unpredictable costs. This article explains how to build an on-premises AI coding platform, covering hardware sizing, storage planning, model quantization, concurrency benchmarking, batching and scheduling, multi-tenant isolation, containerized deployment, monitoring, and phased rollout. All figures are starting reference values that should be validated against your own models and workloads.

    AI-assisted coding has become a common way to improve productivity in software development. However, enterprises that directly call cloud-based LLM APIs often face three problems: core code may be exposed externally, network latency hurts the responsiveness of code completion, and the cost of high-frequency calls is hard to predict. As a result, many teams choose to build an on-premises AI coding platform inside their own environment. This article answers the practical questions: how to build such a platform, how to select hardware, how to control concurrency, and how to operate it after launch.

    All numbers in this article are starting reference values. Adjust them based on measurements with your own models and workloads.

    1. Hardware Selection: Calculate VRAM First, Then Choose GPU Count

    Question: how much VRAM does one server need?

    The VRAM occupied by model weights can be roughly estimated as parameter count multiplied by bytes per parameter. For a 70B-parameter model, FP16 requires about 140 GB of weight memory, INT8 about 70 GB, and INT4 about 35 GB. You also need to reserve space for the KV cache and runtime overhead, typically an additional 20% to 40% on top of the weights, depending on maximum context length and concurrency.

    In multi-GPU setups, tensor parallelism requires inter-GPU communication. If the accelerators lack high-bandwidth interconnects, cross-GPU communication becomes the bottleneck, and throughput may not scale linearly with GPU count. When selecting hardware, confirm the inter-GPU interconnect bandwidth, the supported parallelism strategies, and whether the inference framework supports the chosen hardware.

    The CPUs handle request routing, preprocessing, and log writing. A dual-socket multi-core processor can cover these tasks, but verify that memory channel count and bandwidth are sufficient. Memory capacity should be sized for model loading and peak buffering; terabyte-scale memory provides more headroom when multiple models are loaded simultaneously.

    2. Storage Planning: Estimate by Data Type

    Storage capacity should be calculated separately for four categories of data:

    1. Model weights: each model version occupies tens to over a hundred GB; keeping rollback versions multiplies this figure.
    2. Code indexes and vector stores: proportional to codebase size. Measure the per-repository footprint with sample repos first, then extrapolate to the full codebase.
    3. Inference logs: calculated from daily request volume, average log entry size, and retention period.
    4. Buffers and temporary files: reserve a fixed percentage of total capacity.

    Example: 100,000 requests per day, 2 KB per log entry, retained for 90 days, requires about 18 GB. If logs include code snippets, entry size grows significantly—use real samples as the basis.

    Storage bandwidth matters as much as capacity. Model loading speed depends on sequential read bandwidth, while index updates depend on random read/write performance.

    3. Model Quantization and Inference Optimization

    Question: does quantization noticeably degrade code quality?

    INT8 quantization usually has minimal impact on quality, but INT4 losses on coding tasks need evaluation. Build an evaluation set from internal code samples and compare pass rates and completion acceptance rates across quantization schemes. For accuracy-sensitive tasks, such as security-related code review, pin those tasks to a higher-precision version.

    PagedAttention manages the KV cache in pages, reducing memory fragmentation so that a single GPU can serve more concurrent requests.

    FlashAttention reduces memory read/write operations through tiled computation, improving long-context inference speed. It does not reduce the theoretical computational complexity of attention, which still grows quadratically with sequence length. Its benefits depend on hardware and framework kernel support, so benchmark it on the target hardware before production.

    For long-context scenarios such as cross-file refactoring or global defect localization, validate the context length limit, time to first token, and VRAM usage together.

    4. Concurrency Capacity: Load Testing Over Rules of Thumb

    Question: how many developers can one server support?

    The answer depends on the model, quantization method, context length, and latency targets. There is no universal number to copy. The recommended approach:

    1. Define service objectives, e.g., P95 time to first token for code completion under a given millisecond value, and timeout ratio below a given threshold.
    2. Load test with a realistic request distribution: prompt lengths, the ratio of completion to review requests, and peak-hour request patterns.
    3. Gradually increase concurrency until latency exceeds the target, and record that concurrency level.
    4. Multiply that value by a safety factor (e.g., 0.7) as the capacity ceiling, leaving headroom for traffic bursts.
    5. Re-run load tests after every model version, quantization method, or driver change.

    5. Dynamic Batching and Priority Scheduling

    Dynamic batching merges requests arriving within a short window into one batch before sending them to the accelerator. Two key parameters require trade-offs:

    • max_batch_size: the batch size cap. Start with a conservative value within VRAM limits, then tune based on load tests.
    • max_wait_ms: the batching wait window. For completion scenarios, keep it small, e.g., single-digit to low-double-digit milliseconds. A larger window increases throughput but adds waiting time to each request.

    Recommended scheduling policies:

    • Code completion is high priority, uses a dedicated queue, and has a short timeout (e.g., return a degraded result if no response within 2 seconds).
    • Code review and documentation generation are low priority, have longer timeouts, and run when the queue is idle.
    • High-priority requests can be scheduled ahead in the queue, but should not preempt batches already executing on the GPU.

    6. Multi-Tenant Isolation and Access Control

    Isolation operates at three layers:

    • Access layer: rate-limit by user or team to prevent a single client from saturating the queue.
    • Container layer: set CPU and memory limits for each inference instance. GPUs are typically allocated as whole cards or partitions; sharing granularity depends on hardware and framework.
    • Data layer: request logs are redacted by default, access records go to audit logs, and code data access permissions stay consistent with repository permissions.

    7. Containerized Deployment and Elastic Scaling

    Running inference services in containers unifies the runtime environment and simplifies model switching. When using orchestration tools such as Kubernetes:

    • Use GPU-aware scheduling to allocate resources to inference instances.
    • Use canary releases: route a small share of traffic to a new model first, then fully switch over after metrics meet targets.
    • Configure health checks so unhealthy instances are automatically removed and restarted.
    • Base elastic scaling on queue depth and GPU utilization rather than CPU metrics alone. The bottleneck in inference services is usually the accelerator.

    8. Monitoring Metrics and Alert Severity

    At minimum, collect these metrics:

    • GPU utilization and VRAM usage
    • P95 and P99 latency of completion requests
    • Queue depth
    • Error rate and timeout rate
    • Token throughput

    Example alert thresholds (adjust to your actual baseline):

    • Warning: VRAM usage above 90% for 5 consecutive minutes, or queue depth persistently above the configured value.
    • Critical: error rate above 1% for 5 consecutive minutes, or completion P95 latency exceeding twice the target.

    When an alert fires, operators should first check whether abnormally long requests are occupying batches, then check for instances repeatedly restarting, and finally decide whether to scale out or degrade to a smaller model.

    9. Phased Rollout and Acceptance Criteria

    Phase 1: single-node pilot. Select one model and one quantization scheme, invite a small team to use it, complete load testing, and record the baseline.

    Phase 2: expand to multiple nodes. Allocate teams according to tested capacity, and establish canary release and alerting mechanisms.

    Phase 3: steady-state operations. Regularly evaluate model versions and continuously optimize batching parameters and index update strategies.

    Acceptance can reference these indicators:

    • Completion P95 latency meets the preset target.
    • Single-node capacity is clearly documented in the load test report.
    • Code quality on the evaluation set is no lower than the agreed baseline.
    • Log redaction and access auditing pass internal security review.
    • Rollback can be completed within the agreed time when failures occur.

    On-premises deployment is not a one-time procurement task but a systems engineering effort that requires continuous measurement and tuning. Only by turning hardware, model, scheduling, and operations parameters into reproducible test results can you judge whether the platform fits your team.