This repository was archived by the owner on Sep 4, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdual_9b_test.ts
More file actions
72 lines (59 loc) · 2.92 KB
/
Copy pathdual_9b_test.ts
File metadata and controls
72 lines (59 loc) · 2.92 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { JCrossEngineDriver, JCrossTokenizerDriver } from './src/verantyx/memory/ffi-driver';
import * as path from 'path';
import * as fs from 'fs';
async function runDual9BJgen() {
console.log("=== Verantyx Dual-JGEN Telepathy Protocol (Full) ===");
const jgenPath = path.resolve(__dirname, 'qwen_9b_full.jgen');
if (!fs.existsSync(jgenPath)) {
console.error(`Error: Full 9B model not found at ${jgenPath}. Please ensure it exists.`);
return;
}
const tokenizerPath = path.resolve(__dirname, 'tokenizer.json');
console.log("\n[Cortex] Booting 9B Engines (Zero-Copy Mmap)...");
// We can use two driver instances pointing to the same file.
// OS will map the 23GB file into physical RAM only once!
const worker = new JCrossEngineDriver(jgenPath);
console.log("[Cortex] Worker Engine Loaded (O(1) Memory).");
const coder = new JCrossEngineDriver(jgenPath);
console.log("[Cortex] Coder Engine Loaded (O(1) Memory).");
console.log("\n--- [Phase 1: Worker (Cognitive Search)] ---");
// Dummy prompt token sequence (e.g., "Implement a quicksort function in Rust")
// For this POC we just use some random valid token IDs as the prompt.
const promptTokens = new Uint32Array([1056, 314, 256, 912, 1145, 12]);
console.log(`[Worker] Reading Prompt Tokens: [${promptTokens.join(', ')}]`);
// Qwen 9B has 3584 hidden dimensions
const hiddenDim = 4096;
let intentVector;
try {
intentVector = worker.executeWorkerForward(promptTokens, hiddenDim);
console.log(`[Worker] Extracted ${hiddenDim}-dim conceptual blueprint (Intent Vector) from final token.`);
} catch (e) {
console.error("Worker forward pass failed:", e);
return;
}
console.log("\n--- [Phase 2: Cortex Routing] ---");
console.log("[Cortex] Routing 4096-dim vector directly to Coder (Zero-Copy FFI)...");
console.log("\n--- [Phase 3: Coder (Latent Resonance Search)] ---");
let startToken = 0;
try {
const resonance = coder.executePuzzleInference("lm_head.weight", intentVector);
console.log(`[Coder] Resonance Lock achieved!`);
console.log(`[Coder] Locked Token ID: ${resonance.token}`);
console.log(`[Coder] Shannon Entropy (Resistance): ${resonance.entropy.toFixed(4)}`);
startToken = resonance.token;
} catch (e) {
console.error("Coder inference failed:", e);
return;
}
console.log("\n--- [Phase 4: Coder (Autoregressive Generation)] ---");
console.log(`[Coder] Engaging generation loop for 10 tokens...`);
const generatedIds = coder.executeGenerationLoop(startToken, 10);
process.stdout.write("[Coder Output]: ");
for (let i = 0; i < generatedIds.length; i++) {
process.stdout.write(generatedIds[i] + " ");
}
console.log("\n\n[Cortex] Telepathic transmission complete.");
worker.destroy();
coder.destroy();
}
runDual9BJgen();