rhui96 commited on
Commit
603ea25
·
verified ·
1 Parent(s): ccf1990

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +149 -5
app.py CHANGED
@@ -8,7 +8,7 @@ A comprehensive tool for estimating VRAM requirements and recommending optimal
8
  GPU configurations for Large Language Model (LLM) deployment and training.
9
 
10
  Author: Rudali Huidrom
11
- Version: 3.0.0
12
  First Written On: 08 December 2025
13
 
14
  Overview
@@ -88,8 +88,13 @@ HF_TOKEN = os.getenv("HF_TOKEN", "")
88
  # - Budget tier: Green gradient for cost-effective options
89
  # - Runner-up tier: Blue gradient for balanced options
90
  # - Performance tier: Purple gradient for maximum performance
 
 
91
  CUSTOM_CSS = """
92
  <style>
 
 
 
93
  .budget-box {
94
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%) !important;
95
  border: 2px solid #22c55e !important;
@@ -125,6 +130,137 @@ CUSTOM_CSS = """
125
  padding: 12px !important;
126
  margin: 8px 0 !important;
127
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  </style>
129
  """
130
 
@@ -476,7 +612,7 @@ GPU_DATABASE = [
476
  # Based on real-world benchmarks from MLPerf, vendor data, and community testing
477
  # Tokens per second per GPU for different model sizes
478
  #
479
- # Last Updated: 15 December 2025
480
  # Sources:
481
  # - MLPerf Training v3.1 (November 2023)
482
  # - NVIDIA TensorRT-LLM benchmarks (Q4 2024)
@@ -790,10 +926,18 @@ def calculate_throughput(
790
  # Get base throughput per GPU (assumes FP16 on vLLM baseline)
791
  tps_per_gpu = interpolate_throughput(gpu_family, model_size_bn, task, use_batched)
792
 
793
- # Apply quantization speedup multiplier
794
  # INT8/INT4 are significantly faster due to specialized Tensor Cores
795
- quant_speedup = QUANTIZATION_SPEEDUP.get(precision, 1.0)
796
- tps_per_gpu *= quant_speedup
 
 
 
 
 
 
 
 
797
 
798
  # Apply framework efficiency multiplier
799
  # TensorRT-LLM is more optimized than vLLM, HuggingFace is less optimized
 
8
  GPU configurations for Large Language Model (LLM) deployment and training.
9
 
10
  Author: Rudali Huidrom
11
+ Version: 4.0.0
12
  First Written On: 08 December 2025
13
 
14
  Overview
 
88
  # - Budget tier: Green gradient for cost-effective options
89
  # - Runner-up tier: Blue gradient for balanced options
90
  # - Performance tier: Purple gradient for maximum performance
91
+ # - Dark/Light mode support
92
+ # - Mobile/Tablet responsive
93
  CUSTOM_CSS = """
94
  <style>
95
+ /* ============================================
96
+ LIGHT MODE (Default)
97
+ ============================================ */
98
  .budget-box {
99
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%) !important;
100
  border: 2px solid #22c55e !important;
 
130
  padding: 12px !important;
131
  margin: 8px 0 !important;
132
  }
133
+
134
+ /* ============================================
135
+ DARK MODE
136
+ ============================================ */
137
+ @media (prefers-color-scheme: dark) {
138
+ .budget-box {
139
+ background: linear-gradient(135deg, #052e16 0%, #064e3b 100%) !important;
140
+ border: 2px solid #22c55e !important;
141
+ box-shadow: 0 2px 8px rgba(34, 197, 94, 0.25) !important;
142
+ }
143
+ .budget-box, .budget-box * {
144
+ color: #dcfce7 !important;
145
+ }
146
+
147
+ .runner-box {
148
+ background: linear-gradient(135deg, #172554 0%, #1e3a8a 100%) !important;
149
+ border: 2px solid #3b82f6 !important;
150
+ box-shadow: 0 2px 8px rgba(59, 130, 246, 0.25) !important;
151
+ }
152
+ .runner-box, .runner-box * {
153
+ color: #dbeafe !important;
154
+ }
155
+
156
+ .perf-box {
157
+ background: linear-gradient(135deg, #3b0764 0%, #4c1d95 100%) !important;
158
+ border: 2px solid #a855f7 !important;
159
+ box-shadow: 0 2px 8px rgba(168, 85, 247, 0.25) !important;
160
+ }
161
+ .perf-box, .perf-box * {
162
+ color: #f3e8ff !important;
163
+ }
164
+
165
+ .warning-box {
166
+ background-color: #451a03 !important;
167
+ border: 1px solid #f59e0b !important;
168
+ color: #fde68a !important;
169
+ }
170
+
171
+ .error-box {
172
+ background-color: #450a0a !important;
173
+ border: 1px solid #ef4444 !important;
174
+ color: #fecaca !important;
175
+ }
176
+ }
177
+
178
+ /* ============================================
179
+ TABLET (max-width: 1024px)
180
+ Stack main columns, keep boxes side by side
181
+ ============================================ */
182
+ @media screen and (max-width: 1024px) {
183
+ .gradio-container {
184
+ padding: 12px !important;
185
+ }
186
+ }
187
+
188
+ /* ============================================
189
+ MOBILE (max-width: 768px)
190
+ ============================================ */
191
+ @media screen and (max-width: 768px) {
192
+ .gradio-container {
193
+ padding: 8px !important;
194
+ }
195
+
196
+ /* Stack recommendation boxes vertically */
197
+ .budget-box, .runner-box, .perf-box {
198
+ margin-bottom: 12px !important;
199
+ }
200
+
201
+ /* Larger touch targets */
202
+ button, .gradio-button {
203
+ min-height: 44px !important;
204
+ font-size: 16px !important;
205
+ }
206
+
207
+ input, select, textarea {
208
+ min-height: 44px !important;
209
+ font-size: 16px !important; /* Prevents iOS zoom */
210
+ }
211
+ }
212
+
213
+ /* ============================================
214
+ SMALL MOBILE (max-width: 480px)
215
+ ============================================ */
216
+ @media screen and (max-width: 480px) {
217
+ .gradio-container {
218
+ padding: 4px !important;
219
+ }
220
+
221
+ .budget-box, .runner-box, .perf-box {
222
+ padding: 12px !important;
223
+ border-radius: 8px !important;
224
+ }
225
+
226
+ h1, .markdown h1 {
227
+ font-size: 1.4rem !important;
228
+ }
229
+
230
+ h3, .markdown h3 {
231
+ font-size: 1rem !important;
232
+ }
233
+ }
234
+
235
+ /* ============================================
236
+ TOUCH DEVICES
237
+ ============================================ */
238
+ @media (pointer: coarse) {
239
+ button, .gradio-button,
240
+ input, select, textarea {
241
+ min-height: 44px !important;
242
+ }
243
+
244
+ input[type="checkbox"], input[type="radio"] {
245
+ width: 20px !important;
246
+ height: 20px !important;
247
+ }
248
+ }
249
+
250
+ /* ============================================
251
+ ACCESSIBILITY
252
+ ============================================ */
253
+ @media (prefers-reduced-motion: reduce) {
254
+ * {
255
+ transition: none !important;
256
+ animation: none !important;
257
+ }
258
+ }
259
+
260
+ *:focus-visible {
261
+ outline: 2px solid #3b82f6 !important;
262
+ outline-offset: 2px !important;
263
+ }
264
  </style>
265
  """
266
 
 
612
  # Based on real-world benchmarks from MLPerf, vendor data, and community testing
613
  # Tokens per second per GPU for different model sizes
614
  #
615
+ # Last Updated: 16 December 2025
616
  # Sources:
617
  # - MLPerf Training v3.1 (November 2023)
618
  # - NVIDIA TensorRT-LLM benchmarks (Q4 2024)
 
926
  # Get base throughput per GPU (assumes FP16 on vLLM baseline)
927
  tps_per_gpu = interpolate_throughput(gpu_family, model_size_bn, task, use_batched)
928
 
929
+ # Apply quantization speedup multiplier (INFERENCE ONLY)
930
  # INT8/INT4 are significantly faster due to specialized Tensor Cores
931
+ # For training, quantization provides memory savings, not speed improvements
932
+ if task == "Inference":
933
+ quant_speedup = QUANTIZATION_SPEEDUP.get(precision, 1.0)
934
+ tps_per_gpu *= quant_speedup
935
+ else:
936
+ quant_speedup = 1.0 # No speedup for training
937
+ # For QLoRA, there's actually a slight slowdown due to
938
+ # quantization/dequantization overhead during forward pass
939
+ if precision in ['nf4', '4bit', 'int4', 'int8'] and ft_method == "QLoRA":
940
+ tps_per_gpu *= 0.85 # ~15% overhead for quantized training
941
 
942
  # Apply framework efficiency multiplier
943
  # TensorRT-LLM is more optimized than vLLM, HuggingFace is less optimized