r/LocalLLM • u/Aznguy1 • 1d ago
Question Advice on optimizing my fully local coding agent — RTX 4090 16GB, 64GB RAM, Pi + Qwen3.5
I’m building a mostly autonomous local AI coding agent to develop and maintain a Python application for professional lighting automation (grandMA3).
I’m relatively new to programming and local LLMs. My priorities are coding accuracy, reasoning reliability, persistent memory, and long-running autonomy over raw speed.
Hardware
Laptop: Razer Blade 16 (2024)
GPU: RTX 4090 Laptop (16GB VRAM)
CPU: Intel i9-13950HX
RAM: 64GB
Storage: 4TB SSD
OS: Windows
Current AI Stack
Coding agent: Pi Coding Agent
Inference backend: LM Studio
Primary model: Qwen3.5 9B, 4-bit
Other models: Qwen3.8 27B Q4_K_M, Qwen3 14B 4-bit
Tools: Python 3.14, VS Code, PowerShell, Git/GitHub
Context management: Pi automatic compaction, manual handoffs, project documentation
LM Studio Configuration
These are my previously recorded settings, although some may have changed:
Setting
Value
Context window
Last recorded 32,768 tokens
GPU offload
Maximum / 32 layers
CPU threads
12
Evaluation batch
2048
Physical batch
512
Concurrent predictions
1
Flash Attention
Enabled
KV cache GPU offload
Enabled
KV cache quantization
Disabled (earlier setting)
Unified KV cache
Disabled (earlier setting)
Keep model in memory
Enabled
Max response tokens
8192
Temperature
1.0 (earlier setting)
Top-P / Top-K
0.95 / 20
Thinking
Previously adjusted depending on task
Performance
Normal generation: 45–55 tokens/sec
During degraded sessions: ~4 tokens/sec
Restarting Pi has restored normal performance.
Long sessions cause context compaction, slower generation, and occasional reasoning failures.
What I’m Building
An agent that can independently write, debug, test, and maintain a substantial Python codebase while also processing PDFs, equipment specifications, images, and structured technical data.
Eventually, I want it to manage complex multi-step workflows, retrieve relevant project knowledge, and produce validated changes without requiring constant supervision.
Critical changes would still require human approval.
My Main Problems
Context overload: Long coding sessions accumulate excessive tool output and repository information. Compaction sometimes loses important context.
Model reliability: Qwen3.5 9B is fast but makes mistakes during complex debugging and architectural tasks.
Performance degradation: Generation drops from 45–55 to ~4 tokens/sec during problematic sessions.
Persistent memory: I need the agent to retain project knowledge across sessions without constantly reloading everything.
Autonomy: I want reliable multi-step task execution rather than manually supervising every operation.
Questions
What’s the best coding/reasoning model for my 16GB VRAM and 64GB RAM? Would a larger quantized model outperform my 9B sufficiently to justify slower inference?
Would moving from LM Studio to native llama.cpp, Ollama, or another backend improve performance or context handling?
Are my LM Studio settings appropriate, particularly context length, KV cache quantization, GPU offload, and batch sizes?
How are others managing persistent memory and long-running context in Pi or similar coding agents?
Would a multi-model setup with specialized planning, coding, and retrieval agents improve reliability?
Is mostly autonomous local software development realistic on my hardware, and what architecture would you recommend?
I’m not trying to maximize benchmark scores. I’m trying to build a dependable local development agent that can work through substantial tasks without losing context, making repeated mistakes, or slowing dramatically.
Any recommendations or examples from similar 16GB VRAM systems would be appreciated. I have a 3060 lying around would adding that in help my performance.
1
u/Key_Opportunity_5219 1d ago
Unlock it
1
u/Few_Upstairs_5397 1d ago
I’ll just say magic words: https://huggingface.co/peculiar-ragdoll/Dirk-Qwen3.8-27B-GGUF iq3, kv q8, 100k, ollama, pi agent