Skip to content

Commit 2d3a655

Browse files
authored
💥 Switch gguf & tasks interdependency (#1004)
cc @ngxson too (you can add yourself to CODEOWNERS for gguf maybe :) ) Move the functions needed by `@huggingface/tasks` directly into `@huggingface/tasks`. Now `@hugginface/gguf` depends on `@huggingface/tasks` and not the other way around. The move is minimal, more could be moved. (Or a fancy solution with shared folders, but fancy solutions can become complicated esp with publishing source code along with dist. Or we could just duplicate the code, and maybe add CI check to ensure consistency)
1 parent 56f465e commit 2d3a655

File tree

12 files changed

+60
-56
lines changed

12 files changed

+60
-56
lines changed

‎.github/workflows/gguf-publish.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ jobs:
4949
node -e "const fs = require('fs'); const package = JSON.parse(fs.readFileSync('./package.json')); package.version = '$BUMPED_VERSION'; fs.writeFileSync('./package.json', JSON.stringify(package, null, '\t') + '\n');"
5050
git commit . -m "🔖 @huggingface/gguf $BUMPED_VERSION"
5151
git tag "gguf-v$BUMPED_VERSION"
52+
53+
- name: "Check Deps are published before publishing this package"
54+
run: pnpm -w check-deps tasks
55+
5256
- run: pnpm publish --no-git-checks .
5357
env:
5458
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

‎.github/workflows/tasks-publish.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,6 @@ jobs:
5050
git commit . -m "🔖 @huggingface/tasks $BUMPED_VERSION"
5151
git tag "tasks-v$BUMPED_VERSION"
5252
53-
- name: "Check Deps are published before publishing this package"
54-
run: pnpm -w check-deps gguf
55-
5653
- run: pnpm publish --no-git-checks .
5754
env:
5855
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

‎.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
run: |
106106
sleep 3
107107
pnpm i --filter root --filter inference... --filter hub... --frozen-lockfile
108-
pnpm --filter inference --filter hub --filter tasks --filter gguf publish --force --no-git-checks --registry http://localhost:4874/
108+
pnpm --filter inference --filter hub --filter tasks publish --force --no-git-checks --registry http://localhost:4874/
109109
110110
- name: E2E test - test yarn install
111111
working-directory: e2e/ts

‎packages/gguf/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
},
2828
"source": "index.ts",
2929
"scripts": {
30-
"prepare": "pnpm run build",
3130
"lint": "eslint --quiet --fix --ext .cjs,.ts .",
3231
"lint:check": "eslint --ext .cjs,.ts .",
3332
"format": "prettier --write .",
@@ -50,6 +49,9 @@
5049
],
5150
"author": "Hugging Face",
5251
"license": "MIT",
52+
"dependencies": {
53+
"@huggingface/tasks": "workspace:^"
54+
},
5355
"devDependencies": {
5456
"@types/node": "^20.12.8"
5557
}

‎packages/gguf/pnpm-lock.yaml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/gguf/src/gguf.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import type { MetadataValue, Version, GGUFMetadata, GGUFTensorInfo, GGUFParseOutput } from "./types";
2-
import { GGMLQuantizationType, GGUFValueType } from "./types";
2+
import { GGUFValueType } from "./types";
33
import { isBackend } from "./utils/isBackend";
44
import { promisesQueue } from "./utils/promisesQueue";
55

66
export type { MetadataBaseValue, MetadataValue, Version, GGUFMetadata, GGUFTensorInfo, GGUFParseOutput } from "./types";
77
export { GGUFValueType, GGMLFileQuantizationType, GGMLQuantizationType, Architecture } from "./types";
88
export { GGUF_QUANT_DESCRIPTIONS } from "./quant-descriptions";
9+
export { parseGGUFQuantLabel, GGUF_QUANT_RE, GGUF_QUANT_RE_GLOBAL } from "@huggingface/tasks";
910

1011
export const RE_GGUF_FILE = /\.gguf$/;
1112
export const RE_GGUF_SHARD_FILE = /^(?<prefix>.*?)-(?<shard>\d{5})-of-(?<total>\d{5})\.gguf$/;
@@ -29,15 +30,6 @@ export function parseGgufShardFilename(filename: string): GgufShardFileInfo | nu
2930
return null;
3031
}
3132

32-
const ggufQuants = Object.values(GGMLQuantizationType).filter((v): v is string => typeof v === "string");
33-
export const GGUF_QUANT_RE = new RegExp(`(?<quant>${ggufQuants.join("|")})` + "(_(?<sizeVariation>[A-Z]+))?");
34-
export const GGUF_QUANT_RE_GLOBAL = new RegExp(GGUF_QUANT_RE, "g");
35-
36-
export function parseGGUFQuantLabel(fname: string): string | undefined {
37-
const quantLabel = fname.toUpperCase().match(GGUF_QUANT_RE_GLOBAL)?.at(-1); // if there is multiple quant substrings in a name, we prefer the last one
38-
return quantLabel;
39-
}
40-
4133
const isVersion = (version: number): version is Version => version === 1 || version === 2 || version === 3;
4234

4335
/**

‎packages/gguf/src/types.ts

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type { TransformerLLM } from "./transformer-llm";
22
import { LLM_ARCHITECTURES } from "./transformer-llm";
3+
import type { GGMLQuantizationType } from "@huggingface/tasks";
4+
export { GGMLQuantizationType } from "@huggingface/tasks";
35

46
export type MetadataBaseValue = string | number | bigint | boolean;
57
export type MetadataValue = MetadataBaseValue | MetadataBaseValue[] | MetadataValue[]; /// recursive as arrays can be nested.
@@ -45,38 +47,6 @@ export enum GGMLFileQuantizationType {
4547
MOSTLY_Q4_0_8_8 = 35,
4648
}
4749

48-
export enum GGMLQuantizationType {
49-
F32 = 0,
50-
F16 = 1,
51-
Q4_0 = 2,
52-
Q4_1 = 3,
53-
Q5_0 = 6,
54-
Q5_1 = 7,
55-
Q8_0 = 8,
56-
Q8_1 = 9,
57-
Q2_K = 10,
58-
Q3_K = 11,
59-
Q4_K = 12,
60-
Q5_K = 13,
61-
Q6_K = 14,
62-
Q8_K = 15,
63-
IQ2_XXS = 16,
64-
IQ2_XS = 17,
65-
IQ3_XXS = 18,
66-
IQ1_S = 19,
67-
IQ4_NL = 20,
68-
IQ3_S = 21,
69-
IQ2_S = 22,
70-
IQ4_XS = 23,
71-
I8 = 24,
72-
I16 = 25,
73-
I32 = 26,
74-
I64 = 27,
75-
F64 = 28,
76-
IQ1_M = 29,
77-
BF16 = 30,
78-
}
79-
8050
export enum GGUFValueType {
8151
UINT8 = 0,
8252
INT8 = 1,

‎packages/tasks/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,5 @@
5151
"@types/node": "^20.11.5",
5252
"quicktype-core": "https://github.com/huggingface/quicktype/raw/pack-18.0.17/packages/quicktype-core/quicktype-core-18.0.17.tgz",
5353
"type-fest": "^3.13.1"
54-
},
55-
"dependencies": {
56-
"@huggingface/gguf": "workspace:^"
5754
}
5855
}

‎packages/tasks/pnpm-lock.yaml

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/tasks/src/gguf.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
export enum GGMLQuantizationType {
2+
F32 = 0,
3+
F16 = 1,
4+
Q4_0 = 2,
5+
Q4_1 = 3,
6+
Q5_0 = 6,
7+
Q5_1 = 7,
8+
Q8_0 = 8,
9+
Q8_1 = 9,
10+
Q2_K = 10,
11+
Q3_K = 11,
12+
Q4_K = 12,
13+
Q5_K = 13,
14+
Q6_K = 14,
15+
Q8_K = 15,
16+
IQ2_XXS = 16,
17+
IQ2_XS = 17,
18+
IQ3_XXS = 18,
19+
IQ1_S = 19,
20+
IQ4_NL = 20,
21+
IQ3_S = 21,
22+
IQ2_S = 22,
23+
IQ4_XS = 23,
24+
I8 = 24,
25+
I16 = 25,
26+
I32 = 26,
27+
I64 = 27,
28+
F64 = 28,
29+
IQ1_M = 29,
30+
BF16 = 30,
31+
}
32+
33+
const ggufQuants = Object.values(GGMLQuantizationType).filter((v): v is string => typeof v === "string");
34+
export const GGUF_QUANT_RE = new RegExp(`(?<quant>${ggufQuants.join("|")})` + "(_(?<sizeVariation>[A-Z]+))?");
35+
export const GGUF_QUANT_RE_GLOBAL = new RegExp(GGUF_QUANT_RE, "g");
36+
37+
export function parseGGUFQuantLabel(fname: string): string | undefined {
38+
const quantLabel = fname.toUpperCase().match(GGUF_QUANT_RE_GLOBAL)?.at(-1); // if there is multiple quant substrings in a name, we prefer the last one
39+
return quantLabel;
40+
}

‎packages/tasks/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ export type {
4242
export { SPECIAL_TOKENS_ATTRIBUTES } from "./tokenizer-data";
4343

4444
import * as snippets from "./snippets";
45+
export * from "./gguf";
46+
4547
export { snippets };
4648

4749
export { SKUS, DEFAULT_MEMORY_OPTIONS } from "./hardware";

‎packages/tasks/src/local-apps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import { parseGGUFQuantLabel } from "./gguf";
12
import type { ModelData } from "./model-data";
23
import type { PipelineType } from "./pipelines";
3-
import { parseGGUFQuantLabel } from "@huggingface/gguf";
44

55
export interface LocalAppSnippet {
66
/**

0 commit comments

Comments
 (0)