Spaces:
Running
Running
File size: 1,116 Bytes
fa59dd6 | 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 | import { describe, expect, it } from 'vitest';
import { classifyResourceFailure } from './errors';
describe('resource failure classification', () => {
it('recognizes a full KV cache without treating it as device memory loss', () => {
expect(classifyResourceFailure(new Error('kv_cache_full'))).toBe('context-capacity');
expect(classifyResourceFailure(
new Error('native completion failed'),
['stopped due to running out of context capacity'],
)).toBe('context-capacity');
});
it('recognizes WebGPU and WASM allocation failures', () => {
expect(classifyResourceFailure(new Error('GPUOutOfMemoryError'))).toBe('memory-pressure');
expect(classifyResourceFailure(
new Error('Failed to load model'),
['ggml_webgpu: failed to allocate WebGPU KV buffer'],
)).toBe('memory-pressure');
expect(classifyResourceFailure(new Error('memory access out of bounds'))).toBe('memory-pressure');
});
it('does not relabel unrelated runtime failures as memory pressure', () => {
expect(classifyResourceFailure(new Error('Invalid chat template'))).toBeNull();
});
});
|