Skip to content

Commit 4221d28

Browse files
committed
debug: add prefill profiling after GPU init for per-layer timing
1 parent bb3672c commit 4221d28

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

examples/benchmark/index.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,12 @@ <h2>Comparison Charts</h2>
661661
const info = JSON.parse(flareEngine.backend_info());
662662
console.log('[Flare] backend_info:', info);
663663
log(`Flare backend: ${JSON.stringify(info)}`, gpuOk ? 'success' : 'info');
664+
// Prefill profiling — captures per-layer timing
665+
flareEngine.enable_prefill_profiling();
666+
const profile = JSON.parse(flareEngine.prefill_profile_json());
667+
console.log('[Flare] prefill profile:', profile);
668+
log(`Flare prefill profile: ${JSON.stringify(profile)}`, 'info');
669+
flareEngine.disable_prefill_profiling();
664670
} catch (e) {
665671
console.warn('[Flare] GPU init failed:', e);
666672
log('Flare GPU init failed — using CPU SIMD', 'info');

src/engines/flare-engine-wrapper.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ interface FlareEngineInstance {
6060
add_stop_sequence(seq: string): void;
6161
clear_stop_sequences(): void;
6262
backend_info(): string;
63+
enable_prefill_profiling(): void;
64+
disable_prefill_profiling(): void;
65+
prefill_profile_json(): string;
6366
}
6467

6568
interface FlareModule {
@@ -311,7 +314,11 @@ export class FlareEngineWrapper {
311314
if (useGpu) {
312315
try {
313316
this.gpuEnabled = await this.engine.init_gpu();
314-
console.log('[Flare]', JSON.parse(this.engine.backend_info()));
317+
console.log('[Flare] backend_info:', JSON.parse(this.engine.backend_info()));
318+
// Prefill profiling — captures per-layer timing for the first run
319+
this.engine.enable_prefill_profiling();
320+
console.log('[Flare] prefill profile:', JSON.parse(this.engine.prefill_profile_json()));
321+
this.engine.disable_prefill_profiling();
315322
if (!this.gpuEnabled) {
316323
console.info('[Flare] WebGPU unavailable — using CPU SIMD path');
317324
}

0 commit comments

Comments
 (0)