Skip to content

Commit bb33a5d

Browse files
committed
test: fix tests
1 parent 2527413 commit bb33a5d

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

src/evaluator/LlamaContext/types.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ export type SequenceEvaluateMetadataOptions = {
326326
* Same as `probabilities.get(token)` from the output.
327327
*
328328
* If you need only this value, you can skip getting the full probabilities list to improve performance.
329+
*
330+
* This value might be slightly different when evaluated on different GPUs and configurations.
329331
*/
330332
readonly confidence?: boolean,
331333

@@ -359,6 +361,8 @@ export type SequenceEvaluateOutput<
359361
* Same as `probabilities.get(token)`.
360362
*
361363
* If you need only this value, you can skip getting the full probabilities list to improve performance.
364+
*
365+
* This value might be slightly different when evaluated on different GPUs and configurations.
362366
*/
363367
confidence: number,
364368

@@ -367,6 +371,8 @@ export type SequenceEvaluateOutput<
367371
*
368372
* A probability is a number from `0` to `1`.
369373
*
374+
* The probabilities might be slightly different when evaluated on different GPUs and configurations.
375+
*
370376
* The map is sorted by the probability of the tokens from the highest to the lowest,
371377
* and is reflected in the order of the entries when iterating over the map.
372378
* Use `.entries().next().value` to get the top probability pair
@@ -392,6 +398,8 @@ export type ControlledEvaluateInputItem = Token | [token: Token, options: {
392398
* Same as `next.probabilities.get(next.token)` from the output.
393399
*
394400
* If you need only this value, you can skip getting the full probabilities list to improve performance.
401+
*
402+
* This value might be slightly different when evaluated on different GPUs and configurations.
395403
*/
396404
confidence?: boolean,
397405

@@ -437,6 +445,8 @@ export type ControlledEvaluateIndexOutput = {
437445
* Same as `next.probabilities.get(next.token)`.
438446
*
439447
* If you need only this value, you can skip getting the full probabilities list to improve performance.
448+
*
449+
* This value might be slightly different when evaluated on different GPUs and configurations.
440450
*/
441451
confidence?: number,
442452

@@ -445,6 +455,8 @@ export type ControlledEvaluateIndexOutput = {
445455
*
446456
* A probability is a number from `0` to `1`.
447457
*
458+
* The probabilities might be slightly different when evaluated on different GPUs and configurations.
459+
*
448460
* The map is sorted by the probability of the tokens from the highest to the lowest,
449461
* and is reflected in the order of the entries when iterating over the map.
450462
* Use `.entries().next().value` to get the top probability pair

test/modelDependent/llama3.1/controlledEvaluate.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@ import {getTestLlama} from "../../utils/getTestLlama.js";
55

66
describe("llama 3.1", () => {
77
describe("controlled evaluate", () => {
8-
test("get probabilities for 3 tokens", {timeout: 1000 * 60 * 60 * 2}, async () => {
8+
test("get probabilities for 3 tokens", {timeout: 1000 * 60 * 60 * 2}, async (testContext) => {
99
const modelPath = await getModelFile("Meta-Llama-3.1-8B-Instruct.Q4_K_M.gguf");
1010
const llama = await getTestLlama();
1111

12+
// the precise values are different for each GPU type, so we skip the test for GPUs other than metal
13+
if (llama.gpu !== "metal")
14+
testContext.skip();
15+
1216
const model = await llama.loadModel({
1317
modelPath
1418
});

test/modelDependent/llama3.1/evaluateWithMetadata.test.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,14 @@ describe("llama 3.1", () => {
6767
`);
6868
});
6969

70-
test("with probabilities", {timeout: 1000 * 60 * 60 * 2}, async () => {
70+
test("with probabilities", {timeout: 1000 * 60 * 60 * 2}, async (testContext) => {
7171
const modelPath = await getModelFile("Meta-Llama-3.1-8B-Instruct.Q4_K_M.gguf");
7272
const llama = await getTestLlama();
7373

74+
// the precise values are different for each GPU type, so we skip the test for GPUs other than metal
75+
if (llama.gpu !== "metal")
76+
testContext.skip();
77+
7478
const model = await llama.loadModel({
7579
modelPath
7680
});
@@ -246,10 +250,14 @@ describe("llama 3.1", () => {
246250
`);
247251
});
248252

249-
test("with confidence", {timeout: 1000 * 60 * 60 * 2}, async () => {
253+
test("with confidence", {timeout: 1000 * 60 * 60 * 2}, async (testContext) => {
250254
const modelPath = await getModelFile("Meta-Llama-3.1-8B-Instruct.Q4_K_M.gguf");
251255
const llama = await getTestLlama();
252256

257+
// the precise values are different for each GPU type, so we skip the test for GPUs other than metal
258+
if (llama.gpu !== "metal")
259+
testContext.skip();
260+
253261
const model = await llama.loadModel({
254262
modelPath
255263
});
@@ -315,10 +323,14 @@ describe("llama 3.1", () => {
315323
`);
316324
});
317325

318-
test("with probabilities and confidence", {timeout: 1000 * 60 * 60 * 2}, async () => {
326+
test("with probabilities and confidence", {timeout: 1000 * 60 * 60 * 2}, async (testContext) => {
319327
const modelPath = await getModelFile("Meta-Llama-3.1-8B-Instruct.Q4_K_M.gguf");
320328
const llama = await getTestLlama();
321329

330+
// the precise values are different for each GPU type, so we skip the test for GPUs other than metal
331+
if (llama.gpu !== "metal")
332+
testContext.skip();
333+
322334
const model = await llama.loadModel({
323335
modelPath
324336
});
@@ -504,10 +516,14 @@ describe("llama 3.1", () => {
504516
`);
505517
});
506518

507-
test("confidence alone matches probability alone", {timeout: 1000 * 60 * 60 * 2}, async () => {
519+
test("confidence alone matches probability alone", {timeout: 1000 * 60 * 60 * 2}, async (testContext) => {
508520
const modelPath = await getModelFile("Meta-Llama-3.1-8B-Instruct.Q4_K_M.gguf");
509521
const llama = await getTestLlama();
510522

523+
// the precise values are different for each GPU type, so we skip the test for GPUs other than metal
524+
if (llama.gpu !== "metal")
525+
testContext.skip();
526+
511527
const model = await llama.loadModel({
512528
modelPath
513529
});

0 commit comments

Comments
 (0)