Skip to content

Commit 88ed930

Browse files
committed
Updating the diagram
1 parent 6ff5653 commit 88ed930

File tree

2 files changed

+58
-42
lines changed

2 files changed

+58
-42
lines changed

app/components/ScientificVisualization.tsx

Lines changed: 50 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const TOOLTIPS: Record<string, TooltipInfo> = {
2727
},
2828
enhanced_parser: {
2929
title: 'Enhanced Parser',
30-
description: 'Advanced parsing with intrinsics detection (~100 CUDA intrinsics), index pattern analysis, and warp operation detection.',
30+
description: 'Advanced parsing with 150+ CUDA intrinsics detection, index pattern analysis, warp operations, and tensor core intrinsics.',
3131
},
3232
semantic: {
3333
title: 'Semantic Analyzer',
@@ -39,7 +39,7 @@ const TOOLTIPS: Record<string, TooltipInfo> = {
3939
},
4040
pattern: {
4141
title: 'Pattern Detector',
42-
description: '7 pattern matchers: Elementwise, GEMM, Reduction, Scan, Stencil, Histogram, Sparse. Detects variants like warp_shuffle, multi_block, 2D/3D stencils.',
42+
description: '18 pattern matchers with 60+ variants. Core: Elementwise, GEMM, Reduction, Scan, Stencil. ML/DL: Convolution, Pooling, Normalization, Fused. LLM: Attention, RoPE, KV Cache, Embedding, Quantization. Specialized: Sparse, Histogram, Sorting, FFT.',
4343
},
4444
ir_builder: {
4545
title: 'IR Builder',
@@ -51,7 +51,7 @@ const TOOLTIPS: Record<string, TooltipInfo> = {
5151
},
5252
templates: {
5353
title: 'Template CodeGen',
54-
description: 'Variant-specific code templates: tree_reduction, warp_shuffle, stencil_2d_5pt, etc. Falls back to generic generator.',
54+
description: '14 template files with 60+ variant-specific generators. Supports Flash Attention, RoPE, KV Cache, Quantization, Convolution, Normalization, and more.',
5555
},
5656
diagnostics: {
5757
title: 'Diagnostics',
@@ -286,7 +286,7 @@ export default function ScientificVisualization({
286286
/>
287287
<text x="550" y="105" textAnchor="middle" fill={textColor} fontSize="8" fontFamily="monospace">Pattern</text>
288288
<text x="550" y="117" textAnchor="middle" fill={textColor} fontSize="8" fontFamily="monospace">Detector</text>
289-
<text x="550" y="129" textAnchor="middle" fill={mutedColor} fontSize="7" fontFamily="monospace">(7 types)</text>
289+
<text x="550" y="129" textAnchor="middle" fill={mutedColor} fontSize="7" fontFamily="monospace">(18 types)</text>
290290
{getNodeStatus(4) === 'completed' && <text x="595" y="85" fill={greenColor} fontSize="11"></text>}
291291
</g>
292292

@@ -406,27 +406,56 @@ export default function ScientificVisualization({
406406
</g>
407407

408408
{/* ===== PATTERN LABELS ===== */}
409-
<g transform="translate(480, 200)">
410-
<text x="70" y="0" textAnchor="middle" fill={mutedColor} fontSize="8" fontFamily="monospace">Patterns:</text>
411-
<rect x="0" y="8" width="50" height="16" fill="none" stroke={mutedColor} strokeWidth="0.5" rx="2" />
412-
<text x="25" y="20" textAnchor="middle" fill={textColor} fontSize="7" fontFamily="monospace">GEMM</text>
413-
<rect x="55" y="8" width="50" height="16" fill="none" stroke={mutedColor} strokeWidth="0.5" rx="2" />
414-
<text x="80" y="20" textAnchor="middle" fill={textColor} fontSize="7" fontFamily="monospace">Reduction</text>
415-
<rect x="110" y="8" width="40" height="16" fill="none" stroke={mutedColor} strokeWidth="0.5" rx="2" />
416-
<text x="130" y="20" textAnchor="middle" fill={textColor} fontSize="7" fontFamily="monospace">Scan</text>
417-
<rect x="0" y="28" width="45" height="16" fill="none" stroke={mutedColor} strokeWidth="0.5" rx="2" />
418-
<text x="22" y="40" textAnchor="middle" fill={textColor} fontSize="7" fontFamily="monospace">Stencil</text>
419-
<rect x="50" y="28" width="55" height="16" fill="none" stroke={mutedColor} strokeWidth="0.5" rx="2" />
420-
<text x="77" y="40" textAnchor="middle" fill={textColor} fontSize="7" fontFamily="monospace">Histogram</text>
421-
<rect x="110" y="28" width="45" height="16" fill="none" stroke={mutedColor} strokeWidth="0.5" rx="2" />
422-
<text x="132" y="40" textAnchor="middle" fill={textColor} fontSize="7" fontFamily="monospace">Sparse</text>
409+
<g transform="translate(210, 200)">
410+
{/* Core Patterns */}
411+
<text x="0" y="0" textAnchor="start" fill={mutedColor} fontSize="7" fontFamily="monospace" fontWeight="600">Core:</text>
412+
<rect x="30" y="-8" width="40" height="14" fill="none" stroke={mutedColor} strokeWidth="0.5" rx="2" />
413+
<text x="50" y="2" textAnchor="middle" fill={textColor} fontSize="6" fontFamily="monospace">GEMM</text>
414+
<rect x="75" y="-8" width="50" height="14" fill="none" stroke={mutedColor} strokeWidth="0.5" rx="2" />
415+
<text x="100" y="2" textAnchor="middle" fill={textColor} fontSize="6" fontFamily="monospace">Reduction</text>
416+
<rect x="130" y="-8" width="35" height="14" fill="none" stroke={mutedColor} strokeWidth="0.5" rx="2" />
417+
<text x="147" y="2" textAnchor="middle" fill={textColor} fontSize="6" fontFamily="monospace">Scan</text>
418+
<rect x="170" y="-8" width="40" height="14" fill="none" stroke={mutedColor} strokeWidth="0.5" rx="2" />
419+
<text x="190" y="2" textAnchor="middle" fill={textColor} fontSize="6" fontFamily="monospace">Stencil</text>
420+
421+
{/* ML/DL Patterns */}
422+
<text x="0" y="18" textAnchor="start" fill={mutedColor} fontSize="7" fontFamily="monospace" fontWeight="600">ML/DL:</text>
423+
<rect x="35" y="10" width="55" height="14" fill="none" stroke={mutedColor} strokeWidth="0.5" rx="2" />
424+
<text x="62" y="20" textAnchor="middle" fill={textColor} fontSize="6" fontFamily="monospace">Convolution</text>
425+
<rect x="95" y="10" width="40" height="14" fill="none" stroke={mutedColor} strokeWidth="0.5" rx="2" />
426+
<text x="115" y="20" textAnchor="middle" fill={textColor} fontSize="6" fontFamily="monospace">Pooling</text>
427+
<rect x="140" y="10" width="60" height="14" fill="none" stroke={mutedColor} strokeWidth="0.5" rx="2" />
428+
<text x="170" y="20" textAnchor="middle" fill={textColor} fontSize="6" fontFamily="monospace">Normalization</text>
429+
430+
{/* LLM Patterns */}
431+
<text x="0" y="36" textAnchor="start" fill={greenColor} fontSize="7" fontFamily="monospace" fontWeight="600">LLM:</text>
432+
<rect x="25" y="28" width="50" height="14" fill="none" stroke={greenColor} strokeWidth="0.5" rx="2" />
433+
<text x="50" y="38" textAnchor="middle" fill={textColor} fontSize="6" fontFamily="monospace">Attention</text>
434+
<rect x="80" y="28" width="35" height="14" fill="none" stroke={greenColor} strokeWidth="0.5" rx="2" />
435+
<text x="97" y="38" textAnchor="middle" fill={textColor} fontSize="6" fontFamily="monospace">RoPE</text>
436+
<rect x="120" y="28" width="48" height="14" fill="none" stroke={greenColor} strokeWidth="0.5" rx="2" />
437+
<text x="144" y="38" textAnchor="middle" fill={textColor} fontSize="6" fontFamily="monospace">KV Cache</text>
438+
<rect x="173" y="28" width="35" height="14" fill="none" stroke={greenColor} strokeWidth="0.5" rx="2" />
439+
<text x="190" y="38" textAnchor="middle" fill={textColor} fontSize="6" fontFamily="monospace">Quant</text>
440+
441+
{/* Specialized */}
442+
<text x="0" y="54" textAnchor="start" fill={mutedColor} fontSize="7" fontFamily="monospace" fontWeight="600">Other:</text>
443+
<rect x="30" y="46" width="40" height="14" fill="none" stroke={mutedColor} strokeWidth="0.5" rx="2" />
444+
<text x="50" y="56" textAnchor="middle" fill={textColor} fontSize="6" fontFamily="monospace">Sparse</text>
445+
<rect x="75" y="46" width="50" height="14" fill="none" stroke={mutedColor} strokeWidth="0.5" rx="2" />
446+
<text x="100" y="56" textAnchor="middle" fill={textColor} fontSize="6" fontFamily="monospace">Histogram</text>
447+
<rect x="130" y="46" width="40" height="14" fill="none" stroke={mutedColor} strokeWidth="0.5" rx="2" />
448+
<text x="150" y="56" textAnchor="middle" fill={textColor} fontSize="6" fontFamily="monospace">Sorting</text>
449+
<rect x="175" y="46" width="30" height="14" fill="none" stroke={mutedColor} strokeWidth="0.5" rx="2" />
450+
<text x="190" y="56" textAnchor="middle" fill={textColor} fontSize="6" fontFamily="monospace">FFT</text>
423451
</g>
424452

425453
{/* ===== VARIANT INFO ===== */}
426454
<g transform="translate(650, 200)">
427-
<text x="90" y="0" textAnchor="middle" fill={mutedColor} fontSize="8" fontFamily="monospace">Variants:</text>
428-
<text x="90" y="15" textAnchor="middle" fill={textColor} fontSize="7" fontFamily="monospace">tree_reduction | warp_shuffle | multi_block</text>
429-
<text x="90" y="28" textAnchor="middle" fill={textColor} fontSize="7" fontFamily="monospace">stencil_2d_5pt | stencil_3d | spmv_csr</text>
455+
<text x="90" y="0" textAnchor="middle" fill={mutedColor} fontSize="8" fontFamily="monospace">60+ Variants:</text>
456+
<text x="90" y="15" textAnchor="middle" fill={textColor} fontSize="6" fontFamily="monospace">flash_attention | flash_attention_v2 | multi_head_attention</text>
457+
<text x="90" y="28" textAnchor="middle" fill={textColor} fontSize="6" fontFamily="monospace">rope_standard | rope_neox | kvcache_paged | quant_int8</text>
458+
<text x="90" y="41" textAnchor="middle" fill={textColor} fontSize="6" fontFamily="monospace">layernorm | rmsnorm | conv_2d | conv_depthwise | bitonic_sort</text>
430459
</g>
431460

432461
{/* ===== ARROWS ===== */}

lib/transpiler.ts

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import { semanticAnalyzer, SemanticAnalysisResult } from './ast/semantic-analyze
77
import { memoryAnalyzer, MemoryAnalysisResult } from './ast/memory-analyzer';
88
import { cudaParser, EnhancedParseResult } from './parser';
99
import { patternMatcher, PatternAnalysis } from './patterns/matcher';
10-
import { histogramMatcher } from './patterns/matchers/histogram';
11-
import { sparseMatcher } from './patterns/matchers/sparse';
1210
import { irBuilder } from './ir/builder';
1311
import { irOptimizer, EnhancedKernelIR } from './ir';
1412
import { codeGenerator } from './codegen/generator';
@@ -116,27 +114,16 @@ export async function transpile(code: string): Promise<EnhancedTranspileResult>
116114
}
117115

118116
/**
119-
* Detect the best pattern including new histogram and sparse patterns
117+
* Detect the best pattern using the unified pattern matcher orchestrator
118+
* Supports all 18 archetypes with 60+ variants
120119
*/
121120
function detectBestPattern(kernel: any, enhanced: EnhancedParseResult): PatternMatch {
122-
// Get all pattern matches
123-
const allMatches = patternMatcher.matchAll(kernel);
124-
125-
// Also check new patterns
126-
const histogramMatch = histogramMatcher.match(kernel);
127-
const sparseMatch = sparseMatcher.match(kernel);
128-
129-
// Combine all matches
130-
const allPatterns = [
131-
...allMatches,
132-
histogramMatch,
133-
sparseMatch,
134-
];
135-
136-
// Sort by confidence and return best match
137-
allPatterns.sort((a, b) => b.confidence - a.confidence);
138-
139-
const best = allPatterns[0];
121+
// Use the pattern matcher orchestrator which includes all 18 pattern matchers:
122+
// - Core: elementwise, gemm, reduction, scan, stencil
123+
// - ML/DL: convolution, pooling, normalization, fused
124+
// - LLM: attention, rope, kvcache, embedding, quantization
125+
// - Specialized: sparse, histogram, sorting, fft
126+
const best = patternMatcher.match(kernel);
140127

141128
// Boost confidence based on enhanced analysis signals
142129
let boostedConfidence = best.confidence;

0 commit comments

Comments
 (0)