File size: 19,748 Bytes
b9259a1 | 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 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | import os
import json
from pptx import Presentation
from pptx.util import Inches, Pt
from pptx.enum.text import PP_ALIGN
from pptx.dml.color import RGBColor
from pptx.enum.shapes import MSO_SHAPE
def create_presentation():
pptx_path = "/home/adminuser/aiops_pocs/MAMBA_7B/CODESTRAL_MAMBA_7B_VS_QWEN_7B_COMPARISON.pptx"
json_path = "/home/adminuser/aiops_pocs/MAMBA_7B/mamba_vs_qwen_results.json"
with open(json_path, "r", encoding="utf-8") as f:
benchmarks = json.load(f)
prs = Presentation()
prs.slide_width = Inches(13.333)
prs.slide_height = Inches(7.5)
# Color Palette
COLOR_BG = RGBColor(15, 23, 42) # Slate 900
COLOR_CARD = RGBColor(30, 41, 59) # Slate 800
COLOR_ACCENT = RGBColor(6, 182, 212) # Cyan 500
COLOR_MAMBA = RGBColor(16, 185, 129) # Emerald 500
COLOR_QWEN = RGBColor(59, 130, 246) # Blue 500
COLOR_TEXT = RGBColor(248, 250, 252) # Slate 50
COLOR_MUTED = RGBColor(148, 163, 184) # Slate 400
def apply_bg(slide):
bg = slide.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, 0, Inches(13.333), Inches(7.5))
bg.fill.solid()
bg.fill.fore_color.rgb = COLOR_BG
bg.line.fill.background()
def add_header(slide, title_text, category_text="BENCHMARK ANALYSIS"):
tb = slide.shapes.add_textbox(Inches(0.8), Inches(0.4), Inches(11.7), Inches(0.9))
tf = tb.text_frame
tf.word_wrap = True
p_cat = tf.paragraphs[0]
p_cat.text = category_text.upper()
p_cat.font.size = Pt(11)
p_cat.font.bold = True
p_cat.font.color.rgb = COLOR_ACCENT
p_title = tf.add_paragraph()
p_title.text = title_text
p_title.font.size = Pt(24)
p_title.font.bold = True
p_title.font.color.rgb = COLOR_TEXT
# -------------------------------------------------------------
# SLIDE 1: Title Slide
# -------------------------------------------------------------
slide1 = prs.slides.add_slide(prs.slide_layouts[6])
apply_bg(slide1)
tb = slide1.shapes.add_textbox(Inches(1.0), Inches(2.2), Inches(11.3), Inches(3.2))
tf = tb.text_frame
tf.word_wrap = True
p1 = tf.paragraphs[0]
p1.text = "TECHNICAL BENCHMARK & ARCHITECTURAL EVALUATION"
p1.font.size = Pt(14)
p1.font.bold = True
p1.font.color.rgb = COLOR_ACCENT
p2 = tf.add_paragraph()
p2.text = "Codestral Mamba 7B vs. Qwen 2.5 7B"
p2.font.size = Pt(38)
p2.font.bold = True
p2.font.color.rgb = COLOR_TEXT
p3 = tf.add_paragraph()
p3.text = "Empirical comparison of Selective State Space Models (SSM) vs Multi-Head Self-Attention Transformers across 10 Technical Benchmarks on NVIDIA H200 GPUs"
p3.font.size = Pt(16)
p3.font.color.rgb = COLOR_MUTED
# -------------------------------------------------------------
# SLIDE 2: Executive Summary
# -------------------------------------------------------------
slide2 = prs.slides.add_slide(prs.slide_layouts[6])
apply_bg(slide2)
add_header(slide2, "Executive Summary & Core Findings", "Overview")
cards = [
("42.2% Faster Completion", "Codestral Mamba 7B achieved an average query latency of 4.28s vs Qwen 2.5's 7.40s, delivering ultra-fast time-to-first-token.", COLOR_MAMBA),
("~195 Tokens / Sec Speed", "Both models saturated hardware limits at ~194.8 t/s (Mamba) vs ~193.3 t/s (Qwen) on NVIDIA H200 NVL GPUs.", COLOR_ACCENT),
("2.25x Explanation Density", "Qwen 2.5 7B generated 4,347 chars/response vs Mamba's 1,930 chars, providing rich docstrings & edge cases.", COLOR_QWEN),
("Constant O(1) Memory State", "Mamba maintains a fixed recurrent state buffer, eliminating KV-cache VRAM expansion at long context (up to 256k).", COLOR_MAMBA)
]
for idx, (title, desc, color) in enumerate(cards):
row = idx // 2
col = idx % 2
x = Inches(0.8 + col * 5.9)
y = Inches(1.6 + row * 2.6)
card = slide2.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, x, y, Inches(5.6), Inches(2.3))
card.fill.solid()
card.fill.fore_color.rgb = COLOR_CARD
card.line.color.rgb = color
card.line.width = Pt(1.5)
tf = card.text_frame
tf.word_wrap = True
p_t = tf.paragraphs[0]
p_t.text = title
p_t.font.size = Pt(18)
p_t.font.bold = True
p_t.font.color.rgb = color
p_d = tf.add_paragraph()
p_d.text = desc
p_d.font.size = Pt(13)
p_d.font.color.rgb = COLOR_TEXT
# -------------------------------------------------------------
# SLIDE 3: Architectural Mechanics (SSM vs Transformer)
# -------------------------------------------------------------
slide3 = prs.slides.add_slide(prs.slide_layouts[6])
apply_bg(slide3)
add_header(slide3, "Architectural Mechanics: Selective SSM vs. Self-Attention", "Deep Dive")
# Left Card: Mamba
c1 = slide3.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(0.8), Inches(1.6), Inches(5.6), Inches(5.2))
c1.fill.solid()
c1.fill.fore_color.rgb = COLOR_CARD
c1.line.color.rgb = COLOR_MAMBA
c1.line.width = Pt(2)
tf1 = c1.text_frame
tf1.word_wrap = True
p = tf1.paragraphs[0]
p.text = "🟢 Codestral Mamba 7B (Selective SSM S6)"
p.font.size = Pt(18)
p.font.bold = True
p.font.color.rgb = COLOR_MAMBA
bullets1 = [
"• Core Mechanism: Input-dependent Selective State Space Model (S6).",
"• Time Complexity: O(N) Linear scaling with sequence length.",
"• Hardware Scanning: Parallel associative scan algorithm utilizing SRAM.",
"• Memory Footprint: Recurrent O(1) constant-size hidden state buffer.",
"• Key Advantage: Zero KV-cache VRAM inflation during 256k long-context inference."
]
for b in bullets1:
p = tf1.add_paragraph()
p.text = b
p.font.size = Pt(13)
p.font.color.rgb = COLOR_TEXT
# Right Card: Qwen Transformer
c2 = slide3.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(6.8), Inches(1.6), Inches(5.6), Inches(5.2))
c2.fill.solid()
c2.fill.fore_color.rgb = COLOR_CARD
c2.line.color.rgb = COLOR_QWEN
c2.line.width = Pt(2)
tf2 = c2.text_frame
tf2.word_wrap = True
p = tf2.paragraphs[0]
p.text = "🔵 Qwen 2.5 7B (Multi-Head Self-Attention)"
p.font.size = Pt(18)
p.font.bold = True
p.font.color.rgb = COLOR_QWEN
bullets2 = [
"• Core Mechanism: Multi-Head Self-Attention with Rotary Position Embeddings (RoPE).",
"• Time Complexity: O(N²) Quadratic attention scaling.",
"• Hardware Optimization: FlashAttention-2 & deep Tensor Core integration.",
"• Memory Footprint: Grows linearly per token (KV Cache memory inflation).",
"• Key Advantage: Deep global contextual reasoning, extensive docstring synthesis."
]
for b in bullets2:
p = tf2.add_paragraph()
p.text = b
p.font.size = Pt(13)
p.font.color.rgb = COLOR_TEXT
# -------------------------------------------------------------
# SLIDE 4: Quantitative Performance Table
# -------------------------------------------------------------
slide4 = prs.slides.add_slide(prs.slide_layouts[6])
apply_bg(slide4)
add_header(slide4, "Quantitative Benchmark Performance Summary", "Metrics")
rows = len(benchmarks) + 1
cols = 7
table_shape = slide4.shapes.add_table(rows, cols, Inches(0.8), Inches(1.5), Inches(11.7), Inches(5.3))
table = table_shape.table
headers = ["ID", "Technical Task Title", "Mamba Time", "Qwen Time", "Mamba Speed", "Qwen Speed", "Output Delta"]
widths = [Inches(0.6), Inches(4.5), Inches(1.3), Inches(1.3), Inches(1.3), Inches(1.3), Inches(1.4)]
for idx, w in enumerate(widths):
table.columns[idx].width = w
for c_idx, h in enumerate(headers):
cell = table.cell(0, c_idx)
cell.fill.solid()
cell.fill.fore_color.rgb = COLOR_CARD
p = cell.text_frame.paragraphs[0]
p.text = h
p.font.size = Pt(11)
p.font.bold = True
p.font.color.rgb = COLOR_ACCENT
for r_idx, b in enumerate(benchmarks, start=1):
m = b["mamba"]
q = b["qwen"]
delta = f"+{(q['char_len'] - m['char_len'])/m['char_len']*100:.0f}% Qwen"
vals = [
f"{b['id']:02d}",
b["title"],
f"{m['time_sec']:.2f}s",
f"{q['time_sec']:.2f}s",
f"{m['tps']} t/s",
f"{q['tps']} t/s",
delta
]
for c_idx, val in enumerate(vals):
cell = table.cell(r_idx, c_idx)
cell.fill.solid()
cell.fill.fore_color.rgb = RGBColor(20, 30, 48) if r_idx % 2 == 0 else COLOR_BG
p = cell.text_frame.paragraphs[0]
p.text = val
p.font.size = Pt(10)
p.font.color.rgb = COLOR_TEXT
# -------------------------------------------------------------
# SLIDE 5: Benchmark Category 1 - Algorithms & Data Structures
# -------------------------------------------------------------
slide5 = prs.slides.add_slide(prs.slide_layouts[6])
apply_bg(slide5)
add_header(slide5, "Benchmark Spotlight: Algorithms & Data Structures", "Test 01 & 02")
# Test 1 Card
c1 = slide5.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(0.8), Inches(1.6), Inches(5.6), Inches(5.2))
c1.fill.solid()
c1.fill.fore_color.rgb = COLOR_CARD
tf1 = c1.text_frame
tf1.word_wrap = True
p = tf1.paragraphs[0]
p.text = "Test 01: Lock-Free LRU Cache in Python"
p.font.size = Pt(16)
p.font.bold = True
p.font.color.rgb = COLOR_ACCENT
p = tf1.add_paragraph()
p.text = "• Mamba (7.16s | 1,504 chars):\nLeveraged collections.OrderedDict for a minimal, working 15-line implementation. Extremely fast & compact.\n\n• Qwen 2.5 (24.97s | 4,970 chars):\nBuilt full double-linked node class, explicit generic typing, thread safety locks, comprehensive docstrings & edge cases."
p.font.size = Pt(12)
p.font.color.rgb = COLOR_TEXT
# Test 2 Card
c2 = slide5.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(6.8), Inches(1.6), Inches(5.6), Inches(5.2))
c2.fill.solid()
c2.fill.fore_color.rgb = COLOR_CARD
tf2 = c2.text_frame
tf2.word_wrap = True
p = tf2.paragraphs[0]
p.text = "Test 02: Red-Black Tree Balancing in C++"
p.font.size = Pt(16)
p.font.bold = True
p.font.color.rgb = COLOR_ACCENT
p = tf2.add_paragraph()
p.text = "• Mamba (6.56s | 4,200 chars):\nProduced clean C++ rotation logic (left/right rotate) and color fixup helper methods directly without boilerplate.\n\n• Qwen 2.5 (8.19s | 5,793 chars):\nGenerated full C++ template struct, explicit enum Color { RED, BLACK }, driver main() function, and memory destruction logic."
p.font.size = Pt(12)
p.font.color.rgb = COLOR_TEXT
# -------------------------------------------------------------
# SLIDE 6: Benchmark Category 2 - System Engineering & eBPF
# -------------------------------------------------------------
slide6 = prs.slides.add_slide(prs.slide_layouts[6])
apply_bg(slide6)
add_header(slide6, "Benchmark Spotlight: Systems Engineering & eBPF", "Test 03 & 04")
# Test 3 Card
c1 = slide6.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(0.8), Inches(1.6), Inches(5.6), Inches(5.2))
c1.fill.solid()
c1.fill.fore_color.rgb = COLOR_CARD
tf1 = c1.text_frame
tf1.word_wrap = True
p = tf1.paragraphs[0]
p.text = "Test 03: Asyncio WebSockets Gateway"
p.font.size = Pt(16)
p.font.bold = True
p.font.color.rgb = COLOR_ACCENT
p = tf1.add_paragraph()
p.text = "• Mamba (6.13s | 3,398 chars):\nConcise Python asyncio server with heartbeat ping/pong & token check middleware.\n\n• Qwen 2.5 (5.46s | 4,874 chars):\nFull async server architecture with sliding-window rate limiting, signal handlers for graceful shutdown, and client connection registry."
p.font.size = Pt(12)
p.font.color.rgb = COLOR_TEXT
# Test 4 Card
c2 = slide6.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(6.8), Inches(1.6), Inches(5.6), Inches(5.2))
c2.fill.solid()
c2.fill.fore_color.rgb = COLOR_CARD
tf2 = c2.text_frame
tf2.word_wrap = True
p = tf2.paragraphs[0]
p.text = "Test 04: Linux eBPF Packet Tracing (C/BCC)"
p.font.size = Pt(16)
p.font.bold = True
p.font.color.rgb = COLOR_ACCENT
p = tf2.add_paragraph()
p.text = "• Mamba (3.32s | 1,147 chars):\nShort eBPF C snippet hooking kprobe/sys_enter_connect with basic BCC python print loop.\n\n• Qwen 2.5 (4.56s | 2,947 chars):\nDetailed C eBPF kernel program using BPF_HASH maps, IP byte-order conversions, error checking, and formatted BCC CLI table output."
p.font.size = Pt(12)
p.font.color.rgb = COLOR_TEXT
# -------------------------------------------------------------
# SLIDE 7: Strategic Comparison - Codestral Mamba 7B
# -------------------------------------------------------------
slide7 = prs.slides.add_slide(prs.slide_layouts[6])
apply_bg(slide7)
add_header(slide7, "Model Profile: Codestral Mamba 7B", "Mistral AI")
c1 = slide7.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(0.8), Inches(1.6), Inches(5.6), Inches(5.2))
c1.fill.solid()
c1.fill.fore_color.rgb = COLOR_CARD
c1.line.color.rgb = COLOR_MAMBA
tf1 = c1.text_frame
tf1.word_wrap = True
p = tf1.paragraphs[0]
p.text = "🌟 Core Strengths & Advantages"
p.font.size = Pt(18)
p.font.bold = True
p.font.color.rgb = COLOR_MAMBA
b1 = [
"1. Ultra-Low Latency: 42.2% faster average response completion.",
"2. Constant O(1) Memory State: Eliminates KV-cache VRAM expansion at long context (up to 256k tokens).",
"3. High Code Autocomplete Efficiency: Delivers direct, fluff-free code snippets instantly.",
"4. High Throughput: ~194.8 t/s generation speed on H200 GPUs."
]
for b in b1:
p = tf1.add_paragraph()
p.text = b
p.font.size = Pt(13)
p.font.color.rgb = COLOR_TEXT
c2 = slide7.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(6.8), Inches(1.6), Inches(5.6), Inches(5.2))
c2.fill.solid()
c2.fill.fore_color.rgb = COLOR_CARD
c2.line.color.rgb = RGBColor(239, 68, 68)
tf2 = c2.text_frame
tf2.word_wrap = True
p = tf2.paragraphs[0]
p.text = "⚠️ Known Bottlenecks & Trade-offs"
p.font.size = Pt(18)
p.font.bold = True
p.font.color.rgb = RGBColor(239, 68, 68)
b2 = [
"1. Minimal Inline Documentation: Frequently omits docstrings, type hints, and code comments.",
"2. Concise Edge-Case Handling: May require follow-up prompts to handle complex exception paths.",
"3. Higher Recurrent State Complexity: Requires custom SSM CUDA kernels for peak training."
]
for b in b2:
p = tf2.add_paragraph()
p.text = b
p.font.size = Pt(13)
p.font.color.rgb = COLOR_TEXT
# -------------------------------------------------------------
# SLIDE 8: Strategic Comparison - Qwen 2.5 7B Instruct
# -------------------------------------------------------------
slide8 = prs.slides.add_slide(prs.slide_layouts[6])
apply_bg(slide8)
add_header(slide8, "Model Profile: Qwen 2.5 7B Instruct", "Alibaba Cloud")
c1 = slide8.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(0.8), Inches(1.6), Inches(5.6), Inches(5.2))
c1.fill.solid()
c1.fill.fore_color.rgb = COLOR_CARD
c1.line.color.rgb = COLOR_QWEN
tf1 = c1.text_frame
tf1.word_wrap = True
p = tf1.paragraphs[0]
p.text = "🌟 Core Strengths & Advantages"
p.font.size = Pt(18)
p.font.bold = True
p.font.color.rgb = COLOR_QWEN
b1 = [
"1. Exhaustive Code Density: 2.25x higher output character count (4,347 chars avg).",
"2. Complete Edge-Case Coverage: Includes explicit error checking, logging, and type hints.",
"3. Superior Explanatory Power: Accompanies code with thorough architectural breakdowns.",
"4. Versatile Multi-Domain Logic: Excellent performance across math proofs, code & general QA."
]
for b in b1:
p = tf1.add_paragraph()
p.text = b
p.font.size = Pt(13)
p.font.color.rgb = COLOR_TEXT
c2 = slide8.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(6.8), Inches(1.6), Inches(5.6), Inches(5.2))
c2.fill.solid()
c2.fill.fore_color.rgb = COLOR_CARD
c2.line.color.rgb = RGBColor(239, 68, 68)
tf2 = c2.text_frame
tf2.word_wrap = True
p = tf2.paragraphs[0]
p.text = "⚠️ Known Bottlenecks & Trade-offs"
p.font.size = Pt(18)
p.font.bold = True
p.font.color.rgb = RGBColor(239, 68, 68)
b2 = [
"1. Higher Total Response Time: Takes 7.40s avg due to generating comprehensive explanations.",
"2. Transformer Memory Expansion: O(N) KV-cache growth at extreme long contexts (32k+ tokens)."
]
for b in b2:
p = tf2.add_paragraph()
p.text = b
p.font.size = Pt(13)
p.font.color.rgb = COLOR_TEXT
# -------------------------------------------------------------
# SLIDE 9: Production Deployment Roadmap
# -------------------------------------------------------------
slide9 = prs.slides.add_slide(prs.slide_layouts[6])
apply_bg(slide9)
add_header(slide9, "Strategic Production Deployment Roadmap", "Recommendations")
c1 = slide9.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(0.8), Inches(1.6), Inches(5.6), Inches(5.2))
c1.fill.solid()
c1.fill.fore_color.rgb = COLOR_CARD
c1.line.color.rgb = COLOR_MAMBA
tf1 = c1.text_frame
tf1.word_wrap = True
p = tf1.paragraphs[0]
p.text = "🚀 Deploy Codestral Mamba 7B For:"
p.font.size = Pt(18)
p.font.bold = True
p.font.color.rgb = COLOR_MAMBA
recs1 = [
"1. Real-Time IDE Inline Autocomplete:\nInstant sub-second code completions where speed is critical.",
"2. Massive Repository Context Processing:\nProcessing 100k+ token codebases without VRAM KV-cache exhaustion.",
"3. High-Throughput Streaming API Microservices:\nLow-cost, low-latency microservice integrations."
]
for r in recs1:
p = tf1.add_paragraph()
p.text = r
p.font.size = Pt(13)
p.font.color.rgb = COLOR_TEXT
c2 = slide9.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(6.8), Inches(1.6), Inches(5.6), Inches(5.2))
c2.fill.solid()
c2.fill.fore_color.rgb = COLOR_CARD
c2.line.color.rgb = COLOR_QWEN
tf2 = c2.text_frame
tf2.word_wrap = True
p = tf2.paragraphs[0]
p.text = "🚀 Deploy Qwen 2.5 7B Instruct For:"
p.font.size = Pt(18)
p.font.bold = True
p.font.color.rgb = COLOR_QWEN
recs2 = [
"1. Full-Stack System Architecture Design:\nGenerating complete production microservices with docstrings.",
"2. Automated Refactoring & Unit Test Suites:\nCreating high-coverage pytest/unittest suites with mocks.",
"3. Complex Debugging & Security Auditing:\nComprehensive race condition and memory leak repair."
]
for r in recs2:
p = tf2.add_paragraph()
p.text = r
p.font.size = Pt(13)
p.font.color.rgb = COLOR_TEXT
prs.save(pptx_path)
print("Successfully generated PowerPoint presentation:", pptx_path)
if __name__ == "__main__":
create_presentation()
|