@hy-sde-org/dsh-llm-slots 0.2.0-rc.2 → 0.2.1-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -5
- package/package.json +5 -11
- package/dist/invariant.d.ts +0 -13
- package/dist/invariant.d.ts.map +0 -1
- package/dist/invariant.js +0 -65
- package/dist/invariant.js.map +0 -1
package/README.md
CHANGED
|
@@ -50,11 +50,6 @@ Additional mounts share the same global budget and are safe but redundant.
|
|
|
50
50
|
- `setEnabled(boolean)` — toggle admission without touching capacity.
|
|
51
51
|
- `setCapacity(number)` — change the budget; a shrink applies as calls drain.
|
|
52
52
|
|
|
53
|
-
The optional `./invariant` entry registers package-owned admission-accounting
|
|
54
|
-
checks with a Cordis host's `ctx.invariants` service and needs
|
|
55
|
-
`@deepseek-ai/cordis` + `@deepseek-ai/dsh-invariants` peers only when you use
|
|
56
|
-
that entry.
|
|
57
|
-
|
|
58
53
|
## Development
|
|
59
54
|
|
|
60
55
|
```sh
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hy-sde-org/dsh-llm-slots",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1-alpha.4",
|
|
4
4
|
"description": "Host-wide model-slot admission control (ctx.modelSlots) decided FIFO at the llm/stream waterfall: a shared budget over every model call so 2-3 concurrent local inference slots stay predictable, as a standalone npm package.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -10,10 +10,6 @@
|
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"default": "./dist/index.js"
|
|
12
12
|
},
|
|
13
|
-
"./invariant": {
|
|
14
|
-
"types": "./dist/invariant.d.ts",
|
|
15
|
-
"default": "./dist/invariant.js"
|
|
16
|
-
},
|
|
17
13
|
"./package.json": "./package.json"
|
|
18
14
|
},
|
|
19
15
|
"files": [
|
|
@@ -34,17 +30,15 @@
|
|
|
34
30
|
},
|
|
35
31
|
"license": "MIT",
|
|
36
32
|
"peerDependencies": {
|
|
37
|
-
"@deepseek-ai/cordis": "~4.0.
|
|
38
|
-
"@deepseek-ai/dsh-
|
|
39
|
-
"@deepseek-ai/dsh-llm": "^0.2.0-rc.2"
|
|
33
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.2",
|
|
34
|
+
"@deepseek-ai/dsh-llm": "^0.2.1-alpha.4"
|
|
40
35
|
},
|
|
41
36
|
"dependencies": {
|
|
42
37
|
"@deepseek-ai/schemastery": "~3.18.4"
|
|
43
38
|
},
|
|
44
39
|
"devDependencies": {
|
|
45
|
-
"@deepseek-ai/cordis": "~4.0.
|
|
46
|
-
"@deepseek-ai/dsh-
|
|
47
|
-
"@deepseek-ai/dsh-llm": "^0.2.0-rc.2",
|
|
40
|
+
"@deepseek-ai/cordis": "~4.0.5-alpha.2",
|
|
41
|
+
"@deepseek-ai/dsh-llm": "^0.2.1-alpha.4",
|
|
48
42
|
"@deepseek-ai/schemastery": "~3.18.4",
|
|
49
43
|
"@types/node": "^24.0.0",
|
|
50
44
|
"typescript": "^5.9.3",
|
package/dist/invariant.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/** Package-owned model-slot admission accounting invariants. @module @hy-sde-org/dsh-llm-slots/invariant */
|
|
2
|
-
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
-
/** Cordis companion plugin name. */
|
|
4
|
-
export declare const name = "llm-slots-invariant";
|
|
5
|
-
/** Service required before the companion can reserve package ownership. */
|
|
6
|
-
export declare const inject: string[];
|
|
7
|
-
/**
|
|
8
|
-
* Register the model-slot invariant companion.
|
|
9
|
-
* @param ctx - Cordis context carrying the invariant service.
|
|
10
|
-
* @returns the installed registration's disposer after setup succeeds.
|
|
11
|
-
*/
|
|
12
|
-
export declare const apply: (ctx: Context) => Promise<() => void>;
|
|
13
|
-
//# sourceMappingURL=invariant.d.ts.map
|
package/dist/invariant.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"invariant.d.ts","sourceRoot":"","sources":["../src/invariant.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAE5G,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAOlD,oCAAoC;AACpC,eAAO,MAAM,IAAI,wBAAwB,CAAA;AACzC,2EAA2E;AAC3E,eAAO,MAAM,MAAM,UAAiB,CAAA;AA0DpC;;;;GAIG;AACH,eAAO,MAAM,KAAK,GAAI,KAAK,OAAO,KAAG,OAAO,CAAC,MAAM,IAAI,CACU,CAAA"}
|
package/dist/invariant.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/** Package-owned model-slot admission accounting invariants. @module @hy-sde-org/dsh-llm-slots/invariant */
|
|
2
|
-
const PACKAGE_NAME = '@hy-sde-org/dsh-llm-slots';
|
|
3
|
-
/** Cordis companion plugin name. */
|
|
4
|
-
export const name = 'llm-slots-invariant';
|
|
5
|
-
/** Service required before the companion can reserve package ownership. */
|
|
6
|
-
export const inject = ['invariants'];
|
|
7
|
-
/** Read live admission stats, or `undefined` when the plugin is not mounted. */
|
|
8
|
-
function readStats(ctx) {
|
|
9
|
-
const slots = ctx.get('modelSlots');
|
|
10
|
-
if (slots === undefined)
|
|
11
|
-
return undefined;
|
|
12
|
-
try {
|
|
13
|
-
return slots.stats();
|
|
14
|
-
}
|
|
15
|
-
catch {
|
|
16
|
-
// A service mid-teardown may throw; absence of stats makes the checks inert.
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Assert the gate's structural accounting around one model call, as far as a
|
|
22
|
-
* single observer can see it without coupling to concurrent streams:
|
|
23
|
-
*
|
|
24
|
-
* - `running` stays within `[0, capacity]` at settlement — a value above
|
|
25
|
-
* capacity means acquisitions leaked past the budget; a negative value means
|
|
26
|
-
* releases outran acquisitions. Cross-stream interleaving cannot break this
|
|
27
|
-
* bound, so the check never races a sibling.
|
|
28
|
-
* - `waiting` never goes negative.
|
|
29
|
-
* - `acquiredTotal` is monotonic across the observed call (it only counts
|
|
30
|
-
* acquisitions and never decreases, regardless of concurrent streams).
|
|
31
|
-
*
|
|
32
|
-
* A missing service (plugin not mounted on the checked root, or mid-teardown)
|
|
33
|
-
* makes every check inert rather than failing.
|
|
34
|
-
*/
|
|
35
|
-
async function* inspected(_options, next, fail, stats) {
|
|
36
|
-
const before = stats();
|
|
37
|
-
try {
|
|
38
|
-
yield* next();
|
|
39
|
-
}
|
|
40
|
-
finally {
|
|
41
|
-
const after = stats();
|
|
42
|
-
if (before === undefined || after === undefined)
|
|
43
|
-
return;
|
|
44
|
-
if (after.running < 0 || after.running > after.capacity) {
|
|
45
|
-
fail(`model-slot accounting broken after one call: running=${after.running} outside [0, ${after.capacity}]`);
|
|
46
|
-
}
|
|
47
|
-
if (after.waiting < 0) {
|
|
48
|
-
fail(`model-slot waiting counter went negative: ${after.waiting}`);
|
|
49
|
-
}
|
|
50
|
-
if (after.acquiredTotal < before.acquiredTotal) {
|
|
51
|
-
fail(`model-slot acquiredTotal decreased: ${after.acquiredTotal} < ${before.acquiredTotal}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
/** Install admission-accounting checks around every model call. */
|
|
56
|
-
const install = (ctx, fail) => {
|
|
57
|
-
ctx.on('llm/stream', (options, next) => inspected(options, next, fail, () => readStats(ctx)), { global: true });
|
|
58
|
-
};
|
|
59
|
-
/**
|
|
60
|
-
* Register the model-slot invariant companion.
|
|
61
|
-
* @param ctx - Cordis context carrying the invariant service.
|
|
62
|
-
* @returns the installed registration's disposer after setup succeeds.
|
|
63
|
-
*/
|
|
64
|
-
export const apply = (ctx) => Promise.resolve(ctx.invariants.register(PACKAGE_NAME, install));
|
|
65
|
-
//# sourceMappingURL=invariant.js.map
|
package/dist/invariant.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
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