omnius 1.0.923 → 1.0.925
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/dist/{providerRegistry.d.ts → _types/backend-vllm/providerRegistry.d.ts} +0 -1
- package/dist/_types/backend-vllm/types.d.ts +209 -0
- package/dist/_types/execution/av/media-capability.d.ts +94 -0
- package/dist/_types/execution/delegation-contract.d.ts +102 -0
- package/dist/_types/execution/evidence.d.ts +68 -0
- package/dist/_types/execution/html-source-evidence.d.ts +65 -0
- package/dist/_types/execution/mcp/types.d.ts +169 -0
- package/dist/_types/execution/mutation-contract.d.ts +102 -0
- package/dist/_types/execution/nol/artifacts.d.ts +39 -0
- package/dist/_types/execution/nol/checkpoint-edits.d.ts +98 -0
- package/dist/_types/execution/nol/distributions.d.ts +128 -0
- package/dist/_types/execution/nol/gguf-checkpoint-edits.d.ts +194 -0
- package/dist/_types/execution/nol/gguf-control-reader.d.ts +224 -0
- package/dist/_types/execution/nol/lora-exports.d.ts +129 -0
- package/dist/_types/execution/nol/neuronary.d.ts +212 -0
- package/dist/_types/execution/nol/pytorch-control-reader.d.ts +143 -0
- package/dist/_types/execution/nol/qwen35-head-sites.d.ts +61 -0
- package/dist/_types/execution/nol/worker-assets.d.ts +82 -0
- package/dist/_types/execution/nol/worker-protocol.d.ts +94 -0
- package/dist/_types/execution/page-content-source.d.ts +40 -0
- package/dist/_types/execution/rapid-computer-use/artifact-store.d.ts +21 -0
- package/dist/_types/execution/rapid-computer-use/contracts.d.ts +320 -0
- package/dist/_types/execution/rapid-computer-use/decision.d.ts +70 -0
- package/dist/_types/execution/rapid-computer-use/desktop-verification.d.ts +23 -0
- package/dist/_types/execution/rapid-computer-use/geometry.d.ts +57 -0
- package/dist/_types/execution/rapid-computer-use/planner.d.ts +78 -0
- package/dist/_types/execution/rapid-computer-use/trace.d.ts +80 -0
- package/dist/_types/execution/rapid-computer-use/visual.d.ts +48 -0
- package/dist/_types/execution/shell-runs.d.ts +78 -0
- package/dist/_types/execution/streamed-web-source.d.ts +64 -0
- package/dist/_types/execution/tools/browser-page-fallback.d.ts +25 -0
- package/dist/_types/execution/tools/network-egress-policy.d.ts +30 -0
- package/dist/_types/execution/tools/pdf-native-tables.d.ts +46 -0
- package/dist/_types/execution/tools/todo-store.d.ts +133 -0
- package/dist/_types/execution/tools/web-fetch.d.ts +57 -0
- package/dist/_types/execution/tools/workboard.d.ts +1223 -0
- package/dist/_types/execution/types.d.ts +549 -0
- package/dist/_types/execution/web-source.d.ts +14 -0
- package/dist/_types/memory/artifactReviewSourceIndex.d.ts +133 -0
- package/dist/_types/memory/contextMemoryLedger.d.ts +213 -0
- package/dist/_types/memory/db.d.ts +12 -0
- package/dist/_types/memory/embeddings.d.ts +36 -0
- package/dist/_types/memory/immutableEvidenceStore.d.ts +165 -0
- package/dist/_types/memory/memoryIngestion.d.ts +65 -0
- package/dist/_types/memory/memoryTypes.d.ts +312 -0
- package/dist/_types/memory/sourceCorpusStore.d.ts +331 -0
- package/dist/_types/memory/structuredMemoryStore.d.ts +105 -0
- package/dist/_types/memory/unifiedMemoryStore.d.ts +127 -0
- package/dist/_types/memory/virtualMemory.d.ts +187 -0
- package/dist/_types/orchestrator/agentic-page-content-receipt.d.ts +20 -0
- package/dist/_types/orchestrator/agentic-web-fetch-receipt.d.ts +20 -0
- package/dist/_types/orchestrator/agenticRunner.d.ts +5219 -0
- package/dist/_types/orchestrator/app-state.d.ts +171 -0
- package/dist/_types/orchestrator/artifactClaimCritic.d.ts +63 -0
- package/dist/_types/orchestrator/artifactQuality.d.ts +15 -0
- package/dist/_types/orchestrator/artifactSemanticIntegrity.d.ts +203 -0
- package/dist/_types/orchestrator/canonical-context-projection.d.ts +254 -0
- package/dist/_types/orchestrator/canonical-source-body-projection.d.ts +51 -0
- package/dist/_types/orchestrator/completion-review-pending.d.ts +24 -0
- package/dist/_types/orchestrator/completionContract.d.ts +103 -0
- package/dist/_types/orchestrator/completionFinalization.d.ts +224 -0
- package/dist/_types/orchestrator/completionLedger.d.ts +429 -0
- package/dist/_types/orchestrator/completionReadiness.d.ts +234 -0
- package/dist/_types/orchestrator/context-admission.d.ts +93 -0
- package/dist/_types/orchestrator/context-dump-retention.d.ts +25 -0
- package/dist/_types/orchestrator/context-fabric.d.ts +133 -0
- package/dist/_types/orchestrator/contextEngine.d.ts +68 -0
- package/dist/_types/orchestrator/contextWindowDump.d.ts +327 -0
- package/dist/_types/orchestrator/convergence-breaker.d.ts +225 -0
- package/dist/_types/orchestrator/convergence-progress.d.ts +66 -0
- package/dist/_types/orchestrator/deliveryCoverage.d.ts +181 -0
- package/dist/_types/orchestrator/document-persistence-goal-binding.d.ts +106 -0
- package/dist/_types/orchestrator/durable-document-worker.d.ts +85 -0
- package/dist/_types/orchestrator/evidenceBranch.d.ts +291 -0
- package/dist/_types/orchestrator/expected-inference-response.d.ts +55 -0
- package/dist/_types/orchestrator/expectedOutcomeContract.d.ts +58 -0
- package/dist/_types/orchestrator/failure-taxonomy.d.ts +36 -0
- package/dist/_types/orchestrator/focusSupervisor.d.ts +436 -0
- package/dist/_types/orchestrator/forced-update-requirement-recovery.d.ts +105 -0
- package/dist/_types/orchestrator/hooks.d.ts +100 -0
- package/dist/_types/orchestrator/inference-pressure.d.ts +61 -0
- package/dist/_types/orchestrator/integrationClosure.d.ts +89 -0
- package/dist/_types/orchestrator/interruption-lifecycle.d.ts +154 -0
- package/dist/_types/orchestrator/live-memory-passages.d.ts +51 -0
- package/dist/_types/orchestrator/liveVirtualContext.d.ts +84 -0
- package/dist/_types/orchestrator/memory-compiler.d.ts +254 -0
- package/dist/_types/orchestrator/memory-consolidation.d.ts +134 -0
- package/dist/_types/orchestrator/model-router.d.ts +17 -0
- package/dist/_types/orchestrator/modelResponseDiagnostics.d.ts +71 -0
- package/dist/_types/orchestrator/nativeRequirementAmendment.d.ts +63 -0
- package/dist/_types/orchestrator/nol/coordinator.d.ts +204 -0
- package/dist/_types/orchestrator/nol/datasets.d.ts +58 -0
- package/dist/_types/orchestrator/nol/discovery.d.ts +286 -0
- package/dist/_types/orchestrator/nol/evaluation.d.ts +59 -0
- package/dist/_types/orchestrator/nol/model-validation.d.ts +198 -0
- package/dist/_types/orchestrator/nol/statistics.d.ts +142 -0
- package/dist/_types/orchestrator/nol/store.d.ts +133 -0
- package/dist/_types/orchestrator/nol/variant-registry.d.ts +292 -0
- package/dist/_types/orchestrator/ollama-context-policy.d.ts +34 -0
- package/dist/_types/orchestrator/personality.d.ts +66 -0
- package/dist/_types/orchestrator/prompt-cache.d.ts +24 -0
- package/dist/_types/orchestrator/remote-inference-fallback.d.ts +224 -0
- package/dist/_types/orchestrator/remote-inference-policy.d.ts +58 -0
- package/dist/_types/orchestrator/request-budget.d.ts +75 -0
- package/dist/_types/orchestrator/requirementCoverage.d.ts +69 -0
- package/dist/_types/orchestrator/reviewedInterpretation.d.ts +111 -0
- package/dist/_types/orchestrator/runEvents.d.ts +115 -0
- package/dist/_types/orchestrator/runtime-rollout.d.ts +63 -0
- package/dist/_types/orchestrator/semanticVerification.d.ts +135 -0
- package/dist/_types/orchestrator/source-wide-extraction.d.ts +202 -0
- package/dist/_types/orchestrator/steeringIntake.d.ts +123 -0
- package/dist/_types/orchestrator/structured-memory-extraction-worker.d.ts +89 -0
- package/dist/_types/orchestrator/structuredMemoryInference.d.ts +62 -0
- package/dist/_types/orchestrator/successful-procedure-memory.d.ts +127 -0
- package/dist/_types/orchestrator/supportedAnswer.d.ts +68 -0
- package/dist/_types/orchestrator/taskEffectEvidence.d.ts +38 -0
- package/dist/_types/orchestrator/taskExecutionSnapshot.d.ts +67 -0
- package/dist/_types/orchestrator/taskObjective.d.ts +310 -0
- package/dist/_types/orchestrator/taskObjectiveContinuation.d.ts +134 -0
- package/dist/_types/orchestrator/taskRequirementReview.d.ts +246 -0
- package/dist/_types/orchestrator/taskRequirements.d.ts +80 -0
- package/dist/_types/orchestrator/taskSemanticAdmission.d.ts +159 -0
- package/dist/_types/orchestrator/taskWorkDelegation.d.ts +147 -0
- package/dist/_types/orchestrator/taskWorkPlan.d.ts +177 -0
- package/dist/_types/orchestrator/telegram-passive-history.d.ts +42 -0
- package/dist/_types/orchestrator/terminalTaskReport.d.ts +91 -0
- package/dist/_types/orchestrator/todoObservability.d.ts +147 -0
- package/dist/_types/orchestrator/tool-exposure-policy.d.ts +100 -0
- package/dist/_types/orchestrator/trajectory-checkpoint.d.ts +159 -0
- package/dist/_types/orchestrator/types.d.ts +185 -0
- package/dist/_types/schemas/dispatch.d.ts +53 -0
- package/dist/_types/schemas/feature-workflow.d.ts +362 -0
- package/dist/_types/schemas/messages.d.ts +15 -0
- package/dist/_types/schemas/nol-assets.d.ts +955 -0
- package/dist/_types/schemas/nol-json.d.ts +2 -0
- package/dist/_types/schemas/nol.d.ts +3995 -0
- package/dist/_types/schemas/patch.d.ts +47 -0
- package/dist/_types/schemas/plan.d.ts +47 -0
- package/dist/_types/schemas/repoProfile.d.ts +116 -0
- package/dist/_types/schemas/retrieval.d.ts +44 -0
- package/dist/_types/schemas/task.d.ts +57 -0
- package/dist/_types/schemas/tools.d.ts +16 -0
- package/dist/_types/schemas/verification.d.ts +31 -0
- package/dist/api/py-embed.js +3353 -1829
- package/dist/assets/nol-checkpoint-editor.py +701 -0
- package/dist/assets/nol-gguf-checkpoint-editor.py +785 -0
- package/dist/assets/nol-gguf-control-reader.py +428 -0
- package/dist/assets/nol-gne-tools-worker.py +425 -0
- package/dist/assets/nol-gne-worker.py +1081 -0
- package/dist/assets/nol-lora-exporter.py +349 -0
- package/dist/assets/nol-pytorch-control-reader.py +470 -0
- package/dist/assets/nol-transformers-nnsight-worker.py +512 -0
- package/dist/assets/nol-transformers-peft-validation-worker.py +385 -0
- package/dist/assets/nol-transformers-peft-worker.py +488 -0
- package/dist/assets/nol-transformers-research-worker.py +472 -0
- package/dist/assets/nol-transformers-worker.py +920 -0
- package/dist/assets/nol-vllm-owned-worker.py +803 -0
- package/dist/assets/nol-vllm-runtime.py +695 -0
- package/dist/assets/nol-vllm-tokenizer.py +93 -0
- package/dist/assets/nol-vllm-worker.py +201 -0
- package/dist/computer-use/configured-planner.d.ts +37 -0
- package/dist/computer-use/configured-point.d.ts +35 -0
- package/dist/computer-use/host-session.d.ts +60 -0
- package/dist/computer-use/runner-ui-port.d.ts +37 -0
- package/dist/computer-use/session-review.d.ts +14 -0
- package/dist/computer-use/task-spec.d.ts +84 -0
- package/dist/discovery.d.ts +16 -2
- package/dist/index.js +2 -2
- package/dist/library.d.ts +94 -10
- package/dist/library.js +144003 -87414
- package/dist/memory-maintenance-worker.js +1676 -511
- package/dist/nol/cpu-control-reader-profile.d.ts +93 -0
- package/dist/nol/cpu-control-reader-service.d.ts +87 -0
- package/dist/nol/cuda-lease.d.ts +111 -0
- package/dist/nol/cuda-mutations.d.ts +34 -0
- package/dist/nol/export-runtime-config.d.ts +114 -0
- package/dist/nol/export-service.d.ts +143 -0
- package/dist/nol/facade.d.ts +147 -0
- package/dist/nol/gguf-cpu-control-reader-profile.d.ts +106 -0
- package/dist/nol/gguf-cpu-control-reader-service.d.ts +91 -0
- package/dist/nol/gguf-model-control-verifier.d.ts +120 -0
- package/dist/nol/gguf-parameter-inventory.d.ts +28 -0
- package/dist/nol/gne-adapter.d.ts +134 -0
- package/dist/nol/gne-agent-evaluation.d.ts +84 -0
- package/dist/nol/gne-profile.d.ts +124 -0
- package/dist/nol/gne-tools-profile.d.ts +148 -0
- package/dist/nol/gne-tools-transport.d.ts +194 -0
- package/dist/nol/model-actions.d.ts +662 -0
- package/dist/nol/model-control-verifier.d.ts +135 -0
- package/dist/nol/model-json-scorer.d.ts +13 -0
- package/dist/nol/model-runtime-config.d.ts +830 -0
- package/dist/nol/model-serving.d.ts +130 -0
- package/dist/nol/model-subject-adapter.d.ts +72 -0
- package/dist/nol/model-validation-factory.d.ts +113 -0
- package/dist/nol/neuronary-catalog.d.ts +130 -0
- package/dist/nol/orphan-custody.d.ts +72 -0
- package/dist/nol/peft-conformance.d.ts +48 -0
- package/dist/nol/peft-control-types.d.ts +137 -0
- package/dist/nol/peft-control-verifier.d.ts +8 -0
- package/dist/nol/peft-model-actions.d.ts +41 -0
- package/dist/nol/peft-model-authority.d.ts +146 -0
- package/dist/nol/peft-model-controls.d.ts +20 -0
- package/dist/nol/peft-model-host.d.ts +47 -0
- package/dist/nol/peft-model-profile.d.ts +161 -0
- package/dist/nol/peft-model-runtime-config.d.ts +174 -0
- package/dist/nol/peft-model-subject-adapter.d.ts +36 -0
- package/dist/nol/peft-validation.d.ts +105 -0
- package/dist/nol/persistent-parameter-inventory.d.ts +32 -0
- package/dist/nol/runtime.d.ts +100 -0
- package/dist/nol/sqlite-store.d.ts +80 -0
- package/dist/nol/transformers-adapter.d.ts +119 -0
- package/dist/nol/transformers-nnsight.d.ts +87 -0
- package/dist/nol/transformers-peft.d.ts +107 -0
- package/dist/nol/transformers-research.d.ts +114 -0
- package/dist/nol/variant-service.d.ts +143 -0
- package/dist/nol/variant-store.d.ts +51 -0
- package/dist/nol/vllm-actions.d.ts +774 -0
- package/dist/nol/vllm-adapter.d.ts +1473 -0
- package/dist/nol/vllm-authority.d.ts +55 -0
- package/dist/nol/vllm-conformance.d.ts +662 -0
- package/dist/nol/vllm-profile.d.ts +850 -0
- package/dist/nol/vllm-protocol.d.ts +1505 -0
- package/dist/nol/vllm-runtime-config.d.ts +120 -0
- package/dist/nol/vllm-runtime.d.ts +34 -0
- package/dist/nol/vllm-startup.d.ts +235 -0
- package/dist/omni-setup-worker.js +3433 -1909
- package/dist/service-version.d.ts +0 -1
- package/dist/tui/async-process.d.ts +27 -0
- package/dist/tui/native/worker.js +3 -1
- package/dist/tui/telegram-action-session-registry.d.ts +136 -0
- package/dist/tui/telegram-cognition-queue.d.ts +154 -0
- package/dist/tui/telegram-context-packet-v2.d.ts +99 -0
- package/dist/tui/telegram-input-ownership.d.ts +78 -0
- package/dist/tui/telegram-turn-contract-v2.d.ts +62 -0
- package/dist/update-worker-runtime.js +4216 -2603
- package/docs/DISCOVERY.json +389 -0
- package/docs/DISCOVERY.md +4 -0
- package/npm-shrinkwrap.json +28 -12
- package/package.json +3 -2
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Versioned unmerged PEFT observation extension. No framework import at startup.
|
|
3
|
+
|
|
4
|
+
Three explicit teacher-forced prefills; never delegates profile to generate.
|
|
5
|
+
Facts do not issue host capability or materialized-weight equivalence authority.
|
|
6
|
+
"""
|
|
7
|
+
import hashlib
|
|
8
|
+
import importlib.util
|
|
9
|
+
import json
|
|
10
|
+
import math
|
|
11
|
+
import os
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
import struct
|
|
14
|
+
import sys
|
|
15
|
+
import uuid
|
|
16
|
+
|
|
17
|
+
sys.dont_write_bytecode = True
|
|
18
|
+
VERSION = "omnius.nol.transformers-peft-validation.v2"
|
|
19
|
+
PEFT_SHA = "acbedcc78edf2565ce8638a85df81a1e4b8a4f98c5d0dfb49b38e2785b247682"
|
|
20
|
+
BASE_SHA = "ea1950abcceda7d76c5fb54c3b10a73d5756cd947149d4b3b6d7be83ae12ebc0"
|
|
21
|
+
COMPANION = Path(__file__).resolve().parent / "nol-transformers-peft-worker.py"
|
|
22
|
+
if COMPANION.is_symlink() or hashlib.sha256(COMPANION.read_bytes()).hexdigest() != PEFT_SHA:
|
|
23
|
+
raise RuntimeError("Frozen PEFT companion identity changed")
|
|
24
|
+
spec = importlib.util.spec_from_file_location("_nol_validation_peft", COMPANION)
|
|
25
|
+
peft = importlib.util.module_from_spec(spec)
|
|
26
|
+
spec.loader.exec_module(peft)
|
|
27
|
+
base = peft.base
|
|
28
|
+
require, fields, integer, Rejected = base.require, base.fields, base.integer, base.Rejected
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def ownership():
|
|
32
|
+
return {key: base.OWNER[key] for key in ("jobId", "ownerId", "generation")}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def runtime_info(lock_path=None, hash_runtime=False, max_bytes=34359738368):
|
|
36
|
+
info = peft.ORIGINAL_BUILD(lock_path, hash_runtime, max_bytes)
|
|
37
|
+
info.update(schema="omnius.nol.transformers-peft-validation-build.v2", workerVersion=VERSION,
|
|
38
|
+
workerSha256=base.hash_file(Path(__file__).resolve())["sha256"],
|
|
39
|
+
peftWorkerSha256=PEFT_SHA, baseWorkerSha256=BASE_SHA,
|
|
40
|
+
reviewedPeftSource=peft.source_pin())
|
|
41
|
+
return info
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
base.runtime_info = runtime_info
|
|
45
|
+
base.WORKER_VERSION = VERSION
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def no_target_aliases(state, torch):
|
|
49
|
+
# Whole storage, not only equal Tensor objects, is the conservative boundary.
|
|
50
|
+
originals = state["originals"]
|
|
51
|
+
for name in state["targetHashes"]:
|
|
52
|
+
target = originals[name]
|
|
53
|
+
storage = target.untyped_storage().data_ptr()
|
|
54
|
+
require(target.is_contiguous() and target.storage_offset() == 0 and target.numel() * target.element_size() == target.untyped_storage().nbytes(),
|
|
55
|
+
"Target has unsupported view/storage geometry", "UNSUPPORTED")
|
|
56
|
+
require(all(other_name == name or other.untyped_storage().data_ptr() != storage
|
|
57
|
+
for other_name, other in originals.items()), "Tied/aliased PEFT target is unsupported", "UNSUPPORTED")
|
|
58
|
+
require(all(buffer.untyped_storage().data_ptr() != storage for buffer in state["model"].buffers()),
|
|
59
|
+
"Target aliases a model buffer", "UNSUPPORTED")
|
|
60
|
+
base_storage = {parameter.untyped_storage().data_ptr() for parameter in originals.values()}
|
|
61
|
+
factor_storage = [factor.untyped_storage().data_ptr() for factor in state["factors"].values()]
|
|
62
|
+
require(len(factor_storage) == len(set(factor_storage)) and not base_storage.intersection(factor_storage),
|
|
63
|
+
"Tied/base-aliased adapter factors are unsupported", "UNSUPPORTED")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def admit_base_sources(payload):
|
|
67
|
+
require(payload.get("model", {}).get("quantization", {}).get("method") == "none",
|
|
68
|
+
"Only unquantized dense bases are supported", "UNSUPPORTED")
|
|
69
|
+
path = base.safe_path(Path(payload["checkpointRoot"]), "config.json")
|
|
70
|
+
require(path.stat().st_size <= 1048576, "Base configuration byte limit", "CAPACITY")
|
|
71
|
+
config_ref = next((part["artifact"] for part in payload["model"].get("files", []) if part["path"] == "config.json"), None)
|
|
72
|
+
require(config_ref is not None and config_ref["sizeBytes"] <= 1048576, "Frozen base config full artifact required", "IDENTITY")
|
|
73
|
+
raw = path.read_bytes()
|
|
74
|
+
require(len(raw) == config_ref["sizeBytes"] and hashlib.sha256(raw).hexdigest() == config_ref["sha256"],
|
|
75
|
+
"Frozen base configuration bytes changed", "IDENTITY")
|
|
76
|
+
config = base.parse_json(raw.decode("utf-8", "strict"))
|
|
77
|
+
text = config.get("text_config", config)
|
|
78
|
+
require(config.get("model_type") == "qwen3_5" and text.get("model_type") == "qwen3_5_text" and
|
|
79
|
+
not config.get("quantization_config") and not text.get("quantization_config") and
|
|
80
|
+
not text.get("num_experts") and not text.get("num_local_experts"),
|
|
81
|
+
"Quantized/MoE/unreviewed base configurations are unsupported", "UNSUPPORTED")
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def capture_prefills(state, torch, token_ids, positions, forward, capture_limit, reset=None):
|
|
85
|
+
"""CPU-testable actual PEFT Linear seam, independent of Runtime.load.
|
|
86
|
+
|
|
87
|
+
`forward` performs exactly one explicit cold prefill. No generation, sampling,
|
|
88
|
+
fallback, model copy or phase-input substitution is used here.
|
|
89
|
+
"""
|
|
90
|
+
no_target_aliases(state, torch)
|
|
91
|
+
require(type(token_ids) is list and 0 < len(token_ids) <= 4096 and all(type(v) is int and 0 <= v < 2**31 for v in token_ids), "Invalid token IDs")
|
|
92
|
+
require(type(positions) is list and 0 < len(positions) <= 64 and positions == sorted(set(positions)) and
|
|
93
|
+
all(type(p) is int and 0 <= p < len(token_ids) for p in positions), "Invalid capture positions")
|
|
94
|
+
integer(capture_limit, 1, 268435456)
|
|
95
|
+
arrays, metadata, states, calls = {}, [], [], 0
|
|
96
|
+
used = 0
|
|
97
|
+
|
|
98
|
+
def save(key, value, width=None):
|
|
99
|
+
nonlocal used
|
|
100
|
+
require(key not in arrays and type(value) is torch.Tensor and value.ndim == 3 and value.shape[0] == 1 and value.shape[1] == len(token_ids),
|
|
101
|
+
"Target invocation/shape is not one full prefill", "UNSUPPORTED")
|
|
102
|
+
require(value.dtype in (torch.float32, torch.float16, torch.bfloat16) and (width is None or value.shape[2] == width), "Capture dtype/geometry changed", "IDENTITY")
|
|
103
|
+
# Admission preceded forward. This check also detects unexpected hook geometry.
|
|
104
|
+
amount = len(positions) * value.shape[2] * 4
|
|
105
|
+
require(used + amount <= capture_limit, "Capture byte budget exceeded", "CAPACITY")
|
|
106
|
+
selected = value.detach()[0, positions, :].to(dtype=torch.float32, device="cpu").contiguous()
|
|
107
|
+
require(bool(torch.isfinite(selected).all()), "Nonfinite native capture", "NUMERIC")
|
|
108
|
+
arrays[key] = selected.numpy().copy()
|
|
109
|
+
used += amount
|
|
110
|
+
|
|
111
|
+
try:
|
|
112
|
+
for index, item in enumerate(state["approved"]["geometry"]):
|
|
113
|
+
module = state["modules"][item["modulePath"]]
|
|
114
|
+
require(not module.training and module.scaling == {"default": 1.0} and (type(module.lora_dropout["default"]) is torch.nn.Identity or (type(module.lora_dropout["default"]) is torch.nn.Dropout and module.lora_dropout["default"].p == 0)),
|
|
115
|
+
"Only eval scale-one/dropout-zero PEFT is supported", "UNSUPPORTED")
|
|
116
|
+
info = {"index": index, "modulePath": item["modulePath"], "shape": item["shape"], "rank": item["rank"],
|
|
117
|
+
"baseDtype": str(module.base_layer.weight.dtype).removeprefix("torch."), "factorHashes": {}}
|
|
118
|
+
for part in ("A", "B"):
|
|
119
|
+
factor = getattr(module, "lora_" + part)["default"].weight
|
|
120
|
+
amount = factor.numel() * 4
|
|
121
|
+
require(used + amount <= capture_limit, "Factor capture byte budget exceeded", "CAPACITY")
|
|
122
|
+
arrays[f"m{index}_factor_{part}"] = factor.detach().to("cpu").contiguous().numpy().copy()
|
|
123
|
+
used += amount
|
|
124
|
+
info["factorHashes"][part] = peft.tensor_sha(factor, torch)
|
|
125
|
+
metadata.append(info)
|
|
126
|
+
for phase in ("disabled", "enabled", "restored"):
|
|
127
|
+
enabled = phase == "enabled"
|
|
128
|
+
reset_before = reset() if reset else None
|
|
129
|
+
state["model"].base_model.disable_adapter_layers()
|
|
130
|
+
peft.verify_state(state, torch, False)
|
|
131
|
+
if enabled:
|
|
132
|
+
state["model"].base_model.enable_adapter_layers()
|
|
133
|
+
for parameter in state["model"].parameters(): parameter.requires_grad_(False)
|
|
134
|
+
before = peft.verify_state(state, torch, enabled)
|
|
135
|
+
handles = []
|
|
136
|
+
try:
|
|
137
|
+
for info in metadata:
|
|
138
|
+
i, module = info["index"], state["modules"][info["modulePath"]]
|
|
139
|
+
prefix = f"m{i}_{phase}_"
|
|
140
|
+
def pre(mod, args, key=prefix + "input", width=info["shape"][1]):
|
|
141
|
+
require(len(args) >= 1, "Missing actual Linear input", "IDENTITY")
|
|
142
|
+
save(key, args[0], width)
|
|
143
|
+
def hook(key, width):
|
|
144
|
+
return lambda mod, args, output: save(key, output, width)
|
|
145
|
+
handles.append(module.register_forward_pre_hook(pre))
|
|
146
|
+
handles.append(module.base_layer.register_forward_hook(hook(prefix + "base", info["shape"][0])))
|
|
147
|
+
handles.append(module.register_forward_hook(hook(prefix + "after", info["shape"][0])))
|
|
148
|
+
if enabled:
|
|
149
|
+
handles.append(module.lora_A["default"].register_forward_hook(hook(prefix + "a", info["rank"])))
|
|
150
|
+
handles.append(module.lora_B["default"].register_forward_hook(hook(prefix + "branch", info["shape"][0])))
|
|
151
|
+
with torch.inference_mode():
|
|
152
|
+
result = forward()
|
|
153
|
+
calls += 1
|
|
154
|
+
require(getattr(result, "past_key_values", None) is None, "Prefill retained KV state", "RESET")
|
|
155
|
+
# Caller discards logits; only fixed selected coordinates are kept.
|
|
156
|
+
del result
|
|
157
|
+
finally:
|
|
158
|
+
for handle in handles: handle.remove()
|
|
159
|
+
state["model"].base_model.disable_adapter_layers()
|
|
160
|
+
after = peft.verify_state(state, torch, False)
|
|
161
|
+
reset_after = reset() if reset else None
|
|
162
|
+
states.append({"phase": phase, "before": before, "after": after, "resetBefore": reset_before, "resetAfter": reset_after})
|
|
163
|
+
expected = len(metadata) * 13
|
|
164
|
+
require(len(arrays) == expected, "Missing/repeated native target invocation", "IDENTITY")
|
|
165
|
+
for info in metadata:
|
|
166
|
+
for field in ("input", "base", "after"):
|
|
167
|
+
a, b = arrays[f'm{info["index"]}_disabled_{field}'], arrays[f'm{info["index"]}_restored_{field}']
|
|
168
|
+
require(a.tobytes() == b.tobytes(), "Disabled/restored capture differs", "RESET")
|
|
169
|
+
return arrays, {"modules": metadata, "positions": positions, "tokenIds": token_ids,
|
|
170
|
+
"states": states, "forwardCalls": calls, "inputTokens": 3 * len(token_ids), "sampledTokens": 0,
|
|
171
|
+
"captureTensorBytes": used, "parameterMergePerformed": False,
|
|
172
|
+
"numericalPolicy": "native_f32_A_then_native_f32_B_then_add_and_cast_to_base_output_dtype",
|
|
173
|
+
"materializedWeightEquivalenceClaim": False,
|
|
174
|
+
"resetMode": "native_reset_between_every_prefill" if reset else "cpu_fixture_no_native_runtime_reset"}
|
|
175
|
+
finally:
|
|
176
|
+
state["model"].base_model.disable_adapter_layers()
|
|
177
|
+
peft.verify_state(state, torch, False)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def admission(state, tokens, positions, geometry, limits):
|
|
181
|
+
fields(geometry, ("layers", "hiddenSize", "intermediateSize", "attentionHeads", "vocabSize"))
|
|
182
|
+
g = {key: integer(value, 1, 1000000) for key, value in geometry.items()}
|
|
183
|
+
fields(limits, ("maxForwardTokens", "maxCaptureBytes", "maxWorkingBytes", "maxMultiplyAdds"))
|
|
184
|
+
limits = {key: integer(value, 1) for key, value in limits.items()}
|
|
185
|
+
t, h, n, v, heads = tokens, g["hiddenSize"], g["layers"], g["vocabSize"], g["attentionHeads"]
|
|
186
|
+
parameter_elements = sum(parameter.numel() for parameter in state["originals"].values())
|
|
187
|
+
require(parameter_elements > 0, "Actual base parameter inventory required", "IDENTITY")
|
|
188
|
+
attention_width_bound = max(h, 65536)
|
|
189
|
+
# Deliberately loose bounds over actual full parameter inventory and reviewed
|
|
190
|
+
# dense Qwen attention/recurrent widths, not the smaller 4*H^2 approximation.
|
|
191
|
+
require(heads <= 256 and h <= 65536 and g["intermediateSize"] <= 262144, "Unsupported compute geometry", "UNSUPPORTED")
|
|
192
|
+
multiply = 3 * (16*t*parameter_elements + 128*n*t*t*attention_width_bound + t*h*v)
|
|
193
|
+
capture = 65536
|
|
194
|
+
for item in state["approved"]["geometry"]:
|
|
195
|
+
out, inp = item["shape"]; rank = item["rank"]
|
|
196
|
+
multiply += 3*t*rank*(inp+out)
|
|
197
|
+
capture += (rank*(inp+out) + positions*(3*inp+7*out+rank))*4 + 13*1024
|
|
198
|
+
working = 4*t*h*(256*n+128) + 32*t*g["intermediateSize"]*n + 64*t*t*heads*n + 16*t*v + capture*3 + state["approved"]["totalBytes"]*2 + state["approved"]["factorBytes"]*2
|
|
199
|
+
require(3*t <= limits["maxForwardTokens"] and capture <= limits["maxCaptureBytes"] and
|
|
200
|
+
working <= limits["maxWorkingBytes"] and multiply <= limits["maxMultiplyAdds"], "Pre-forward compute/capture/working admission denied", "CAPACITY")
|
|
201
|
+
return {"forwardTokens": 3*t, "captureBytesBound": capture, "workingBytesBound": working,
|
|
202
|
+
"multiplyAddsBound": multiply, "baseParameterElements": parameter_elements, "basis": "conservative_actual_parameter_inventory_dense_qwen_prefill_planning_not_measured_flops_or_peak_memory"}
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def publish_capture(work_root, arrays, maximum):
|
|
206
|
+
import numpy as np
|
|
207
|
+
root = Path(work_root)
|
|
208
|
+
require(root.is_absolute() and not root.is_symlink() and root.is_dir() and root.resolve() == root and
|
|
209
|
+
root.stat().st_mode & 0o077 == 0, "Private existing capture root required", "IDENTITY")
|
|
210
|
+
# Bound uncompressed NPZ headers/ZIP overhead BEFORE opening/writing.
|
|
211
|
+
bound = sum(value.nbytes + 1024 for value in arrays.values()) + 65536
|
|
212
|
+
require(bound <= maximum, "Capture publication reservation too small", "CAPACITY")
|
|
213
|
+
path = root / ("peft-capture-" + str(uuid.uuid4()) + ".npz")
|
|
214
|
+
fd = os.open(path, os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_NOFOLLOW, 0o600)
|
|
215
|
+
try:
|
|
216
|
+
with os.fdopen(fd, "wb") as output:
|
|
217
|
+
np.savez(output, **arrays)
|
|
218
|
+
output.flush(); os.fsync(output.fileno())
|
|
219
|
+
actual = base.hash_file(path, maximum)
|
|
220
|
+
return {"path": str(path), **actual, "mediaType": "application/x-npz"}
|
|
221
|
+
except BaseException:
|
|
222
|
+
try: path.unlink()
|
|
223
|
+
except FileNotFoundError: pass
|
|
224
|
+
raise
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
class Runtime(peft.Runtime):
|
|
228
|
+
def __init__(self):
|
|
229
|
+
super().__init__()
|
|
230
|
+
self.used_keys = set()
|
|
231
|
+
self.forward_confirmed = False
|
|
232
|
+
|
|
233
|
+
def load(self, payload):
|
|
234
|
+
admit_base_sources(payload)
|
|
235
|
+
result = super().load(payload)
|
|
236
|
+
no_target_aliases(self.peft_state, self.torch)
|
|
237
|
+
result.update(implementation=VERSION, ownership=ownership(), peftWorkerSha256=PEFT_SHA, baseWorkerSha256=BASE_SHA,
|
|
238
|
+
supportedAssets=["standard_peft_unmerged_lora"], nativeCapabilityAuthority=False)
|
|
239
|
+
return result
|
|
240
|
+
|
|
241
|
+
def consume(self, key):
|
|
242
|
+
require(type(key) is str and base.SHA.fullmatch(key) and key not in self.used_keys and len(self.used_keys) < 10000,
|
|
243
|
+
"Missing/replayed caller cache key", "IDENTITY")
|
|
244
|
+
self.used_keys.add(key) # No refund after failure/reset.
|
|
245
|
+
|
|
246
|
+
def confirm_forward(self, payload):
|
|
247
|
+
self.ready(); fields(payload, ("pid", "startIdentity"))
|
|
248
|
+
actual = base.placement(self.gpu_uuid)
|
|
249
|
+
require(payload == {"pid": actual["pid"], "startIdentity": actual["startIdentity"]}, "First-forward gate placement changed", "PLACEMENT")
|
|
250
|
+
self.forward_confirmed = True
|
|
251
|
+
return {"confirmed": True, "placement": actual, "nativeCapabilityAuthority": False}
|
|
252
|
+
|
|
253
|
+
def generate(self, payload):
|
|
254
|
+
self.ready(); require(self.forward_confirmed, "Explicit host first-forward confirmation required", "PLACEMENT")
|
|
255
|
+
self.consume(payload.get("cacheKeyDigest"))
|
|
256
|
+
config = getattr(self.model.config, "text_config", self.model.config)
|
|
257
|
+
require(getattr(config, "model_type", None) == "qwen3_5_text" and not getattr(config, "num_experts", 0), "Unsupported generation architecture", "UNSUPPORTED")
|
|
258
|
+
prompt = self.tokenize({"messages": payload["messages"]})["tokenIds"]
|
|
259
|
+
maximum = integer(payload["maxTokens"], 1, self.limits["maxOutputTokens"])
|
|
260
|
+
geometry = {"layers": config.num_hidden_layers, "hiddenSize": config.hidden_size,
|
|
261
|
+
"intermediateSize": config.intermediate_size, "attentionHeads": config.num_attention_heads,
|
|
262
|
+
"vocabSize": config.vocab_size}
|
|
263
|
+
# Bound every cold autoregressive forward using the largest prefix;
|
|
264
|
+
# generation retains no NPZ, but the larger profile working bound is safe.
|
|
265
|
+
factor = (maximum + 2) // 3
|
|
266
|
+
bounds = admission(self.peft_state, len(prompt) + maximum, 1, geometry,
|
|
267
|
+
{"maxForwardTokens": 3*(len(prompt)+maximum), "maxCaptureBytes": 268435456,
|
|
268
|
+
"maxWorkingBytes": self.limits["maxWorkingBytes"],
|
|
269
|
+
"maxMultiplyAdds": self.limits["maxMultiplyAdds"] // factor})
|
|
270
|
+
bounds["multiplyAddsBound"] *= factor
|
|
271
|
+
bounds["forwardTokens"] = maximum*(len(prompt)+maximum)
|
|
272
|
+
bounds["maxForwardCalls"] = maximum
|
|
273
|
+
self.charge(bounds["multiplyAddsBound"])
|
|
274
|
+
result = super().generate(payload)
|
|
275
|
+
result["native"]["generationAdmission"] = bounds
|
|
276
|
+
# Raw native base binding is preserved; composition is a distinct fact.
|
|
277
|
+
result["native"]["implementation"] = VERSION
|
|
278
|
+
result["native"]["ownership"] = ownership()
|
|
279
|
+
result["native"]["peftComposition"] = {"adapterModelDigest": self.peft_state["approved"]["manifest"]["modelDigest"],
|
|
280
|
+
"nativeBaseBinding": self.binding, "parameterMergePerformed": False}
|
|
281
|
+
return result
|
|
282
|
+
|
|
283
|
+
def profile(self, payload):
|
|
284
|
+
if type(payload) is dict and payload.get("mode") == "confirm_first_forward":
|
|
285
|
+
fields(payload, ("mode", "pid", "startIdentity"))
|
|
286
|
+
return self.confirm_forward({key: payload[key] for key in ("pid", "startIdentity")})
|
|
287
|
+
self.ready(); require(self.forward_confirmed, "Explicit host first-forward confirmation required", "PLACEMENT")
|
|
288
|
+
fields(payload, ("mode", "messages", "expectedTokenIds", "positions", "cacheKeyDigest", "workRoot", "geometry", "limits"))
|
|
289
|
+
require(payload["mode"] == "unmerged_linear_conformance", "Unknown observation mode", "UNSUPPORTED")
|
|
290
|
+
require(self.last_reset is not None and self.last_reset.get("peft", {}).get("enabled") is False, "Explicit disabled reset required", "RESET")
|
|
291
|
+
tokens = self.tokenize({"messages": payload["messages"]})["tokenIds"]
|
|
292
|
+
require(tokens == payload["expectedTokenIds"], "Teacher-forced token identity mismatch", "IDENTITY")
|
|
293
|
+
positions = payload["positions"]
|
|
294
|
+
require(type(positions) is list and 0 < len(positions) <= 64 and positions == sorted(set(positions)) and
|
|
295
|
+
all(type(p) is int and 0 <= p < len(tokens) for p in positions), "Invalid capture positions")
|
|
296
|
+
# Only the reviewed dense Qwen3.5 model is admitted by this bound.
|
|
297
|
+
config = self.model.config
|
|
298
|
+
config = getattr(config, "text_config", config)
|
|
299
|
+
require(getattr(config, "model_type", None) == "qwen3_5_text" and not getattr(config, "num_experts", 0), "Unsupported profile architecture", "UNSUPPORTED")
|
|
300
|
+
actual_geometry = {"layers": config.num_hidden_layers, "hiddenSize": config.hidden_size,
|
|
301
|
+
"intermediateSize": config.intermediate_size, "attentionHeads": config.num_attention_heads,
|
|
302
|
+
"vocabSize": config.vocab_size}
|
|
303
|
+
require(base.same_json(payload["geometry"], actual_geometry), "Frozen model compute geometry changed", "IDENTITY")
|
|
304
|
+
root = Path(payload["workRoot"])
|
|
305
|
+
require(root.is_absolute() and not root.is_symlink() and root.is_dir() and root.resolve() == root and root.stat().st_mode & 0o077 == 0,
|
|
306
|
+
"Private existing capture root required before forward", "IDENTITY")
|
|
307
|
+
bounds = admission(self.peft_state, len(tokens), len(positions), payload["geometry"], payload["limits"])
|
|
308
|
+
require(payload["limits"]["maxWorkingBytes"] <= self.limits["maxWorkingBytes"] and
|
|
309
|
+
payload["limits"]["maxMultiplyAdds"] <= self.limits["maxMultiplyAdds"], "Profile exceeds load budget", "CAPACITY")
|
|
310
|
+
self.consume(payload["cacheKeyDigest"])
|
|
311
|
+
self.charge(bounds["multiplyAddsBound"])
|
|
312
|
+
torch = self.torch
|
|
313
|
+
ids = torch.tensor([tokens], device="cuda:0", dtype=torch.long)
|
|
314
|
+
def forward():
|
|
315
|
+
return self.model(input_ids=ids, attention_mask=torch.ones_like(ids), use_cache=False, logits_to_keep=1)
|
|
316
|
+
try:
|
|
317
|
+
arrays, facts = capture_prefills(self.peft_state, torch, tokens, positions, forward, payload["limits"]["maxCaptureBytes"], self.reset)
|
|
318
|
+
torch.cuda.synchronize()
|
|
319
|
+
capture = publish_capture(payload["workRoot"], arrays, payload["limits"]["maxCaptureBytes"])
|
|
320
|
+
reset = self.reset()
|
|
321
|
+
return {"schema": "omnius.nol.peft-linear-capture.v1", "implementation": VERSION, "ownership": ownership(),
|
|
322
|
+
"binding": self.binding, "adapterModelDigest": self.peft_state["approved"]["manifest"]["modelDigest"],
|
|
323
|
+
"workerSha256": base.hash_file(Path(__file__).resolve())["sha256"], "peftWorkerSha256": PEFT_SHA,
|
|
324
|
+
"baseWorkerSha256": BASE_SHA, "cacheKeyDigest": payload["cacheKeyDigest"],
|
|
325
|
+
"capture": capture, "admission": bounds, "resetAfter": reset, **facts}
|
|
326
|
+
except BaseException:
|
|
327
|
+
try: self.reset()
|
|
328
|
+
except BaseException: self.poisoned = True
|
|
329
|
+
raise
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
def serve():
|
|
333
|
+
sys.stdout = sys.stderr
|
|
334
|
+
require(0 < base.MAX_FRAME <= 67108864 and all(base.OWNER.values()), "Private ownership and frame bounds required")
|
|
335
|
+
runtime, sequence = Runtime(), 0
|
|
336
|
+
try:
|
|
337
|
+
while True:
|
|
338
|
+
header = base.read_exact(sys.stdin.buffer, 4)
|
|
339
|
+
if header is None: break
|
|
340
|
+
size = struct.unpack(">I", header)[0]
|
|
341
|
+
require(0 < size <= base.MAX_FRAME, "Frame bound exceeded", "CAPACITY")
|
|
342
|
+
raw = base.read_exact(sys.stdin.buffer, size)
|
|
343
|
+
require(raw is not None, "Truncated request")
|
|
344
|
+
request = base.parse_json(raw.decode("utf-8", "strict"))
|
|
345
|
+
fields(request, ("schema", "kind", "sessionId", "jobId", "ownerId", "generation", "id", "action", "payload"))
|
|
346
|
+
require(request["schema"] == base.PROTOCOL and request["kind"] == "request" and
|
|
347
|
+
all(request[key] == value for key, value in base.OWNER.items()) and request["id"] == sequence + 1, "Owner/generation/sequence mismatch", "IDENTITY")
|
|
348
|
+
sequence += 1
|
|
349
|
+
response = {key: request[key] for key in ("schema", "sessionId", "jobId", "ownerId", "generation", "id", "action")}
|
|
350
|
+
response["kind"] = "response"
|
|
351
|
+
closing = False
|
|
352
|
+
try:
|
|
353
|
+
action, payload = request["action"], request["payload"]
|
|
354
|
+
if action == "hello":
|
|
355
|
+
fields(payload, ())
|
|
356
|
+
result = {"protocol": base.PROTOCOL, "workerVersion": VERSION, "ownership": ownership(),
|
|
357
|
+
"workerSha256": base.hash_file(Path(__file__).resolve())["sha256"], "peftWorkerSha256": PEFT_SHA,
|
|
358
|
+
"baseWorkerSha256": BASE_SHA, "pid": os.getpid(), "loaded": runtime.loaded,
|
|
359
|
+
"torchImported": "torch" in sys.modules, "nativeCapabilityAuthority": False}
|
|
360
|
+
elif action in ("inspect", "load", "tokenize", "generate", "profile"):
|
|
361
|
+
result = getattr(runtime, action)(payload)
|
|
362
|
+
elif action == "confirm_placement": result = runtime.confirm(payload)
|
|
363
|
+
elif action in ("reset", "close"):
|
|
364
|
+
fields(payload, ()); result = getattr(runtime, action)(); closing = action == "close"
|
|
365
|
+
else: raise Rejected("UNSUPPORTED", "Unknown validation worker action")
|
|
366
|
+
response["result"] = result
|
|
367
|
+
except Rejected as error:
|
|
368
|
+
closing = error.fatal or action in ("load", "close", "reset") or runtime.poisoned
|
|
369
|
+
response["error"] = {"code": error.code, "message": str(error)[:4096], "fatal": closing}
|
|
370
|
+
except BaseException as error:
|
|
371
|
+
base.private_diagnostic(error); closing = True
|
|
372
|
+
response["error"] = {"code": "RUNTIME_FAILURE", "message": type(error).__name__, "fatal": True}
|
|
373
|
+
encoded = json.dumps(response, ensure_ascii=False, separators=(",", ":"), allow_nan=False).encode()
|
|
374
|
+
require(len(encoded) <= base.MAX_FRAME, "Response frame bound exceeded", "CAPACITY")
|
|
375
|
+
base.WIRE_OUT.write(struct.pack(">I", len(encoded)) + encoded); base.WIRE_OUT.flush()
|
|
376
|
+
if closing: break
|
|
377
|
+
finally:
|
|
378
|
+
runtime.close()
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
if __name__ == "__main__":
|
|
382
|
+
try: serve()
|
|
383
|
+
except BaseException as error:
|
|
384
|
+
base.private_diagnostic(error)
|
|
385
|
+
sys.exit(1)
|