File size: 6,802 Bytes
6379283
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2088481
6379283
2088481
6379283
2088481
 
 
 
 
 
 
 
 
 
 
 
 
6379283
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# Stack 2.9 Benchmarks & Performance

This document provides detailed performance benchmarks and context length tradeoffs for Stack 2.9.

## Context Window: 128K vs 32K

Stack 2.9 supports a full 128K token context window (131072 tokens), enabling complete repository awareness and cross-file understanding.

### Memory Requirements by Context Length

| Context Length | KV Cache (4-bit) | KV Cache (BF16) | Total with 4-bit Model | Total with BF16 Model |
|----------------|------------------|-----------------|------------------------|-----------------------|
| 8K             | ~3.4 GB          | ~6.8 GB         | ~10 GB                 | ~20 GB                |
| 16K            | ~6.8 GB          | ~13.6 GB        | ~13 GB                 | ~27 GB                |
| 32K            | ~13.6 GB         | ~27.2 GB        | ~20 GB                 | ~40 GB                |
| 64K            | ~27.2 GB         | ~54.4 GB        | ~34 GB                 | ~61 GB                |
| **128K**       | **~54.4 GB**     | **~108.8 GB**   | **~60 GB**             | **~115 GB**           |

**Note:** Estimates based on Qwen2.5-Coder-32B with 64 layers, 5120 hidden size. Actual usage varies by batch size and optimization.

### When to Use 128K vs 32K

#### Use 128K when:
- **Large codebases**: Need to understand entire repository structure (>1000 files)
- **Cross-file refactoring**: Renaming/moving symbols across multiple files
- **Complex architectural changes**: Understanding dependencies and impact analysis
- **Full documentation loading**: Loading entire API docs or specs in context
- **Long conversations**: Extended multi-turn dialogue with context retention

#### Use 32K when:
- **Single-file tasks**: Editing one file at a time
- **Limited GPU memory**: Consumer GPUs (24GB or less) can use quantization
- **Higher throughput needed**: Max tokens/sec is ~40% higher at 32K
- **Quick responses**: Simple code generation or Q&A
- **Batch processing**: Processing many independent requests

### Throughput Impact

Measured on A100 80GB with vLLM + AWQ 4-bit:

| Context Length | Tokens/sec (batch=1) | Relative Speed | Latency (first token) |
|----------------|---------------------|----------------|----------------------|
| 8K             | ~80                 | 100%           | ~50ms                |
| 16K            | ~70                 | 87%            | ~80ms                |
| 32K            | ~60                 | 75%            | ~120ms               |
| 64K            | ~45                 | 56%            | ~220ms               |
| **128K**       | **~40**             | **50%**        | **~400ms**           |

**Key Insight**: Throughput decreases roughly linearly with context length due to:
- Larger KV cache to manage
- More attention computation (O(nΒ²) complexity)
- Memory bandwidth limitations

### GPU Recommendations

| GPU | 4-bit 32K | 4-bit 128K | BF16 32K | BF16 128K |
|-----|-----------|-------------|----------|-----------|
| RTX 4090 (24GB) | βœ… | ⚠️ marginal | ❌ no | ❌ no |
| A100 40GB | βœ… | ⚠️ tight | ❌ no | ❌ no |
| **A100 80GB** | βœ… comfortable | βœ… works | βœ… | ⚠️ tight |
| **H100 80GB** | βœ… | βœ… comfortable | βœ… | βœ… |
| H200 141GB | βœ… | βœ… | βœ… | βœ… |

## Model Performance Benchmarks

⚠️ **Evaluation Status**: The benchmark scores previously claimed (76.8% HumanEval, 82.3% MBPP, 94.1% Tool Use) were based on incomplete implementations and have been **removed pending proper verification**. See [EVALUATION.md](../EVALUATION.md) for the audit report.

### Coding Benchmarks (Actual Baseline Expectations)

| Benchmark | Status | Notes |
|-----------|--------|-------|
| **HumanEval** | Pending | Full 164-problem evaluation in progress |
| **MBPP** | Pending | Full 500-problem evaluation in progress |
| **Tool Use** | Pending | Custom tool-calling benchmark to be created |
| **GSM8K** | Not started | Math reasoning evaluation planned |
| **Context** | βœ… 128K | Token context window tested |

**Expected Baseline** (Qwen2.5-Coder-32B, unquantized):
- HumanEval: ~70-72% Pass@1
- MBPP: ~75-77% Pass@1

Stack 2.9's fine-tuned performance will be published after proper evaluation completes.

### Voice-First Features

| Metric | Value |
|--------|-------|
| Voice Cloning Time | 10-30 seconds of audio |
| Speech Synthesis | Real-time (~2x faster than playback) |
| Voice Model Size | ~50-200 MB per voice |
| Multi-language | EN, AR, ES, FR, DE |
| Audio Quality | 44.1kHz, 16-bit PCM |

## Deployment Performance

### Local Deployment (A100 80GB)

- **Cold start time**: ~60 seconds (model loading)
- **Memory footprint**: ~60 GB (4-bit, 128K context)
- **Average throughput**: 40 tokens/sec (128K context)
- **P99 latency**: <2s for 512 token responses
- **Concurrent requests**: 8-16 (depending on batch size)

### Cloud Deployment (RunPod/Vast)

- **Cost**: ~$0.30-$0.50/hour for A100 80GB
- **Availability**: High in US/EU regions
- **Scaling**: Easy horizontal scaling with load balancer
- **Bandwidth**: 1Gbps typical

## Trade-offs Summary

### Pros of 128K Context
- βœ… Complete repository awareness
- βœ… Cross-file refactoring with full understanding
- βœ… Load entire documentation/specs
- βœ… Maintain conversation history
- βœ… No artificial truncation

### Cons of 128K Context
- ❌ 40-60GB memory required (4-bit)
- ❌ ~30% slower throughput vs 32K
- ❌ Higher GPU memory bandwidth needs
- ❌ More expensive hardware required
- ❌ Slower cold starts

### Optimization Strategies

1. **Dynamic Context**: Start with 32K, expand to 128K only when needed
2. **Pre-filtering**: Use RAG to retrieve relevant files before loading full context
3. **Streaming**: Stream responses to avoid waiting for full generation
4. **Quantization**: Use AWQ 4-bit to halve memory requirements
5. **Attention Optimization**: FlashAttention-2 for faster attention computation

## Recommendations

### For Production:
- Start with 32K context for most deployments
- Enable 128K only for enterprise customers with large codebases
- Use automatic scaling based on request complexity

### For Development:
- Use 128K locally for complex refactoring
- Switch to 32K for daily coding to save resources
- Benchmark with your specific codebase to find optimal setting

### For Evaluation:
- Test with both context lengths on your specific tasks
- Measure memory usage with `nvidia-smi` during inference
- Consider quality vs speed tradeoff for your use case

## Testing Your Deployment

Run the included test script to validate your 128K setup:

```bash
cd stack-2.9-eval
python context_length_test.py --model-path /models --max-context 131072
```

This will:
- Generate 128K token dummy input
- Test tokenizer handling
- Estimate memory requirements
- Optionally test with loaded model (if available)