How to Deploy a 27B Model on an Internal Server and Control Token Costs
In situations where external APIs cannot be used due to security regulations, deploying a 27B model to your own server becomes necessary. Budgets are insufficient to purchase expensive H100s, and monthly token costs are snowballing. This post covers concrete, practical methods to save over 40% on hardware budgets in an on-premise environment while blocking infinite loop token waste.
Multi-GPU Configuration to Reduce Hardware Budgets
To run a 27B model without OOM, you need to accurately calculate VRAM requirements. Instead of buying a single Nvidia H100 80GB, bundle two RTX 4090 24GB cards to create 48GB of unified VRAM. Using this approach can lower initial hardware setup costs by more than half.
- Add the model weights (approx. 28GB based on FP8) and the KV cache (1GB based on an 8K context) to ensure the total required VRAM does not exceed 30GB.
- In environments without NVLink, specify the
--tensor-parallel-size 2 option when running vLLM to distribute computations within the PCIe bandwidth.
- To handle peak power draw exceeding 1000W from two RTX 4090s, use an 80 Plus Titanium certified power supply and prevent thermal throttling with front intake fans.
There is no need to obsess over single high-priced devices. Bundling cheaper graphics cards in parallel is a realistic alternative for infrastructure teams under budget pressure.
Engine Settings to Prevent Infinite Loop Token Consumption
Recently, when processing complex logic, 27B models often fail to output an end token and loop infinitely up to the maximum token limit. In commercial API environments, this single phenomenon alone causes monthly operating costs to swell to unmanageable levels. Tweaking parameters in your local serving engine can definitively curb this waste.
- Suppress the occurrence of repetitive sentences by assigning
repeat_penalty 1.15 and presence_penalty 0.1 to the serving parameters.
- Add
<|im_end|>, <|eot_id|>, and \nUser: to the stop array in the configuration file to force the model from continuing a self-dialogue.
- Apply
temperature 0.2 and min_p 0.05 to bind the model so it does not touch low-probability tokens.
Applying these settings reduces the average output token count from 4,000 to 800. Even including power bills and equipment depreciation, monthly operating costs per unit can be controlled around the $290 mark.
Weight Deployment and Pipeline Management in Air-Gapped Environments
In completely air-gapped environments cut off from external networks, a pipeline that stably manages and serves weights is essential. By utilizing vLLM, you can open API endpoints with speeds comparable to commercial services even within internal corporate networks.
- Download weights using
huggingface-cli on an internet-connected bastion host, and use the --local-dir-use-symlinks False option to download into a single-file structure.
- Increase RAG context reusability and prevent VRAM fragmentation by applying
--enable-prefix-caching and --gpu-memory-utilization 0.92 when running vLLM.
- Continuously monitor the Prometheus endpoint (
/metrics), and if the vllm:gpu_cache_usage_factor metric exceeds 90%, immediately lower --max-model-len from 16384 to 8192.
The only way to control costs while complying with internal security policies is ultimately to build it yourself and monitor the metrics.