Repository navigation
Add native Cactus and Needle runtime - #116
Conversation
…pinned fixture - rename loader SM symbols to state_/guard_/effect_ prefixes per AGENTS.md - wire tests/cact/ into model_and_batch ctest shard - add tests/cact/loader_tests.cpp: lifecycle, malformed-image rejection (bad tag, truncated directory, out-of-bounds and unaligned offsets), bind/parse ordering, and 405-record directory parity vs the committed CSV fixture generated from route-w4-qat.cact - pin tests/models/route-w4-qat.cact fixture
…ader - src/emel/model/needle: SML binder mapping the cact loader's positional tensor table onto a named contract (embedding, per-layer runs, mHC stack, engram sites, final_norm, probe heads, tokenizer blob) validated against header geometry; every validation outcome is a guard-dispatched _error. - src/emel/text/tokenizer/needle: SML loader parsing the trailing RAW SentencePiece-BPE dump into the shared text/tokenizer vocab (SPM preprocessor/encoder consume it unchanged). - tests: doctest units with SML introspection, pinned-fixture happy paths, rejection paths, and tokenizer piece parity vs a committed CSV fixture generated by scripts/gen_cact_tokenizer_csv.py.
…xture Inverts export.py _tensors() emission back into the reference params tree from the pinned route-w4-qat.cact (exact QAT operands, not the fp32 checkpoint) and runs the maintained decode._forward_cached prefill + 2 greedy decode steps per case. Full 8192-float logits per step, manifest with prompt ids and greedy tokens. Phase-4 C++ parity tests consume these files.
…am, mhc + CQ row routes
SML graph actor under model/needle/graph consuming the phase-2 contract and the stage kernels: init decodes fp16 scales + precomputes RoPE + clears state; each prefill/decode token is one allocation-free RTC step chain with guard-routed CQ route (scalar/AVX2), engram-site vs plain layers, and growing vs full sliding-window states. Parity vs the committed 3-case JAX fixture: greedy tokens match all cases; worst rel err 9.28e-4 (<= 1e-3).
…chmark markers The f32 vector mul_mat guard honored a forced-true runtime NEON flag on builds with no NEON codegen (x86 hosts), tripping the route-exclusivity test in the kernel_and_graph coverage lane. Gate it behind the same compile-time support predicate pattern as the f16/conv/q8 routes. Also switch the new kernel sm.hpp benchmark markers to the recognized 'scaffold' tier (bench.sh only accepts scaffold|designed|ready).
New needle_graph bench_runner suite driving the native graph strictly through public events (init/prefill/decode) on the pinned tests/models/route-w4-qat.cact via the maintained loader chain. Decode measures steady-state single-core steps after a ~100-token context prefill; prefill measures a 512-token prompt. Explicit tokens_per_second in both snapshot and compare output. The closed-source libneedle 2.0.3 engine cannot be linked; its lane is recorded documented constants (145 decode / 180 prefill tok/s, user-supplied single-core measurement on this host class). All rows carry proof_status=measurement_only markers so the snapshot/compare gates skip them until baselines are approved (no snapshot consent yet). Dependency manifest gains the needle_graph records; baseline refreshed via --write-dependency-manifest (check reports fresh).
emel_needle_eval drives the maintained chain end to end (cact loader -> needle binder -> tokenizer blob -> shared SPM tokenizer -> native graph public events) and reproduces the JAX reference eval protocol (greedy, 80 new tokens, EOS stop, <tool_call> arguments parse) on /shared/effortless/train/heldout.jsonl for comparison vs the 0.840 domain / 0.760 effort reference. scripts/gen_needle_heldout_eval.py renders prompts exactly like finetune.render_example and encodes them with the byte-level export.py RefTokenizer from the pinned .cact blob; the C++ tool prefills those reference ids and reports per-row emel-tokenizer id parity separately (currently mismatching on chat-marker prompts — reported, not hidden). Probe heads (contrastive/confidence manifest codes) are not part of the reference accuracy path: the confidence head is uncalibrated for tuned weights and the contrastive head embeds tool schemas; domain/effort accuracy is a generation metric per eval_jax.py.
This reverts commit 2f2e04d.
|
Scheduler cutover is now complete and published at HEAD |
|
Final authenticated Needle/Cactus diagnostic work is published at Current live diagnostic smoke on the same model and four canonical requests:
The mismatch is now characterized rather than hidden. Authenticated The diagnostic path now:
Focused proof at the published head:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6d64446. Configure here.
Reject EMEL request rows whose thread contract, prompt count, or token limit diverges from the canonical workload while preserving lane-specific sampling and stop metadata.
Keep marker metadata authoritative by accepting only the canonical metric key set and rejecting cross-row key collisions before records are merged. Add boundary regressions for masked thread contracts, general metadata collisions, unexpected metric metadata, and duplicate metric tokens.

Summary
Verification
5cd1570cis Proven-for with empty findingsScheduler cutover
fork_join_lane_poolpath is removed and the scheduler cutover to upstream SML is complete ata6f1ec0923114dbb007b27896047097a23378562stateforward.SMLis pinned exactly to67f898e6e19d516bb445841263fd35db3f3cd3c3co_smthread-pool tests passed/tmp/probe7passed 10/10 consecutive contention runsRuntime diagnostics: native EMEL and Cactus
Maintained live diagnostics on the same host and model artifact:
These diagnostics are
comparable=false: the runtime workloads and measurement contracts are not equivalent. Native EMEL is observed to beat the Cactus engine in these maintained runs, but this PR makes no ratio, latency-equivalence, or kernel-equivalence claim. The earlier 435 tok/s figure is retained only as theoretical roofline/stretch context, not a required acceptance gate.Authenticated request contract
thread_count,thread_contract,prompt_rows,max_new_tokens, lane-specific sampling/stop identifiers, and strict marker/metric field ownershipinternal_error, suppress stale success callbacks, and invalidate all prior public outputs as required by the event lifetime contract412/335/384/216; Cactus then applies closed constrained enum-selection and validation semantics unavailable through its public API, so output and timing equivalence remain unclaimedMemory safety contract
MemoryMaxis at most 50% of effective memory, where effective memory is physical RAM limited by the minimum finitememory.maxacross ancestor cgroups.MemorySwapMax=0.ControlGroupand unified cgroup membership.memory.max=53687091200,memory.swap.max=0, and exactControlGroupmembership.Gate note
Aggregate gates were attempted but cannot run in the current environment because
zigis absent (error: zig not found); no green aggregate-gate claim is made. Earlier aggregate attempts built successfully and completed the heldout lane, but stopped or failed in unrelated lint/prerequisite lanes; repeated OOM/container crashes prohibit another aggregate rerun. The focused behavioral proofs, documentation generation check, shell syntax checks, live memory-envelope proof, scheduler proof, and blind reviews are recorded above.Merge
PR #116 remains open; merge is authority-gated and no merge is claimed.
Note
Medium Risk
Large native inference surface (loaders, kernels, graph execution) plus build-gate and callback contract changes affect every maintainer workflow; memory-envelope fail-closed behavior can block local runs on unsupported hosts.
Overview
Publishes the native Cactus/Needle runtime lane for review on PR #116: terminal planning/handoff state, verification summaries, and new architecture docs (plus Mermaid) for the
.cactloader, Needle model/graph/tokenizer, and CQ/engram/rope/SWA kernel state machines.Build and test wiring adds
EMEL_ENABLE_NEEDLE_EVAL, the maintained heldout evaluator undertools/needle_eval, Needle request SML in theemellibrary, and doctest coverage for Cactus loading, Needle binding/graph parity, Needle tokenizer loading, and the new kernel suites. CTest shards split the oldgenerator_and_runtimebucket intotext_generator,embeddings, andlogits_and_token;model_and_batchnow includestests/cact/*. Stateforward.SML is pinned to67f898e6e19d516bb445841263fd35db3f3cd3c3(upstream thread-pool scheduler fixes). CMakePresets drops bundled build/test presets.Operator policy updates
AGENTS.md,README.md, and benchmarking/determinism docs: maintained scripts must run throughscripts/build_jobs.shwith a verified Linux systemd cgroup-v2 memory cap (50% effective RAM, swap off) and fail closed on macOS; parallel matmul documentation refers tothread_pool_schedulerinstead of the removed custom fork/join lane pool. Needle vs Cactus benchmark rows are documented as diagnostic-only (comparable=false).Public API tightening:
emel::callbackthunks andfrom()factories now require noexcept callables, matching stricter runtime validation on hot paths.Reviewed by Cursor Bugbot for commit 6d64446. Subsequent review findings were repaired through current head
5cd1570cand independently re-reviewed with empty HSM and metadata-contract findings. Bugbot is set up for automated code reviews on this repo. Configure here.