Release Neuro Compiler 0.3.0
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
Files changed (50)
- .gitattributes+1-1
- .gitignore+5-9
- ARCHITECTURE.md+5-52
- CHANGELOG.md+8-17
- README.md+80-279
- REPRODUCIBILITY.md+12-67
- SHA256SUMSAdded+53
- THIRD_PARTY_NOTICES.md+19-17
- config.json+5-5
- dist/neuro_compiler-0.3.0-py3-none-any.whlAdded
- evaluation/README.mdDeleted-19
- evaluation/benchmark.jsonDeleted-294
- evaluation/cases.jsonAdded
- evaluation/clean_final_wheel.jsonAdded+11
- evaluation/contract_tests.jsonAdded+9
- evaluation/evaluate.pyAdded+19
- evaluation/export_parity.jsonAdded+14
- evaluation/fresh_package_parity.jsonAdded+10
- evaluation/portability.json+19-17
- evaluation/qualification.jsonAdded
- evaluation/qualified_codes.jsonAdded+602
- evaluation/regression.jsonDeleted-275
- evaluation/test.jsonDeleted-132
- evaluation/validation.jsonDeleted-133
- examples/compile_example.pyDeleted-11
- examples/eight_operations.cppAdded+1
- manifest.json
- neuro_compiler/__init__.py+3-3
- neuro_compiler/_verify_worker.pyAdded+14
- neuro_compiler/backbone.pyAdded+74
- neuro_compiler/backend/__init__.pyAdded+1
- neuro_compiler/backend/allocation_constants.pyAdded+2
- neuro_compiler/backend/allocator.pyAdded+120
- neuro_compiler/backend/boundary.pyAdded+49
- neuro_compiler/backend/canonical.pyAdded+125
- neuro_compiler/backend/encoder.pyAdded+53
- neuro_compiler/backend/graph.pyAdded+90
- neuro_compiler/backend/physical.pyAdded+11
- neuro_compiler/backend/policy.pyAdded+44
- neuro_compiler/backend/resident.pyAdded+85
- neuro_compiler/backend/stack.pyAdded+153
- neuro_compiler/cli.py+17-20
- neuro_compiler/compiler.py+121-110
- neuro_compiler/emulation.pyAdded+40
- neuro_compiler/legacy/__init__.pyDeleted-4
- neuro_compiler/legacy/cli.pyDeleted-18
- neuro_compiler/legacy/compiler.pyDeleted-86
- neuro_compiler/legacy/neurocc.pyDeleted-48
- neuro_compiler/legacy/neurocc_ast.pyDeleted-102
- neuro_compiler/legacy/neurocc_backend_trace.pyDeleted-38
1*.safetensors filter=lfs diff=lfs merge=lfs -text1*.safetensors filter=lfs diff=lfs merge=lfs -text
123456789__pycache__/*.pyc.venv/*.egg-info/build/dist/.env*.pt.cache/12345__pycache__/*.py[cod]*.egg-info/build/.venv/
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556# Graph compiler architecture```mermaidflowchart TDS[Restricted C++ source] --> T[Tokenization and character-offset mapping]T --> Q[Frozen Qwen blocks 1–6]Q --> A[Source-indexed neural AST]A --> SSA[Graph neural SSA]SSA --> I[Graph neural instruction selection]I --> R[Occupancy-supervised physical resource streams]R --> B[Independent neural binary encoding]B --> P[Bit packing and serialization]P --> X[Callable x86-64 SysV bytes]```The AST predicts active nodes, types, literal values, root and child pointers atsource-character identities. Raw tokenizer offsets map input characters tofeatures; they do not parse expressions or identify AST structure.SSA preserves computational identities and learns execution ordering, valuedependencies and operand references. Instruction selection retains associationswith originating computations through learned pointers and copying of operandidentities and immediate values.The allocator maintains latent streams for physical register resources. Localtemporal processing learns bindings and instruction-emission counts. Registercontent supervision supplies an auxiliary training signal at reference-alignedboundaries; reference occupancy is never supplied during inference. The modeldoes not build a deterministic interference graph or run a conventional allocator.The independent binary encoder operates per physical MIR instruction, predictingencoding templates and payload fields. Tensor lookup, bit packing, concatenationand EOS/PAD serialization are infrastructure around learned encoding decisions.There is no conventional assembler, ISA-based correction or semantic repair.| Stage | Parameters | Selected epoch || --- | ---: | ---: || AST | 753,739 | 68 || SSA | 1,078,162 | 79 || Instruction selection | 913,695 | 68 || Register allocation | 585,134 | 30 || Independent binary encoder | 311,553 | 2 || Specialized total | 3,642,283 | || Frozen backbone | 225,608,960 | || Compiler total | 229,251,243 | |Precision boundaries, masks, graph identity conventions, register descriptors,instruction vocabularies and encoding templates are preserved in the packageddefinitions and manifest configs. Intermediate APIs return the original graphfields, MIR fields, emission counts, overflow flags and instruction lengths.Resource-stream allocation and independent binary encoding have approximatelylinear program-length scaling under fixed resources and local processing.This is an architectural scaling argument, not measured generalization beyondseven operations. Other stages, including Qwen attention, retain quadraticcomponents. Dynamic representations do not imply unrestricted language support.123456789# Architecture of 0.3.0The source encoder uses the pinned Qwen2.5-Coder-0.5B tokenizer and its first six transformer blocks. The original intermediate-layer contract omits Qwen's final normalization. Learned grounded graph AST, graph SSA and graph instruction selection retain the accepted eight-operation weights and their latent boundaries.The 15E backend consumes predicted instruction-selection output. CanonicalMIR performs fixed ISA normalization and rejects unsupported or malformed rows. Exact dependency/lifetime computation and resource reservations supply explicit state. The frozen allocator scores choices using the original learned policy's tensor lookup buffers. Tensor stack lowering routes spill slots and enforces explicit register and System V callee-save/stack behavior. The original slot rank weight is negative and recorded in the manifest. A learned resident encoder and explicit numeric-payload routing emit bytes. This backend replaces both earlier neural regalloc and binary layers.These explicit lifetime, state, stack and ABI mechanisms are production components of the owner-selected hybrid design. They are not described as learned neural algorithms. The scoring LUT is a frozen buffer, not a trainable parameter. No LLVM, assembler or source-reference compiler is called by production inference. The independent verifier alone parses source expressions and runs bounded emulation; it does not repair model predictions.Export uses tensor-only SafeTensors, strict state loading, parameter-count checks and SHA-256 validation. Original accepted checkpoint SHA-256 relationships remain in the manifest. The exported AST/SSA/ISEL/final bytes match all 600 qualified cached-feature examples. Runtime changes are packaging adaptations, not new training.
12345678910111213141516171819# Changelog## 0.2.0-experimental · Python 0.2.0.dev0* Source-indexed AST and graph-based SSA/instruction selection.* Occupancy-supervised physical resource streams with the expanded curriculum.* Independent per-instruction binary encoding; 3,642,283 specialized parameters.* Trained scope expands to arbitrary binary tree topologies, one–seven operations.* Exact packaged/live regression on 2,000 validation and 2,000 held-out programs.* Preserved single/batch/intermediate APIs, pinned revisions, CPU/CUDA loading,raw bytes and optional subprocess-isolated sampled verification.* Retained a legacy inference namespace for prior V2 manifests.* No retraining, quantization or modification of selected checkpoints for export.## 0.1.0-experimental · Python 0.1.0.dev0Initial public balanced-expression NeuroCC V2 release. Preserved at Hugging Facecommit `757aecb2942c3bd66c324b925a93dd366a6a6de1`; five specialized stages with3,934,092 parameters. Validation 97.4% exact bytes and 97.7% sampled semantics.12345678910# 0.3.0- Freeze the accepted eight-operation neural input/AST/SSA/ISEL chain.- Replace legacy regalloc and binary with the frozen Round13/15E hybrid backend.- Export portable SafeTensors and immutable provenance with strict weight validation.- Package local or Hugging Face loading, CPU/CUDA inference, batch and intermediate APIs, and isolated sampled byte verification.- Stream a byte-exact pinned six-block backbone prefix into cache while preserving original intermediate normalization semantics.- Publish existing qualification evidence, all 600 source cases and byte predictions, export parity and clean installed-wheel checks.The 0.1.0-experimental and 0.2.0-experimental tags and their artifacts remain unchanged. No additional training was launched to prepare 0.3.0.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279---language:- enlicense: apache-2.0library_name: neuro_compilerbase_model: Qwen/Qwen2.5-Coder-0.5Btags:- neural-compiler- experimental- non-autoregressive- graph- x86-64---# Neuro-Compiler · 0.2.0-experimentalNeuro-Compiler is an experimental, non-autoregressive neural compiler thattranslates restricted C++ source directly into callable x86-64 machine-codefunctions. Specialized neural networks learn syntax construction, SSA generation,instruction selection, register allocation and binary encoding. The output isbytes, not generated assembly text.**Research proof of concept, not a production-ready C++ compiler.** Generatedmachine code can be incorrect or unsafe. Sampled verification is not formalequivalence and provides no correctness guarantee. No API executes code natively.## What changedThis graph architecture replaces the first release's fixed balanced-treerepresentations with source identities, graph dependencies and physical resourcestreams. It supports the trained range of arbitrary binary tree topologies withone through seven operations. Specialized parameters decrease from 3,934,092 to3,642,283; this is an architectural change, not simply a larger model.```textRestricted C++ source↓ tokenizer + raw character/token offset mappingFrozen Qwen blocks 1–6↓Source-indexed neural AST↓Graph neural SSA↓Graph neural instruction selection↓Occupancy-supervised physical resource streams↓Independent neural binary encoding↓ byte packing and serializationCallable x86-64 System V function bytes```The backbone is [Qwen/Qwen2.5-Coder-0.5B](https://huggingface.co/Qwen/Qwen2.5-Coder-0.5B),revision `0576a1bc0ae53f21860e905e081807bd7ff4a4c7`, first six layers,96 input tokens and 225,608,960 retained parameters. Its weights are downloadedseparately. Loading may initially download the complete backbone before unusedlayers are discarded. Total retained compiler parameters: **229,251,243**.## InstallationPython 3.11+; install a CPU or CUDA PyTorch build appropriate for your machine.```bashhf download chrisuser/neuro-compiler --revision 0.2.0-experimental --local-dir neuro-compilerpython -m pip install ./neuro-compiler# Optional subprocess-isolated Unicorn verification:python -m pip install './neuro-compiler[evaluation]'```CUDA regression used Python 3.14, PyTorch 2.13.0+cu132, Transformers 4.57.6,SafeTensors 0.8.0 and Hugging Face Hub 0.36.2. A fresh, fully isolated environmentinstalled the documented dependencies and passed CPU inference with PyTorch2.15.0+cpu. Exact cross-version or CPU/CUDA byte identity is not guaranteed.## Python and CLI usage```pythonfrom neuro_compiler import NeuralCompilercompiler = NeuralCompiler.from_pretrained('chrisuser/neuro-compiler', revision='0.2.0-experimental', device='cuda')# Local loading and CPU inference also work:# compiler = NeuralCompiler.from_pretrained('./neuro-compiler', device='cpu')source = '''unsigned f(unsigned a,unsigned b,unsigned c){return ((a+b)*(c-7u));}'''machine_code = compiler.compile(source)print(machine_code.hex())results = compiler.compile_batch([source, source], batch_size=32)result = compiler.compile(source, return_intermediates=True)print(result.ast, result.ssa, result.virtual_mir, result.physical_mir)print(result.machine_code, result.diagnostics)``````bashneuro-compiler --model ./neuro-compiler --file example.cpp --output f.binneuro-compiler --model ./neuro-compiler --file example.cpp --verify```The CLI supports `--revision`, `--device`, source strings and source files.Output files are raw callable function bytes, **not ELF or PE executables**.Existing output files are not overwritten. With `--verify`, failed sampledsemantics prevents writing an output file.```pythonfrom neuro_compiler.verification import verifyif __name__ == '__main__': # required for multiprocessing in standalone scriptsreport = verify(source, machine_code, samples=32, timeout=30)print(report['disassembled'], report['semantic'])```Verification uses a spawned subprocess, Capstone and Unicorn, with an enforcedtimeout. It never repairs model predictions. Serialization, complete disassembly,sampled semantic correctness, and formal equivalence are distinct. This projectdoes not provide formal verification or native execution.## Language and target scopeThe training grammar uses `unsigned f(unsigned a,unsigned b,unsigned c)` witha single return expression. Operands are the three arguments or literals `1u`through `63u`; operators are `+`, `-`, `*`, `^`, `&`, `|`. Expressions are fullyparenthesized arbitrary binary trees containing one through seven operations.Arithmetic is unsigned 32-bit wrapping arithmetic. The target is **x86-64 System V**,not the Windows x64 ABI, even when inference runs on Windows.Loops, branches, arbitrary identifiers, pointers, function calls, general memoryoperations, broader C++ syntax and general-purpose linking are unsupported.Lexical checks reject some unsupported inputs but are not a complete grammarvalidator. Formatting outside the synthetic training distribution is unvalidated.Inputs exceeding 96 Qwen tokens are rejected without truncation. Character/tokenoffset mapping is preserved; there is no deterministic parser in inference.Allocation overflow and malformed byte sequences raise errors.## Measured end-to-end results| Metric | Validation | Held-out test || --- | ---: | ---: || Programs | 2,000 | 2,000 || Sampled-correct programs | 1,974 | 1,963 || Sampled semantic accuracy | 98.70% | **98.15%** || Fully disassembled | 100% | 100% || Serializable | 100% | 100% || Exact reference bytes | 98.20% | Not measured || Input triples per function | 32 | 32 |Packaged versus original `neurocc_graph_live.py` predictions match byte-for-byteon **all 4,000 validation and held-out programs**. AST, SSA, virtual MIR, physicalMIR, emission counts, overflow flags and instruction lengths also match exactly.Semantic results match. Single-versus-batch tests passed on 32 programs fromeach split. Checkpoints were fixed before these comparisons; held-out resultswere not used to select weights or change the architecture.| Binary operations | Held-out sampled semantic accuracy || ---: | ---: || 1 | 100% || 2 | 100% || 3 | 99.30% || 4 | 100% || 5 | 98.95% || 6 | 95.79% || 7 | 92.98% || Expression topology | Held-out sampled semantic accuracy || --- | ---: || Left chain | 99.80% || Balanced shape | 98.39% || Right chain | 97.59% || Random | 96.83% |These are narrow synthetic-distribution measurements. See the exact counts andsplit hashes in `evaluation/` and `manifest.json`.## Individual-network measurementsThe occupancy allocator's saved validation reports 98.15% exact physical MIRreconstruction and 98.60% sampled semantics. These are allocator-stage metrics,not final held-out compiler metrics. The independent binary encoder reconstructs100% of reference validation binaries **given correct reference physical MIR**;it cannot correct earlier neural errors.Occupancy readouts achieve 99.48% overall register-content identity accuracy and99.34% computed-value identity accuracy. These measurements use **supervised,reference-aligned instruction boundaries**; they do not establish end-to-endruntime register-state correctness. The manifest retains the saved stage metrics.## PerformanceNew end-to-end graph-runtime measurements on 2,000 test functions, batch 32,three repeats: median **4.961 seconds**, **403.15 candidates/second** and**395.69 sampled-correct candidates/second**. Peak CUDA allocation: **562.14 MiB**(reserved 616 MiB). Hardware: RTX 2060 SUPER and Intel Core i9-10850K.Timing includes tokenization, host/device transfers, all neural stages, bytepacking and CPU serialization; it excludes model initialization, file I/O andverification. Correct throughput multiplies measured candidate throughput bythe separately sampled semantic rate.Clang 23.1.2 at `-O0`, batch 128 and eight CPU workers measured **17,648.68functions/second**, median 0.1133 seconds, for the same source set. This baselineuses batched C++ translation units and includes frontend/backend compilation;its correctness was not evaluated by the timing. **These measurements do notshow a performance advantage over Clang.** Conditions differ in batching andhardware use; see `evaluation/benchmark.json` for the complete methodology.Separate synchronized profiling measured milliseconds per function:| Stage | ms/function || --- | ---: || Tokenization and input transfer | 1.0031 || Qwen | 1.1426 || AST | 0.1522 || SSA | 0.2170 || Instruction selection | 0.2272 || Register allocation | 0.3193 || Binary encoding | 0.0618 || Output transfer | 0.0038 |Synchronization adds overhead; these separate-pass values need not sum to theunsynchronized end-to-end time. Initialization and CPU smoke-test timings arerecorded in the regression and portability JSON reports. No historical V1 or0.1.0 throughput is presented as a measurement of this architecture.## Training and reproducibilityThe base graph curriculum has 16,000 training, 2,000 validation and 2,000 held-outprograms. Register-allocation training additionally uses 48,000 generated trainingcandidates (approximately 64,000 total curriculum programs; some generated tracesmay be filtered). Exact expansion provenance is recorded in the manifest.Reference traces supervise training and evaluation only. No dataset, cachedactivations, compiler traces, optimizer state or training script is required bythe installed inference package.All five original checkpoint hashes and selected epochs are recorded in`manifest.json`, together with configs, vocabularies, register descriptors,encoding templates, dataset hashes and exported SafeTensors hashes. They areunquantized FP32 specialized weights, preserving exact values and dtypes.CUDA Qwen uses the original FP16/autocast path; FP16 inter-stage boundaries andFP32 specialized operations match the live implementation. CPU Qwen uses FP32.The loader verifies file hashes, state schemas and vocabulary compatibility.Local preparation tools in the development checkout are`neurocc_graph_export.py`, `neurocc_graph_release_test.py`,`neurocc_graph_release_smoke.py` and `neurocc_graph_release_benchmark.py`.They operate on original artifacts without training or modifying weights.The installed-wheel portability test ran in a fresh dependency environment,outside the checkout, while denying access to original development directories.The previous release remains reproducible at commit`757aecb2942c3bd66c324b925a93dd366a6a6de1`. The library also dispatches legacyV2 manifests to its preserved legacy inference implementation. Use a pinnedrevision rather than moving `main` for reproducibility.## Research directionsThe next studies target 15, 31 and larger operation counts; more identifiers,literals and operators; longer-range value tracking and allocation; control flowand memory; and alternative pretrained frontends. Generalization beyond thecurrent seven-operation curriculum remains open.Source identities and graph pointers retain computational associations acrossstages. Several stages have size-independent learned parameters. Resource streamsand independent binary encoding have approximately linear length scaling underfixed-resource and local-processing assumptions. **The whole compiler is notlinear-time**: Qwen and other attention stages retain quadratic components.See [ARCHITECTURE.md](ARCHITECTURE.md).Natural-language-to-SSA compilation and general-purpose language models withspecialized executable-output heads are proposed research directions, notfeatures of this release. The long-term question is whether pretrained modelscan emit executable computations through learned backends without textual sourceor assembly as intermediate outputs. No claim of being the first neural compileror of guaranteed executable correctness is made.## LicenseApache-2.0 for project code and specialized weights, following 0.1.0's conventions.The pinned Qwen model metadata declares Apache-2.0. Qwen weights and third-partysource are not redistributed here. See `LICENSE` and `THIRD_PARTY_NOTICES.md`.1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980---language: enlicense: apache-2.0library_name: neuro_compilerbase_model: Qwen/Qwen2.5-Coder-0.5Btags:- compiler- neural-compiler- hybrid- x86-64- safetensors---# Neuro Compiler 0.3.0A frozen graph neural compiler for small unsigned C++ expressions, with the Round13/15E **hybrid** register allocator and machine-code backend. Neural source → AST → SSA → instruction selection is followed by exact lifetime/resource/ABI state logic, learned allocation scoring and a learned instruction encoder. This release is **not a wholly neural compiler** or an end-to-end trainable model.Version **0.3.0** freezes the accepted eight-operation upstream checkpoints and the new 15E backend. It replaces the old register-allocation **and binary-emission** stages. All released weights are frozen. Earlier releases remain available at `0.1.0-experimental` and `0.2.0-experimental`; use their matching Python packages.This is a research compiler with known incorrect outputs. Successful serialization is not a correctness guarantee. Sampled execution does not prove equivalence or optimality.## Install and compileDownload `dist/neuro_compiler-0.3.0-py3-none-any.whl` from this repository's **0.3.0 tag**, then:```bashpython -m pip install "./neuro_compiler-0.3.0-py3-none-any.whl[evaluation]"```Alternatively, download this tagged repository and run `python -m pip install ".[evaluation]"` in its root. The wheel contains code; model weights are downloaded separately by `from_pretrained`.```pythonfrom neuro_compiler import NeuralCompilerfrom neuro_compiler.verification import verifycompiler = NeuralCompiler.from_pretrained("chrisuser/neuro-compiler", revision="0.3.0", device="auto")source = "unsigned f(unsigned a,unsigned b,unsigned c){return ((a+b)*(c-7u));}"result = compiler.compile(source, return_intermediates=True)print(result.machine_code.hex())print(result.diagnostics)print(verify(source, result.machine_code, samples=32))````compile(source)` returns bytes. `compile_batch(sources, batch_size=16)` returns a list of byte strings; `strict=False` preserves rejected rows as `None`. `return_intermediates=True` returns `CompilationResult` objects with AST, SSA, virtual MIR, physical MIR and diagnostics. A local downloaded repository directory also works as `model_id`.CPU and CUDA are supported. The first load downloads the pinned Qwen backbone and tokenizer, then caches an exact six-block tensor prefix; upstream weights are not bundled. See [REPRODUCIBILITY.md](REPRODUCIBILITY.md) for memory and precision details.## Supported scope- Compact `unsigned f(unsigned a,unsigned b,unsigned c){return EXPR;}` functions.- One through **eight binary operations**: `+`, `-`, `*`, `^`, `&`, `|`, fully parenthesized expressions, arguments `a`, `b`, `c`, and unsigned literals `1u` through `63u`.- Unsigned 32-bit arithmetic; at most **105 raw characters** and **96 tokenizer tokens**. Out-of-scope inputs are not supported. Raw character overflow is rejected, with no truncation.- Output is a raw **x86-64 System V** function body: three uint32 arguments, uint32 result. It is **not Windows x64 ABI**, an ELF or PE executable, or a general C/C++ compiler. The evaluation helper emulates bytes; it never executes them natively.## Actual qualification resultsThese are the existing research validation and regression sets, **not a new held-out test**. The previous 0.2.0 release's held-out score does not describe this release.| Measure | Result || --- | ---: || Validation serialized / valid / ABI | 400 / 400 each || Validation sampled semantic correctness | **397 / 400 (99.25%)** || Hardest validation subset | **48 / 50 (96%)** || Regression sampled semantic correctness | **200 / 200 (100%)** || SafeTensors export parity: AST, SSA, ISEL and final bytes | **600 / 600 each** |Fresh original source-to-bytes qualification used 32 input triples per program, or **19,200 bounded emulated executions**. Three validation errors remain upstream in instruction selection (row IDs 16023, 16063, 16125). No acceptance criteria were weakened. Export parity reuses qualified frozen backbone features to isolate serialization/runtime changes; it is not a new full-backbone evaluation. A separate installed-wheel CPU test performs fresh source inference, with access to development directories denied.One original CUDA pass (600 functions, batch 16) measured 7.15 s startup, 9.09 s source-to-bytes inference and 66.0 functions/s; peak allocated tensor memory was 506.9 MiB. Verification is excluded. These are single-run observations, not a robust performance benchmark or a comparison against LLVM.Evidence and reproducible cases are under [evaluation/](evaluation). See [ARCHITECTURE.md](ARCHITECTURE.md) for what is neural and what is explicit logic.## Frozen artifacts- Specialized parameters: **2,765,990**; SafeTensors files: **11,089,998 bytes**.- Retained frozen Qwen parameters: **225,608,960** (embedding and six blocks; final norm is replaced with Identity to preserve the original intermediate-layer features).- Original checkpoint relationships, export hashes, precision and immutable Qwen revision are recorded in `manifest.json`.- `SHA256SUMS` covers the release tree except itself. No optimizer states, training caches or pickle checkpoints are published.- Apache-2.0 project code and specialized weights; external dependency terms are described in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677# Reproducibility and publicationRelease identifier: `0.2.0-experimental`; Python package version: `0.2.0.dev0`.The canonical model repository is `chrisuser/neuro-compiler`, confirmed duringrelease preparation. Earlier development configuration used `orthagonal`; do notupload a replacement repository under that name by accident.For inference, pin the version tag or exact published commit SHA:```pythonfrom neuro_compiler import NeuralCompilercompiler=NeuralCompiler.from_pretrained('chrisuser/neuro-compiler',revision='0.2.0-experimental',device='cuda')```Before publication the directory is usable locally with:```bashpython -m pip install '.[evaluation]'neuro-compiler --model . --source 'unsigned f(unsigned a,unsigned b,unsigned c){return ((a+b)*(c-7u));}' --verifypython -m unittest discover -s tests```The inference wheel contains code. SafeTensors/configuration files remain inthe downloaded model directory or are resolved through Hugging Face. They arenot duplicated into the wheel. Qwen is separately resolved at the pinned backbonecommit in the manifest. Original datasets and LLVM are not needed for inference.Local development-checkout reproduction commands (not runtime dependencies):```bashpython neurocc_graph_export.pypython neurocc_graph_release_test.pypython neurocc_graph_release_smoke.pypython neurocc_graph_release_benchmark.py```The exporter verifies selected original checkpoint hashes, epochs, parametercounts, schema relationships, curriculum split hashes and retained upstreamcaches/reference artifacts before exporting. It checks exact SafeTensors tensorand dtype round trips. Exact original checkpoint copies are frozen separatelyfrom the public directory. Full configs preserve historical training provenancehashes without retaining local filesystem paths.The CUDA regression compares all 2,000 validation and 2,000 test programs againstthe original live pipeline at batch 32, including every exposed intermediate,final bytes and sampled semantics. It does not select new checkpoints. CPUportability uses a fresh dependency environment and development-file accessdenial. Single/batch consistency checks cover 32 programs per split, not everypossible batching arrangement. Different hardware or numerical backends canchange predictions; broader portability remains an empirical question.The pre-0.2.0 public main was`757aecb2942c3bd66c324b925a93dd366a6a6de1`. The publication tool first preservesit as `0.1.0-experimental`, refusing to move an existing tag. It uploads a stagingbranch, compares every remote artifact hash and runs clean-environment inferencefrom that pinned revision. Only then does it update main and create the new tag.The exact final commit SHA is reported by the publication tool; Git tags shouldnot subsequently be moved. Pin the commit SHA for an immutable content reference.Publication requires an authenticated account with write access:```bashhf auth login# From the development checkout, after the local tests and final inventory:python neurocc_graph_publish.py```Tokens must never be embedded in this package or posted in logs/chat. Uploadonly this release directory, excluding its parent audit files, archived releases,checkpoint snapshots and caches. The script refuses changed local files,concurrent remote-main changes and an already-used release tag.No associated public GitHub repository was linked by the inspected prior modelcard or package metadata. The local source checkout has no Git repositorymetadata establishing one; no unrelated GitHub repository is modified.12345678910111213141516171819202122# Reproducing the releaseUse the `0.3.0` Hugging Face tag and its matching wheel. Do not mix older packages with the new manifest. Python 3.11+ is required; qualification/export used PyTorch 2.13.0+cu132, Transformers 4.57.6; clean installed-wheel CPU testing used PyTorch 2.15.0+cpu and Transformers 4.57.6. These observations do not establish every allowed dependency version as tested.Install the wheel with the `evaluation` extra, or install the downloaded repository root with `pip install ".[evaluation,dev]"`. Run:```bashpython -m pytest tests -qpython evaluation/evaluate.py --model . --device cpu --limit 8# Full 600-source sampled evaluation (slower):python evaluation/evaluate.py --model . --device cuda````evaluation/cases.json` lists the 400 existing validation and 200 regression programs. `qualified_codes.json` contains the byte-exact export predictions in the same order. `qualification.json` records the original fresh qualification; `export_parity.json` records 600-row cached-backbone export parity; `portability.json` records isolated fresh CPU inference from the installed wheel. CPU/GPU and dependency-version numerics can differ; do not mistake sampled execution for formal proof. The three known qualification failures are retained.The Qwen tokenizer/config/weights are fetched from revision `0576a1bc0ae53f21860e905e081807bd7ff4a4c7`. The backbone config and original SafeTensors hashes are pinned in `manifest.json`. An exact subset of the original tensor bytes is streamed into the Hugging Face cache. Cache provenance and hashes are checked on each load. No checkpoint or latent cache from a development drive is required. No remote model code is enabled.The backbone initially downloads the full upstream weight file; allow disk space for it, the retained six-block prefix and dependency caches. RAM/commit and GPU headroom are required during loading. Windows with a small/disabled pagefile can fail cold CUDA loads despite apparently free physical RAM. The retained prefix reduces unnecessary mappings; it does not remove memory requirements. There is no automatic CPU fallback for an explicit CUDA request.Production inference requires neither LLVM nor a reference compiler. Independent verification uses Capstone 5.0.9 and Unicorn 2.1.4 in an isolated subprocess with a wall timeout, bounded instruction execution and stack/memory/ABI checks. It never executes generated code natively. Generated functions use System V x86-64 ABI even on Windows hosts.Original accepted weights, curriculum state, training histories and candidate archives were preserved. This release is frozen without additional training. SHA256SUMS covers every public artifact except the checksum file itself.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535431bb4305fb6af7204c30dd3f55b1d70302dd1004224ee37400c003837deafe .gitattributes
f42811251b4785d0ab1b5d6c43df8d0d40c4ee15d2e05e65ffc66bc3610872f3 .gitignore
2385fe5ba342a2b041aff66b292ca68bc72311f3076e66d0b46aab2d2ed0b677 ARCHITECTURE.md
7d43de37d29b2ca6f496b438819cd39cb638ee965d9ea1cbecfe63f066d8bb5b CHANGELOG.md
cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30 LICENSE
f91371dcd2aef280e7e80d723d9c96b1a71b67ef1276bf246a71d28f0c067636 README.md
8c47c12ec608823281bbc91fd252273ccd07ea18f1ad210130fbeefc4583097c REPRODUCIBILITY.md
01fed119473876bc6fe13dae542adb46dd77aa6b7cfb9150772b351191ed1754 THIRD_PARTY_NOTICES.md
2b021e82ff795193eca292489fec2f1ed1435cdbadec8f3ee0f9e616e439fc22 config.json
2f6b05d9808d8158f0ff47d810f712c222e7325601656d11f45fcdb75a408f8f dist/neuro_compiler-0.3.0-py3-none-any.whl
f39e26511fcded945d9ed9bcc6221ac1dfd28e6ee518fe9e3cfa10ab4f8a64d4 evaluation/cases.json
62fa91a28c56bcc27c30e1909a5fa96a9f24bf184120d659afc8e0dd60edcec2 evaluation/clean_final_wheel.json
75ab76711f268763c5e72aa6fa9dfaf4f71a0ffd98ee2e156e2f77998e96526d evaluation/contract_tests.json
57d9837fd7be2da9c632c6208bb563b1155da6b2836802dd4bb5c2a46db2cc17 evaluation/evaluate.py
cf311273f4ef98eca00e0819ea36364015cc6284603aa6fde2c37f319621cbf8 evaluation/export_parity.json
0ebd977868e4edf5d05f1b560b950bcbfb8223224891f79e07e0625005624231 evaluation/fresh_package_parity.json
65d18c10f496c4dbc838d2622d0b44ea7cfcf740c7d89241a072d2fb058f19c2 evaluation/portability.json
93a8fb44c76429c982fb9461252cc675a8bc81261be9f3f62d76bfadc09e9da8 evaluation/qualification.json
5235850f47d5de74b08673cf000aca4c25731952ca31d544802e27dfd2837db8 evaluation/qualified_codes.json
cb9b9e6fdf50660e723f431054fa9a076a95b19ee67770dd89b73928c9545b65 examples/eight_operations.cpp
75726377234e68ca7e33223b7a76dcb6ee9c1eec9711781e521e09b72703caa8 manifest.json
20a15a29a7d6d80556c4894ccf2dcc0b8b5f968d3cddbc30363a72e0a0147813 neuro_compiler/__init__.py
d395434153c7f47643e076ed624f796f2c3a66ab3888e20dbacd9ee4708806af neuro_compiler/_verify_worker.py
b93211c09a538e36150c170d331ff723370618f0765c8b469b25a0fdf32d0a40 neuro_compiler/backbone.py
729007854ebf3e8db085e8d36b9ccd59c290617a4aff117f042ff8d493079a1a neuro_compiler/backend/__init__.py
d53e35de71ac08bee930fd5e8683042d9fa5d6c1eea95d91b598af8ee56b3f26 neuro_compiler/backend/allocation_constants.py
b88ead07194b0ddee42e77c08e58d46155b1c2c2e0f45d5ee8007f05e354269b neuro_compiler/backend/allocator.py
81203a2022b8ced1e4321ea5978624fee45fed1b029155090acad3c8f5ddd065 neuro_compiler/backend/boundary.py
ff99ee2056ac49612b7445c6d73ed05440617c2efa35fbd7847213df61d96dbc neuro_compiler/backend/canonical.py
d77042490506c58b98429dd96b64a077feed859dd613e150bed3685711a922e5 neuro_compiler/backend/encoder.py
28e91d0861ff1302321f70a4daacce242c8cff24b1bf450eb09a2b175ad9e015 neuro_compiler/backend/graph.py
5b88570f35a0c1f281e0816c97f705ae31f10c79166ee0e881e7dd4d8970a31a neuro_compiler/backend/physical.py
0c36e643d1648ca0dfb4ce4f9cdc3d4ef351cba84636cc4b0d9a716c076f8480 neuro_compiler/backend/policy.py
532dd4a9ddee131f4922ee8f1fba8b6a3690cc30ca71c04df01e2b4c25be5fe5 neuro_compiler/backend/resident.py
d7e04d0d572fc7e98c025b9824dcfa6bce5d176ef83b89810700eaae1cd0de62 neuro_compiler/backend/stack.py
fbab50c74d9b496ced4c3ad7962931cd09766c84e68edde615e552eb9d891f16 neuro_compiler/cli.py
f36bfe5684d22922296ac4da786f5f809e97f38ec6c60ead6b15c41724c10dff neuro_compiler/compiler.py
fca314927895e79867e00766e976b2929b884bb27364c9637db5fc1217934fbb neuro_compiler/emulation.py
f2b8cedf9eb288be51a9a9f1f629dcb5ba07b4e8ac7561ad7379598362ba4ad8 neuro_compiler/neurocc.py
a7586da6e0827e2f48a04e7eaea89d3ed66ca794ceb1f8d2ddca10fa3c03cc08 neuro_compiler/neurocc_ast.py
7bf8b7f50cac9babb6bdf796d2ce7bfd4e963add06f7dbb2ccb0791cf67dfa66 neuro_compiler/neurocc_graph_ast.py
91d999063b2f610ab634d07e541cdff9b42bb9940c61e4a3d7af29e8f5683881 neuro_compiler/neurocc_graph_ast_grounded.py
54b28ccf53ad2ad6a7a056576d00338e28f003aecec502f58862a1c75a8ba2e5 neuro_compiler/neurocc_graph_isel.py
50b5291e15f2ca3abcb39f918679738296a67ead01d3c39d295fbd46b9ad9e25 neuro_compiler/neurocc_graph_schema.py
81c0ff9ca8268faed60bca4b7c7c58e8a413dba1521be9611a75caa1b81eb712 neuro_compiler/neurocc_graph_ssa.py
713d99934cbedbfe2554191670ca2acb6c3df39b24410cab17d4da389c4cbcb4 neuro_compiler/verification.py
b6455255e310d74a5eb335650910d1b7223dd315620eb97f9f9e3e14318e1918 pyproject.toml
9b6cda69584e6577d599f45de63110d1192f70c9a95848ee5026d82230812b54 requirements.txt
aea7099fe74ef7e7a1a6e2c8f4669187a3ec097b5de449b68674440835dd623e tests/test_release.py
bde487aed28c62fb42ab8398705f70118036fe7ac2e713aec21b076fbd465bdc weights/ast.safetensors
225ac1f6511a662dc5074b3fb9c9ce8750c621b32ebfeda2b46149ad81a413bf weights/backend.safetensors
73ce7dab9c1bd84319e5dcae53903033f12c4a97e7ba2b0b685c1be79396e66f weights/isel.safetensors
398de4dfaa856d1eae82aeb28b34636989e624084b8981a8c553e40a8d14680a weights/ssa.safetensors1234567891011121314151617# Third-party components and release licensingThe frozen backbone is Qwen/Qwen2.5-Coder-0.5B, revision0576a1bc0ae53f21860e905e081807bd7ff4a4c7. Its weights and tokenizer are downloadedfrom Hugging Face rather than redistributed here. See the upstream model cardand license: https://huggingface.co/Qwen/Qwen2.5-Coder-0.5B .Runtime dependencies are separately installed: PyTorch (BSD-style license),Transformers (Apache-2.0), SafeTensors (Apache-2.0), Hugging Face Hub(Apache-2.0). Optional Capstone and Unicorn have their own BSD and GPL-familylicensing terms respectively; they are evaluation dependencies, not bundled code.Consult the installed versions' license files before redistributing them.The project owner authorized Apache-2.0 for project code and specialized trainedweights during release preparation. See LICENSE. The pinned Qwen revision'sHugging Face model metadata declares Apache-2.0; its snapshot does not containa separate LICENSE file. Its model card links to the upstream license.12345678910111213141516171819# Third-party components and release licensingThe frozen backbone is Qwen/Qwen2.5-Coder-0.5B, revision0576a1bc0ae53f21860e905e081807bd7ff4a4c7. Its weights and tokenizer are downloadedfrom Hugging Face rather than redistributed here. See the upstream model cardand license: https://huggingface.co/Qwen/Qwen2.5-Coder-0.5B .Runtime dependencies are separately installed: PyTorch (BSD-style license),Transformers (Apache-2.0), SafeTensors (Apache-2.0), Hugging Face Hub(Apache-2.0). Optional Capstone and Unicorn have their own BSD and GPL-familylicensing terms respectively; they are evaluation dependencies, not bundled code.Consult the installed versions' license files before redistributing them.The project owner authorized Apache-2.0 for project code and specialized trainedweights during release preparation. See LICENSE. The pinned Qwen revision'sHugging Face model metadata declares Apache-2.0; its snapshot does not containa separate LICENSE file. Its model card links to the upstream license.Version 0.3.0 includes the owner-supplied Round13/15E hybrid backend under the same Apache-2.0 project license. Exact lifetime/state/ABI logic is disclosed; no claim of a wholly learned backend is made. Qwen weights are not redistributed.
12345671 unmodified line91011121314{"release_version": "0.2.0-experimental","package_version": "0.2.0.dev0","architecture": "NeuroCC graph resource streams","spec": {"backbone": "Qwen/Qwen2.5-Coder-0.5B","revision": "0576a1bc0ae53f21860e905e081807bd7ff4a4c7",1 unmodified line"depths": [6]},"abi": "x86-64 System V"}123456781 unmodified line1011121314{"release_version": "0.3.0","architecture": "NeuroCC graph + frozen 15E hybrid","abi": "x86-64 System V","max_operations": 8,"spec": {"backbone": "Qwen/Qwen2.5-Coder-0.5B","revision": "0576a1bc0ae53f21860e905e081807bd7ff4a4c7",1 unmodified line"depths": [6]}}
12345678910111213141516171819# Evaluation artifacts
`validation.json` and `test.json`: fixed split stage/byte regression, sampledsemantics and grouped accuracies. `regression.json`: combined results and cachedmodel initialization times. `benchmark.json`: actual original live graph-runtimebenchmark, independent synchronized per-stage profile and Clang timing.`portability.json`: installed-wheel CPU inference in a fresh dependency venv,outside the checkout with development-directory access denied.
Full CUDA regressions used original precision and batch 32. CPU portability isa smoke test, not a complete CPU accuracy evaluation. Semantic checks use 32input triples (edge cases plus seeded random inputs), seed 20261127. They do notprove equivalence. Binary outputs and held-out metrics were not used to selector retrain any checkpoint during packaging.
Excluded: original/generated datasets, activation and stage caches, LLVM traces,optimizer/resume state, original PyTorch checkpoints, training scripts, localpaths and logs, credentials, executables, Python caches and build intermediates.Frozen original checkpoints are retained outside the public release directory.123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294{
"pipeline": {
"abi": "x86_64 SysV",
"device": "cuda",
"spec": {
"backbone": "Qwen/Qwen2.5-Coder-0.5B",
"revision": "0576a1bc0ae53f21860e905e081807bd7ff4a4c7",
"tokens": 96,
"depths": [
6
]
},
"manifest_sha256": "e7db505c0054653e111aaecdbea2542d00c901173d897cb6f9a93d3d63d2635c",
"source_fingerprint": "fecaadee6daec74c2e6ab067800ddde485698809b0e9c77ef473dfff795e396b",
"checkpoints": {
"ast": {
"sha256": "0115925b513ab25b5307c766b22510ec66db5259bb73387a1778dd8b1470ec03",
"epoch": 68,
"kind": "grounded_graph_ast"
},
"ssa": {
"sha256": "5705cb92c40cc7327da7102071f65aa12600ac9b91de64bf5fb147cb84032978",
"epoch": 79,
"kind": "graph_ssa_stage"
},
"isel": {
"sha256": "0290e3e3dea324a5e571f62503e3c070915e0dcb1b0003b188c607b4eb340fcd",
"epoch": 68,
"kind": "graph_isel_stage"
},
"regalloc": {
"sha256": "c571d8e96f3f1c3c98ca4958f2d776e6949a00ca25c12824d7311ef4318bf659",
"epoch": 30,
"kind": "graph_regalloc_occupancy_stage"
},
"binary": {
"sha256": "c137da040b13ceca334e450d23f32806bdbb01bf831456cf533e612332d14c04",
"epoch": 2,
"kind": "graph_binary_stage"
}
},
"binary_selection": {
"selected": "independent",
"candidates": [
{
"mode": "independent",
"epoch": 2,
"validation": {
"n": 2000,
"exact": 1.0,
"exact_count": 2000,
"instruction_exact": 1.0,
"length_accuracy": 1.0,
"byte_accuracy": 1.0,
"spill_n": 7,
"spill_exact": 1.0,
"nonspill_exact": 1.0
},
"sha256": "c137da040b13ceca334e450d23f32806bdbb01bf831456cf533e612332d14c04"
}
],
"policy": "Reference validation exact, instruction exact, byte accuracy; local and smaller on ties. No held-out selection."
},
"precision": "Qwen original cache precision; FP16 intermediate boundaries, FP32 specialized operations",
"scope": "Curriculum A: fully parenthesized unsigned 32-bit expressions, a/b/c, literals 1..63, 1..7 binary operations",
"reference_binary_sha256": "1ab80e559f1c8b8485abd1fb2056cc11e181c3ef0a3945b9cf6a1e3a29f56096",
"allocator_validation": {
"exact": 0.9815000295639038,
"signature_accuracy": 0.9906620383262634,
"register_accuracy": 0.9885137677192688,
"immediate_accuracy": 0.9915221333503723,
"stack_accuracy": 1.0,
"constant_repair": 0.9825000166893005,
"register_repair": 0.9900000095367432,
"spill_exact": 0.7142857313156128,
"spill_n": 7,
"nonspill_exact": 0.9824385643005371,
"n": 2000,
"structurally_executable": 0.993,
"semantic32": 0.986,
"semantic_n": 2000,
"inputs_per_function": 32,
"binding_accuracy": 0.9879426956176758,
"emission_overflow": 0,
"reference_eligible": 1992,
"predicted_instructions_mean": 6.584000110626221,
"event_count_accuracy": 0.9987921714782715,
"event_count_exact": 0.9939758777618408,
"anchor_accuracy": null,
"by_depth": {
"1": {
"n": 286,
"exact": 1.0
},
"2": {
"n": 370,
"exact": 1.0
},
"3": {
"n": 520,
"exact": 0.9903846383094788
},
"4": {
"n": 256,
"exact": 0.9921875
},
"5": {
"n": 224,
"exact": 0.9464285969734192
},
"6": {
"n": 191,
"exact": 0.9528796076774597
},
"7": {
"n": 153,
"exact": 0.9411764740943909
}
},
"by_operations": {
"1": {
"n": 286,
"exact": 1.0
},
"2": {
"n": 286,
"exact": 1.0
},
"3": {
"n": 286,
"exact": 0.996503472328186
},
"4": {
"n": 286,
"exact": 0.996503472328186
},
"5": {
"n": 286,
"exact": 0.9895104765892029
},
"6": {
"n": 285,
"exact": 0.9719298481941223
},
"7": {
"n": 285,
"exact": 0.9157894849777222
}
},
"by_origin": {
"balanced_shape": {
"n": 497,
"exact": 0.9919517040252686
},
"left_chain": {
"n": 502,
"exact": 0.9980079531669617
},
"random": {
"n": 504,
"exact": 0.954365074634552
},
"right_chain": {
"n": 497,
"exact": 0.9818913340568542
}
},
"by_balanced": {
"False": {
"n": 1559,
"exact": 0.976908266544342
},
"True": {
"n": 441,
"exact": 0.997732400894165
}
},
"occupancy": {
"labels": 49675,
"kind_accuracy": 0.9956517362858581,
"content_exact": 0.994765978862607,
"known_content_exact": 0.9948304663867443,
"by_kind": {
"0": {
"n": 5377,
"exact": 0.9942347033661894
},
"1": {
"n": 9159,
"exact": 0.9975979910470575
},
"2": {
"n": 8744,
"exact": 0.9969121683440073
},
"3": {
"n": 8270,
"exact": 0.9939540507859734
},
"4": {
"n": 11,
"exact": 0.0
},
"5": {
"n": 18114,
"exact": 0.9934304957491443
}
}
}
},
"binary_reference_validation": {
"n": 2000,
"exact": 1.0,
"exact_count": 2000,
"instruction_exact": 1.0,
"length_accuracy": 1.0,
"byte_accuracy": 1.0,
"spill_n": 7,
"spill_exact": 1.0,
"nonspill_exact": 1.0
},
"specialized_parameters_by_stage": {
"ast": 753739,
"ssa": 1078162,
"isel": 913695,
"regalloc": 585134,
"binary": 311553
},
"specialized_parameters": 3642283,
"backbone_parameters": 225608960,
"total_parameters": 229251243
},
"split": "test",
"neural": {
"functions": 2000,
"batch": 32,
"repeats": 3,
"seconds": [
4.960962400073186,
4.9124207000713795,
5.068292499985546
],
"median_seconds": 4.960962400073186,
"candidates_per_second": 403.1475828098386,
"peak_cuda_allocated_mib": 562.14208984375,
"peak_cuda_reserved_mib": 616.0,
"includes": "Tokenizer, host/device transfer, all six neural stages, byte packing and CPU byte serialization. Excludes model loading, file I/O and emulation.",
"sampled_correct_candidates_per_second": 395.68935252785656
},
"synchronized_stage_profile_ms_per_function": {
"tokenization_and_transfer": 1.0030856005614623,
"qwen": 1.142623248975724,
"ast": 0.15224995056632906,
"ssa": 0.21704874990973622,
"isel": 0.22722220013383776,
"regalloc": 0.31930019974242896,
"binary": 0.061826799996197224,
"output_transfer": 0.0037986001698300242
},
"profile_note": "Separate synchronized pass; synchronization overhead means totals need not match end-to-end benchmark.",
"clang": {
"tool": "clang++.EXE",
"optimization": "-O0",
"batch": 128,
"workers": 8,
"repeats": 3,
"seconds": [
0.11174400011077523,
0.11332290014252067,
0.11492149997502565
],
"median_seconds": 0.11332290014252067,
"functions_per_second": 17648.683518377115,
"note": "Clang C++ frontend and backend with batched translation units; may produce different bytes than unfolded SSA reference. Clang correctness not measured by this timing.",
"version": "clang version 23.1.2 (https://github.com/llvm/llvm-project 85ac560262434c9ccfc0c183ec22d4138ed647fb)"
},
"verification": {
"functions": 2000,
"serializable": 1.0,
"fully_disassembled": 1.0,
"semantic_accuracy": 0.9815,
"semantic_correct": 1963,
"inputs_per_function": 32
},
"hardware": {
"gpu": "NVIDIA GeForce RTX 2060 SUPER",
"cpu": "Intel(R) Core(TM) i9-10850K CPU @ 3.60GHz"
},
"environment": {
"python": "3.14.0",
"torch": "2.13.0+cu132"
},
"held_out_note": "Timing only; no checkpoint or architecture selection using these results."
}1234567891011{
"installed_wheel": true,
"version": "0.3.0",
"fresh_cpu_sources": 2,
"eight_operation_source": true,
"byte_matches": 2,
"sampled_abi_semantic": 2,
"startup_seconds": 5.871123899938539,
"development_access_denied": true,
"torch": "2.15.0+cpu"
}123456789{
"runner": "python -m unittest discover -s tests -v",
"device": "cpu",
"tests": 14,
"failures": 0,
"errors": 0,
"backbone_download": false,
"training": false
}12345678910111213141516171819"""Fresh source inference plus independent sampled verification; no training."""import argparse,json,timefrom pathlib import Pathfrom neuro_compiler import NeuralCompilerfrom neuro_compiler.verification import verify
def main(): p=argparse.ArgumentParser();p.add_argument('--model',default='chrisuser/neuro-compiler');p.add_argument('--revision',default='0.3.0');p.add_argument('--device',default='auto');p.add_argument('--limit',type=int);p.add_argument('--output',default='evaluation-result.json');a=p.parse_args() rows=json.loads(Path(__file__).with_name('cases.json').read_text());rows=rows if a.limit is None else rows[:a.limit] if not rows:raise ValueError('No cases selected') started=time.perf_counter();compiler=NeuralCompiler.from_pretrained(a.model,revision=a.revision,device=a.device);startup=time.perf_counter()-started started=time.perf_counter();outputs=compiler.compile_batch([r['source'] for r in rows],strict=False);elapsed=time.perf_counter()-started results=[] for row,code in zip(rows,outputs): checked={'abi':False,'semantic':False,'error':'Compilation rejected'} if code is None else verify(row['source'],code,samples=32,timeout=60) results.append({'row':row['row'],'group':row['group'],'operations':row['operations'],**checked}) report={'revision':a.revision,'device':str(compiler.dev),'startup_seconds':startup,'inference_seconds':elapsed,'functions':len(rows),'abi_correct':sum(r['abi'] for r in results),'semantic_correct':sum(r['semantic'] for r in results),'rows':results} Path(a.output).write_text(json.dumps(report,indent=2)+'\n');print(json.dumps({k:v for k,v in report.items() if k!='rows'},indent=2))if __name__=='__main__':main()1234567891011121314{
"scope": "Export regression against the qualified compiler, using its frozen neural backbone features; not a fresh backbone run",
"functions": 600,
"exact_matches": {
"ast": 600,
"ssa": 600,
"isel": 600,
"bytes": 600
},
"torch": "2.13.0+cu132",
"seconds": 15.638571199961007,
"safe_tensors_export": true,
"no_original_checkpoint_loading": true
}12345678910{
"scope": "Fresh portable package source-to-bytes CUDA inference, compared with original qualified bytes",
"functions": 600,
"exact_byte_matches": 600,
"mismatched_rows": [],
"startup_seconds": 6.952503199921921,
"inference_seconds": 9.530679299961776,
"batch_size": 16,
"no_original_checkpoint_or_latent_cache_loading": true
}12345678910111213141516171819202122{"cpu_hex": "89f801f083ea070fafc2c3","cpu_initialization_seconds": 4.065295299980789,"semantic_verification": {"row": 0,"source": "unsigned f(unsigned a,unsigned b,unsigned c){return ((a+b)*(c-7u));}","hex": "89 f8 01 f0 83 ea 07 0f af c2 c3","disassembled": true,"semantic": true,"error": null},"batch_and_intermediate_apis": true,"input_errors": {"invalid": true,"oversized": true},"torch": "2.15.0+cpu","cuda_available": false,"isolated_environment": true,"development_access_denied": true,"environment": "Fresh venv without system-site-packages; installed all documented dependencies from package indexes"}123456789101112131415161718192021222324{"package_version": "0.3.0","torch": "2.15.0+cpu","device": "cpu","startup_seconds": 6.4752321999985725,"bytes_hex": "4189d001f74181e807000000410faff889f8c3","verification": {"serialized": true,"abi": true,"semantic": true,"error": null,"samples": 32,"sampled_instructions": 192,"native_execution": false,"formal_equivalence": false},"batch_consistency": true,"intermediates": true,"invalid_inputs_rejected": 2,"installed_wheel": true,"development_access_denied": true,"system_site_packages": false,"backbone": "byte-exact prefix of the pinned original weights, original intermediate norm semantics preserved"}
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602[ "4189d041b9090000004181c9390000004489c8c3", "4189d069ff1f00000069ff2900000089f8c3", "4189d041b9030000004181e1060000004569c93e0000004129f14489c8c3", "4189d04189f14109f14181e124000000440fafcf41ba120000004529ca4489d0c3", "4189d081f63000000041b90e0000004181c11c0000004421ce4401c681c60a00000089f0c3", "4189d041b9330000004181e9020000004181c02a0000004101f04181f0290000004401c64101f14489c8c3", "4189d04589c14181f11f0000004589c24509ca4189fb4521c34531da4529d081e7310000004129f84489c0c3", "4189d041b9220000004181c11900000041ba220000004529c24521d14181c1140000004181c91e0000004181f12600000081c707000000440fafcf4489c8c3", "4189d041b9220000004569c9210000004489c8c3", "4189d041b9030000004181c92d0000004181e9040000004489c8c3", "4189d081f60600000081f61100000081ee3c00000089f0c3", "4189d069f62500000081f61800000081ce080000004429c689f0c3", "4189d041b9390000004181c91b000000440fafce4129f14121f14181f10d0000004489c8c3", "4189d04189f94529c14569c92f0000004121f94569c91c0000004129f94181e9390000004489c8c3", "4189d081c63400000009fe81ce1900000021fe81f62c00000081c6270000004431c689f0c3", "4189d041b90c0000004181f11b0000004531c14109f14521c14181c9220000004129f94569c92a0000004181c9030000004489c8c3", "4189d041b9090000004181f12f0000004489c8c3", "4189d041b93a0000004181e9090000004529c84489c0c3", "4189d041b9060000004181e9030000004569c9380000004401ce89f0c3", "4189d041b9160000004181c9130000004181f1230000004181c1180000004421ce89f0c3", "4189d041b9300000004129f94189fa4509ca4569d23f0000004431d729fe89f0c3", "4189d04589c14501c14421ce31f781f72900000069ff2900000081cf0e00000089f8c3", "41544189d041b9140000004181e90500000041ba150000004529ca4189f34509d34189f4450fafe34181c4130000004429e721fe89f0415cc3", "415441554189d041b9240000004181e9240000004181c91100000041ba0c0000004529ca4589d34529d34529d341bc360000004529dc4189fd4521e5410faffd81c71600000089f8415d415cc3", "4189d041b9230000004569c9090000004489c8c3", "4189d04589c14181c93e0000004501c84489c0c3", "4189d041b9200000004181e1260000004109f04531c14489c8c3", "4189d081c62700000041b9290000004181f10b0000004501c84401c689f0c3", "4189d041b91f0000004569c93b0000004181c10b00000041ba2b0000004181f2200000004431d64131f14489c8c3", "4189d041b91c0000004569c91d0000004181c92700000081cf1300000041ba160000004181ca1a0000004429d74131f94489c8c3", "4189d041b90800000041c1e1004189fa4569d2280000004509d14189f34509c301fe4109f3450fafcb4489c8c3", "4189d04189f94181e9310000004189fa4181c21b0000004521d181f63000000041bb090000004181f30e0000004409df21fe4129f14489c8c3", "4189d041b92a0000004181c12c0000004489c8c3", "4189d04569c00b0000004569c02f0000004489c0c3", "4189d04181f01b00000041b9030000004181f127000000450fafc14489c0c3", "4189d04189f14569c91c0000004131f94181e9270000004131f14489c8c3", "4189d041b9140000004181c11f0000004129f94181e91400000069ff360000004121f94489c8c3", "4189d081ee3b0000004409c64589c14101f141ba2f0000004181ca250000004509d14509c84489c0c3", "4189d041b90a0000004181e1330000004589c24181ca240000004429c60faffe4131fa4501d14529c14489c8c3", "4189d04589c14521c14181e10c0000004189f24531ca4181c2120000004421d729f74131f84181c01e0000004489c0c3", "4189d041b91c0000004569c9170000004489c8c3", "4189d04181c81b0000004109f04489c0c3", "4189d04189f94181f1390000004131f94509c14489c8c3", "4189d041b90a0000004181e1140000004109f14181c1020000004181e92a0000004489c8c3", "4189d041b9190000004181c90d0000004131f94521c14181c1330000004501c14489c8c3", "4189d04181c0190000004569c02f000000440fafc74131f84181f0110000004121f84489c0c3", "4189d04189f14569c9110000004181c9380000004181e1190000004109f14531c14181e9090000004109f94489c8c3", "4189d041b90b0000004569c93f000000440fafce4181f1210000004181c914000000440fafce4181e1130000004181c9370000004181c1320000004489c8c3", "4189d041b92100000041c1e1024489c8c3", "4189d041b9170000004129f1410faff989f8c3", "4189d041b9060000004181e12a0000004431cf41ba3c0000004129fa4489d0c3", "4189d081e70d00000081c71c00000081f70400000081cf3b00000089f8c3", "4189d04181e82c000000410faff081e62500000081c62600000041b93f0000004129f14489c8c3", "4189d04181e8020000004189f94501c14421ce29f781cf2d00000081cf0600000089f8c3", "4189d04189f1440fafce4569c9190000004501c84421c781e72300000081f71e00000069ff0c00000089f8c3", "4189d041b9150000004181c136000000450fafc14181f0210000004181e020000000410faff869ff030000000faff781f60b00000089f0c3", "4189d041b9390000004181c10e0000004489c8c3", "4189d081cf2d00000081cf3e00000089f8c3", "4189d081c62d00000041b9310000004181f112000000410faff189f0c3", "4189d041b9090000004181c91e00000081c72c00000069ff030000004101f94489c8c3", "4189d04181c8170000004189f14501c181ee1200000069f6270000004101f14489c8c3", "4189d04189f9440fafcf41ba340000004529ca81f60b0000004589c34509c34431de4109f24489d0c3", "41544189d041b90d0000004529c14189fa440fafd64531d141bb370000004129fb41bc190000004569e4290000004529e34531d94489c8415cc3", "4189d04101f04189f14569c9340000004531c841ba080000004181f22200000081f62e00000041bb190000004129f3450fafd34489d0c3", "4189d041b92a0000004181e1210000004489c8c3", "4189d041b9160000004181e9210000004181e12d0000004489c8c3", "4189d04109f04121f84569c03b0000004489c0c3", "4189d04589c14181e9370000004521c14181f10700000041ba210000004529ca4489d0c3", "4189d04189f14181e10a0000004181c92f0000004421cf4189f2440fafd7440fafd64489d0c3", "4189d04131f04181c01d00000041b90a0000004129f14531c84181c8350000004181f03a0000004489c0c3", "4189d04189f94181e9350000004109f94521c809fe81e61d0000004129f04131f84489c0c3", "4189d04189f14181c91600000081e71e0000004121f981e61f0000004101f141ba1b0000004181f2100000004529d14181c13e0000004489c8c3", "4189d041b9080000004181c1330000004489c8c3", "4189d04429c781cf3300000089f8c3", "4189d04189f94109f14181c118000000440fafcf4489c8c3", "4189d04589c14181e11b0000004569c9210000004509c14569c9140000004489c8c3", "4189d041b92900000041c1e1014181f1110000004109f14181e1190000004129f14489c8c3", "4189d04189f14181e117000000440fafcf4529c14569c910000000440fafce4131f94489c8c3", "4189d041b9040000004181c92c0000004529c1440fafce4529c14181c9110000004101f9450fafc84489c8c3", "4189d04189f14181f13d0000004131f94121f94181e1360000004121f94509c14181c1010000004101f14489c8c3", "4189d041b9230000004181c9080000004489c8c3", "4189d041b9030000004529c141c1e1024489c8c3", "4189d04569c03c0000004401c781cf3400000089f8c3", "4189d081c7340000004101f84181c83900000041b93b0000004529c14489c8c3", "4189d04589c14521c14189fa4521ca4431d781c72700000069ff1300000089f8c3", "4189d04189f94569c9140000004409ce81f63700000021f781e727000000440fafc74489c0c3", "4189d04589c14129f1410faff981c7250000004189f24121fa4189f3450fafda4431de440fafc64489c0c3", "4189d04189f94181c9190000004431cf81c73e00000001fe81ce2100000081e60500000081f6030000004121f04489c0c3", "4189d041b9270000004181c9200000004489c8c3", "4189d04589c1450fafc84181f1340000004489c8c3", "4189d04431c74101f04401c789f8c3", "4189d04189f94569c91200000081e72000000081cf210000004129f94489c8c3", "4189d04189f14181c91400000041ba330000004529ca4189f34129f34529d84531c24489d0c3", "4189d04189f14569c9110000004421ce41ba350000004181e22d00000041bb080000004569db0a0000004521da4421d689f0c3", "4189d04189f94181f10d0000004589c24501c24501d14181c00e00000081c71b0000004101f84501c14489c8c3", "41544189d04189f14181c91e0000004189f24101fa450fafca41bb0b0000004529c34189f4450fafe04429e64109f3450fafcb4489c8415cc3", "4189d041b91a0000004181f1220000004489c8c3", "4189d04189f94569c91f0000004409cf89f8c3", "4189d041b9200000004181e1010000004401ce81e62e00000089f0c3", "4189d081f63300000081c61500000069f63b00000021fe89f0c3", "4189d04189f14181c90f0000004121f181ce2d00000021fe4129f14489c8c3", "4189d041b9150000004181c9130000004431cf69ff3300000041ba190000004181ea310000004409d781f70200000089f8c3", "4189d041b90e0000004181e93a000000440fafce410faff181ee2800000069f62b00000081ce17000000c1e60489f0c3", "4189d04189f1440fafcf81cf3600000081cf3000000069ff2e00000041ba330000004129fa4429d6440fafce4181e13c0000004489c8c3", "4189d041b9130000004181e92a0000004489c8c3", "4189d081e72200000081e73800000089f8c3", "4189d04181c0370000004101f8440fafc64489c0c3", "4189d041b9010000004569c91f0000004181e9100000004109f94181c9210000004489c8c3", "4189d081f73e0000004431c709f74409c781f73a00000089f8c3", "4189d04589c14181c102000000440fafce4181c13c0000004121f94521c14181e9040000004489c8c3", "4189d04189f94181c9040000004181c1250000004101f14181f1340000004181e12d0000004121f94569c9310000004489c8c3", "4189d04189f14129f94181f11f0000004101f14181c13d0000004181f1240000004181f11b0000004181e9230000004181c10a0000004489c8c3", "4189d041b90f0000004181c9200000004489c8c3", "4189d04409c681c61600000089f0c3", "4189d04189f94181f1200000004431cf81c70c00000089f8c3", "4189d029fe41b90f0000004129f14421cf81c70200000089f8c3", "4189d04189f94101f14421ce81e6150000004189fa4121f24429d789f8c3", "41544189d041b9370000004181f1280000004181e11c0000004589c24509ca4589c34501d34589c44501dc4521e04489c0415cc3", "41544189d04189f94181c106000000410faff931fe41ba100000004129f24181f20d00000041bb060000004529d341bc110000004529dc4489e0415cc3", "4189d04401c669f6300000004589c1440fafce41ba160000004529ca4181f23f0000004181e22f0000004589c34531d34529d84489c0c3", "4189d041b92e0000004181c10a0000004489c8c3", "4189d04181c02f0000004181e0250000004489c0c3", "4189d041b92d0000004181c12000000081ee0b0000004121f14489c8c3", "4189d0410faff881c6220000004109f04409c789f8c3", "4189d069ff330000000faff741b91d0000004181c1320000004181e1390000004409ce89f0c3", "4189d041b90600000041c1e1024569c91300000081ce0e0000004569c0320000004431c64129f14489c8c3", "4189d081cf0c00000041b93b0000004529c1410faff941ba3a0000004181f22b0000004109f04529c2410faffa89f8c3", "41544189d04189f1440fafce4589c24569d238000000450fafca41bb320000004181eb260000004589c44509c44569e4250000004501e34531d94489c8415cc3", "4189d041b9390000004181e1070000004489c8c3", "4189d04189f9440fafcf4181e9030000004489c8c3", "4189d04189f94181e93c0000004181c10d0000004431cf89f8c3", "4189d0410faff0440fafc64569c0070000004181e83d0000004489c0c3", "4189d04569c02d00000081f60f0000004131f04181c01f0000004181e0360000004489c0c3", "4189d04421c74429c741b9370000004181c9030000004401cf4129f84181e81f0000004489c0c3", "4189d041b91a0000004181c9020000004181c90b0000004189fa4109f24109f24129fa4531d14501c14489c8c3", "4189d04189f14101f141ba1b0000004181ca370000004529d14569c9060000004109f141bb090000004569db130000004529d94509c14489c8c3", "4189d041b9160000004181c1180000004489c8c3", "4189d081ce1400000021fe89f0c3", "4189d04181f0180000004181e0020000004121f84489c0c3", "4189d04181c8100000004181f00d0000004121f84131f84489c0c3", "4189d041b92a0000004529c14109f94121f14181e92f0000004181c9180000004489c8c3", "4189d081c71800000081ef2c00000081f70500000081ef3e00000001f74409c789f8c3", "4189d04589c14181e9360000004131f94129f94529c14181e13b0000004181e1090000004181e90b0000004489c8c3", "4189d041b91c0000004181e9340000004131f14181c130000000440fafce440fafcf4129f94181c9210000004181f10e0000004489c8c3", "4189d041b9240000004181f12c0000004489c8c3", "4189d04189f14569c9270000004409ce89f0c3", "4189d041b90f0000004129f14181c1240000004181c93e0000004489c8c3", "4189d041b90b0000004569c9120000004509c84181e0190000004569c0130000004489c0c3", "4189d04181e0030000004181e03e0000004181e0150000004181f02d0000004431c789f8c3", "4189d04189f94121f141ba360000004529ca4409d6440fafc64429c769ff2300000089f8c3", "4189d081ce060000004189f94121f141ba270000004529ca410faffa69ff3800000081cf0200000081c72500000089f8c3", "4189d041b9110000004181e1200000004181f1190000004181f10a0000004189f2450fafd14189f34521d3410faff381e61300000069f62600000089f0c3", "4189d041b91b0000004181e1350000004489c8c3", "4189d069ff2200000081cf3800000089f8c3", "4189d04409c641b9180000004181e1390000004429ce89f0c3", "4189d04189f94129f169ff2e00000069ff180000004121f94489c8c3", "4189d04189f14181f121000000450fafc141ba0f0000004181f2160000004401d64101f04489c0c3", "4189d081cf0d0000004189f14131f94189f24181e21500000081ce090000004129f24531d14489c8c3", "4189d04189f14181c90a00000041ba140000004181f20f0000004509d141bb080000004181eb1300000081e62b0000004129f34501d94489c8c3", "4189d041b9040000004181c11f0000004189f24181c2310000004501d141bb370000004569db3500000081e6080000004131f04529c3450fafcb4489c8c3", "4189d041b9070000004569c9070000004489c8c3", "4189d009f781cf0100000089f8c3", "4189d081e72f00000081cf3000000081e71900000089f8c3", "4189d081e62100000081ee1800000081c63b00000081f60200000089f0c3", "4189d041b92a0000004181e9230000004181c13d0000004531c84181f0060000004181e00f0000004489c0c3", "4189d04189f14181c93400000041ba2a0000004181ea1a0000004501d14409c669f63a0000004101f14489c8c3", "4189d04189f94181e12e00000081c72100000081cf0c00000081c71a00000081cf38000000440fafcf4569c9360000004489c8c3", "41544189d041b92a0000004529c14189fa4181ca220000000faff74129f24589c34531c341bc350000004529dc4501e24529d14489c8415cc3", "4189d041b91a0000004181c10b0000004489c8c3", "4189d04589c14509c14181c9180000004489c8c3", "4189d081f60500000081f62e00000081ee2c00000089f0c3", "4189d041b9270000004181c1170000004181c1380000004131f14181e9370000004489c8c3", "4189d04589c14501c14181c1240000004531c1450fafc84109f94489c8c3", "4189d04189f14181e111000000440fafce4181e1030000004181c92a0000004109f14109f94489c8c3", "4189d04181c03d0000004131f0440fafc74131f04131f84569c0350000004129f84489c0c3", "4189d04589c1450fafc84109f14569c9240000004181c9190000004101f14129f94181c9200000004181e9350000004489c8c3", "4189d041b91a0000004181e12c0000004489c8c3", "4189d041b9180000004181c13a0000004181f1180000004489c8c3", "4189d081e63e00000081f61200000081e63700000089f0c3", "4189d04189f94181c9310000004569c92e0000004429cf4129f84489c0c3", "4189d04189f94181e1200000004589c24521ca4189fb4501d34531d8410faff889f8c3", "4189d04181c03f0000004181e02900000041b9340000004529c14181f1130000004189fa4501ca4431d789f8c3", "4189d04189f14129f14189fa4521ca4431d64589c3440fafde4501d84181f0160000004431c789f8c3", "4189d04189f14109f14569c90f00000041ba380000004529ca4181c2280000004181f22f0000004401d781e70f00000081f70500000089f8c3", "4189d041b93c0000004181f1150000004489c8c3", "4189d081f71500000081c73600000089f8c3", "4189d041b9350000004181f1180000004181e0190000004531c14489c8c3", "4189d04589c14181c9350000004589c24531c24409d64101f14489c8c3", "4189d04189f14569c90e0000004181e12b0000004189fa4121fa4409d64131f14489c8c3", "4189d041b9320000004181c91c0000004181c13f0000004189f24181f22900000031fe4121f24531d14489c8c3", "4189d041b91e0000004181c93400000069f63c0000004129f141ba250000004181ea2b00000069ff380000004131fa4501d14489c8c3", "4189d041b9290000004181c91d0000004589c24569d2240000004521d141bb200000004529c34569c00f0000004181c80d0000004501c34529d94489c8c3", "4189d041b93a0000004181c92d0000004489c8c3", "4189d041b90e0000004129f1440fafce4489c8c3", "4189d04189f94181e1340000004409cf81f71e00000089f8c3", "4189d04589c1440fafce4401ce4181e8100000004431c689f0c3", "4189d04181c81d00000041b9050000004181c13b0000004181c91a0000004529c84569c0330000004489c0c3", "4189d041b92f0000004181c9340000004189f24501ca4129f24181c21800000041bb210000004569db190000004521da4489d0c3", "4189d041b9290000004569c91c0000004569c92a0000004589c24109f24181ea320000004529c24509d14181c10f0000004489c8c3", "4189d041b9390000004181e91d00000041ba070000004529ca4521d04181f0320000004129f84181e8020000004121f04181e03f0000004489c0c3", "4189d041b91c0000004569c9140000004489c8c3", "4189d041b90b0000004181c10b0000004509c14489c8c3", "4189d041b9180000004181e9220000004121f14181c12c0000004489c8c3", "4189d041b93f0000004529c14181e11b0000004529c14569c9230000004489c8c3", "4189d04181f00e0000004109f84129f84101f04569c02b0000004489c0c3", "4189d04189f14109f14569c9290000004181e1060000004569c9130000004131f94529c14489c8c3", "4189d04101f84129f84181e8150000004129f84181f02c0000004181c8310000004181e80d0000004489c0c3", "4189d04429c681e63000000069f60300000081ce1c00000081ce2f0000004431c681c62d00000081ce0b00000089f0c3", "4189d041b9060000004181e9180000004489c8c3", "4189d041b9060000004181c92d000000450fafc14489c0c3", "4189d081f61c00000069f60b00000081c62a00000089f0c3", "4189d04189f94121f14421ce29f781f71100000089f8c3", "4189d041b9280000004181e13e0000004189f24521ca4181e21c0000004181ca050000004421d689f0c3", "4189d04189f14569c9390000004529c841ba3f0000004529c24181f20b0000004189f34529d3410faff389f0c3", "4189d041b91e0000004181e10a0000004181c92a0000004181e1350000004181f12b0000004531c84181e0350000004409c689f0c3", "4189d04569c01900000041b9220000004529c14181e1190000004189fa450fafd14181f2280000004409d701fe81ce0d00000089f0c3", "4189d041b9130000004181c1390000004489c8c3", "4189d041b9340000004181f1240000004181e1360000004489c8c3", "4189d041b92c0000004181e135000000410faff04109f14489c8c3", "4189d009fe4189f94131f94181c1060000004429ce89f0c3", "4189d04181f0130000004181c0120000004189f94181e11c000000410faff94129f84489c0c3", "4189d0410faff04189f94129f1410faff841ba1d0000004181ea380000004401d74121f94489c8c3", "4189d04589c14501c181c7310000004121f941ba1d0000004181c20100000041bb090000004181eb020000004531da4529d14489c8c3", "4189d04189f14121f14589c24569d22f0000004521d14189fb440fafdf4121f04181f0080000004521c34509d94489c8c3", "4189d041b9250000004181e1230000004489c8c3", "4189d04589c14181e11c000000450fafc14489c0c3", "4189d081ee0800000081c61f00000081f61200000089f0c3", "4189d04569c0130000004101f841b92a0000004181f12b0000004501c84489c0c3", "4189d081e62800000081c61000000009f741b93b0000004129f94181c9150000004489c8c3", "4189d04189f14181e10c00000081f71900000021fe4409c6440fafce4181c9190000004489c8c3", "4189d04189f14101f14181e11f0000004409ce21f781e73a000000c1e70381f71e00000089f8c3", "4189d041b93a0000004181c9180000004181e9120000004181e1340000004189f24101f24181f2100000004181e228000000450fafd04531d14489c8c3", "4189d041b91c0000004181c9270000004489c8c3", "4189d081f6050000004431c689f0c3", "4189d041b9010000004181f1020000004569c93c0000004181e9180000004489c8c3", "4189d04189f9440fafce4181e9220000004101f94501c14489c8c3", "4189d081ee3800000081ce3400000081ee3800000081f60400000021fe89f0c3", "4189d041b9140000004181f1110000004121f14181e9140000004181f10d0000004181e9070000004181e1130000004489c8c3", "4189d081e7170000004421c781f70900000081e71c00000081ef1400000081ef3000000081c71d00000089f8c3", "4189d041b9360000004181f1360000004181f10d0000004181f12a000000450fafc84121f14101f14109f94121f14489c8c3", "4189d041b93a0000004181f10e0000004489c8c3", "4189d0410faff081c61600000089f0c3", "4189d04189f94181c1180000004181f13a0000004409cf89f8c3", "4189d04589c1450fafc84569c91d0000004181f1080000004569c9070000004489c8c3", "4189d041b9270000004181c9080000004181c93f00000041ba290000004529ca4569d2140000004509d04489c0c3", "4189d041b92a0000004181e10c0000004181e10e0000004501c8410faff809fe81e60500000089f0c3", "4189d041b9160000004529c14589c2450fafd14181ca3e0000004181c20a0000004181c22c0000004501d04181e0250000004489c0c3", "4189d04189f14181e92500000041ba380000004529ca4429d781e73e00000081c72b00000031fe81f63700000081e63c00000089f0c3", "4189d041b92a0000004181c9100000004489c8c3", "4189d041b93d0000004529c14401cf89f8c3", "4189d009fe41b91e0000004181c91f000000410faff189f0c3", "4189d04181e82400000081c61700000081f6180000004121f04489c0c3", "4189d041b9260000004129f94181c92700000021fe69f6030000004121f14489c8c3", "4189d041b93f0000004181e9350000004181c1210000004189fa4181f20f00000069ff210000004129fa4509d14489c8c3", "4189d04189f14101f14181c8120000004509c129fe41ba210000004181e204000000410faff2440fafce4489c8c3", "4189d041b93e0000004129f941ba0a0000004181e233000000450fafca4189fb440fafdf4181f0110000004431c64131f34531d94489c8c3", "4189d041b93a0000004181e1040000004489c8c3", "4189d081e62200000041b91b0000004129f14489c8c3", "4189d04589c14181f13e0000004181c12b0000004529c14489c8c3", "4189d041b9160000004181f10700000031fe81c6220000004121f14489c8c3", "4189d04589c14101f94181e02d00000041ba0f0000004529c24431d64101f14489c8c3", "4189d081e63200000081f6010000004431c64589c1450fafc84181f1110000004421ce89f0c3", "4189d081cf330000004589c14569c91a0000004431cf81c61700000081f63f00000009f74101f84489c0c3", "4189d041b93b0000004181f1330000004181c114000000440fafce4181c1030000004131f94181c1370000004409cf41ba050000004129fa4489d0c3", "4189d041b90e0000004181c10d0000004489c8c3", "4189d041b9150000004569c9210000004521c14489c8c3", "4189d04189f94101f94181f1340000004101f14489c8c3", "4189d04181c03b0000004181c8240000004181c81c0000004181c03d0000004489c0c3", "4189d081ef1400000081f73e00000081cf3a00000081e7090000004429c789f8c3", "4189d081ef2200000081cf2800000031f781cf2500000081cf21000000c1e70589f8c3", "4189d04189f9440fafce4181c91b0000004521c14131f94181c10f0000004121f94181f1300000004489c8c3", "4189d04589c14181f1270000004181e90d0000004181e13f0000004101f94529c14181c9030000004181c1180000004531c14489c8c3", "4189d041b9370000004181c1140000004489c8c3", "4189d041b9020000004181f11d00000041ba350000004529ca4489d0c3", "4189d04189f94181e1010000004429cf29fe89f0c3", "4189d031fe69f60f00000081ce030000000faffe89f8c3", "4189d041b9170000004569c92a0000004181c9220000004181c10d0000004181c1170000004421ce89f0c3", "4189d081c71800000041b91a0000004129f94589c24501ca4409d669f61c0000004131f04489c0c3", "4189d04429c64189f94131f14189fa4501ca4181c22d0000004181e203000000450fafc24429c789f8c3", "4189d04589c14121f94181c92b0000004189f24531ca4181c21f0000004181c2220000004529d04421c681e61700000089f0c3", "4189d041b90e0000004181e1280000004489c8c3", "4189d081f61c00000081f62000000089f0c3", "4189d081f70d00000041b90b0000004569c90e000000410faff989f8c3", "4189d04189f14129f181f71e000000440fafc74531c14489c8c3", "4189d04589c1450fafc84189fa450fafd14189fb4529c34429df4109fa4489d0c3", "4189d04589c14181c10a0000004589c24531ca41bb260000004181eb210000004131f84521c3450fafd34489d0c3", "4189d04189f14131f181e6280000004121f14189fa4501c281f70a0000004109fa4521d14489c8c3", "4189d041b9050000004569c90a0000004589c24569d224000000450fafca4589c34531c381e62700000069f6110000004131f34521d94489c8c3", "4189d041b9030000004181c90c0000004489c8c3", "4189d029fe4129f04489c0c3", "4189d04189f94101f941ba2c0000004529ca4431d689f0c3", "4189d04181e01c0000004101f029fe4131f04489c0c3", "4189d041b9110000004181e11f0000004181c92a0000004429c64101f14501c14489c8c3", "4189d081e61a0000004401c681ee0500000009f781f73900000081e70300000089f8c3", "4189d04589c14181c13000000041ba280000004181e20d0000004509d14129f94181c1190000004529c14129f94489c8c3", "4189d04189f941c1e1004589c24529ca4131f24181c2130000004421c74121f84521c241bb010000004529d34489d8c3", "4189d041b9190000004569c93c0000004489c8c3", "4189d041b92a0000004181f13f000000440fafce4489c8c3", "4189d04189f94181c9160000004529c1440fafcf4489c8c3", "4189d081ef070000004431c781ef02000000410faff889f8c3", "4189d04189f14181e11d0000004121f14131f94131f14101f14489c8c3", "4189d041b92b0000004181e9140000004529c14181e901000000450fafc8440fafce450fafc84489c8c3", "4189d04189f94181c1110000004109f14131f94109f94101f14181f1220000004181e9380000004489c8c3", "4189d041b9330000004181c1380000004101f9450fafc84101f14181c1300000004181e10b0000004569c93c0000004131f94489c8c3", "4189d041b9170000004569c93c0000004489c8c3", "4189d081ef2e000000440fafc74489c0c3", "4189d04589c14569c9240000004589c2450fafd14531d04489c0c3", "4189d021fe81c61f00000081f60500000001f789f8c3", "4189d081c624000000440fafc64421c781f71200000041b92e0000004129f94489c8c3", "4189d041b9280000004181f11c0000004189f2450fafd14181c2080000004409d681f61e00000069f61d00000089f0c3", "4189d041b9180000004181c12f00000041ba280000004529ca4189fb4531d34181f3100000004431df29fe4121f04489c0c3", "4189d04189f94109f94181f11a0000004531c84189f24531c24181ca2a0000004181ca21000000410faff241bb040000004129f34489d8c3", "4189d041b9230000004181e9340000004489c8c3", "4189d069f63d0000000faffe89f8c3", "4189d04189f94181f11a00000081cf030000004121f94489c8c3", "4189d04131f881ce2b00000081e618000000440fafc64489c0c3", "4189d04129f04401c681c72200000081f73200000001fe89f0c3", "4189d041b9020000004181c93700000041ba2c0000004529ca4189f34181e30600000081ce180000004129f34509da4489d0c3", "4189d04189f94181f13c00000009f74121f94101f081f6100000004101f04529c14489c8c3", "4189d04589c14101f969ff290000004129f94181c82c00000081ee3c00000041ba120000004129f24521d04501c14489c8c3", "4189d041b90b0000004181e9110000004489c8c3", "4189d041b92e0000004181e9200000004181f1320000004489c8c3", "4189d041b9240000004181c11f0000004181f1370000004421ce89f0c3", "4189d04189f94121f14189fa4569d22a0000004409d74121f94489c8c3", "4189d041b9140000004181e1210000004189fa4181c2360000004121fa41bb1f0000004529d34509d94489c8c3", "4189d041b9250000004181e9130000004121f84501c14181c13a0000004181f10b0000004421ce89f0c3", "4189d0440fafc74181e83c0000004189f94521c14429cf81c73200000041ba120000004129f24421d789f8c3", "4189d041b92e0000004181e93e0000004181c90e00000041ba370000004181ea0c0000004189f34181cb050000004531da4501d1410faff04109f14489c8c3", "4189d041b9020000004569c9240000004489c8c3", "4189d04181c0070000004129f04489c0c3", "4189d081c62100000081f61300000081ee3200000089f0c3", "4189d069f61b00000069f63a00000081c6220000004421c689f0c3", "4189d04181f0130000004181c8260000004101f8440fafc64181e82c0000004489c0c3", "4189d001f74431c781e70b0000004421c781c72000000081f71c00000089f8c3", "4189d04189f94181e13b000000440fafce4121f94131f14181e9200000004181e138000000440fafcf4489c8c3", "4189d04189f94131f94181c1130000004181f1370000004109f14101f94181f1050000004181c1370000004101f14489c8c3", "4189d041b93c0000004181e1320000004489c8c3", "4189d081f61400000081f61d00000089f0c3", "4189d081f61500000081c63a0000004121f04489c0c3", "4189d04589c14181f10b0000004421ce0faffe4101f84489c0c3", "4189d069f62700000041b9230000004129f14189fa4501ca4189fb4509d34429df89f8c3", "4189d041b9120000004181f1150000004431cf81e73400000081c73100000029fe69f63c00000089f0c3", "4189d04189f14181c1030000004409cf31fe81e63900000081ce3000000041ba090000004129f24569d2250000004489d0c3", "4189d04189f14101f14181e10d0000004189f24521ca4189fb4509d34569db340000004181f3310000004401de0faffe89f8c3", "4189d041b9240000004569c93f0000004489c8c3", "4189d081c7360000004109f84489c0c3", "4189d04431c641b9080000004181e91b0000004401ce89f0c3", "4189d04409c64189f94181c921000000410faff90faff789f0c3", "4189d04189f94131f94181e10400000041ba130000004181c206000000410faffa4121f94489c8c3", "4189d041b91b0000004181e9220000004181e13e0000004421c741ba3c0000004129f24409d7440fafcf4489c8c3", "4189d001f741b90c0000004181e930000000410faff94121f041ba0c0000004181e23d0000004531d04401c789f8c3", "4189d04401c64589c14521c14409ce4589c24181f20d0000004181f0340000004569c01d0000004501c24401d689f0c3", "4189d041b9360000004181e1240000004489c8c3", "4189d041b90a0000004181f1270000004181c9250000004489c8c3", "4189d04589c14569c93b0000004589c24509c24509d14489c8c3", "4189d041b9390000004129f94181e1240000004181c11900000041ba050000004529ca4489d0c3", "4189d081ce1b0000004121f041b93d0000004181c93b000000450fafc14181c8010000004489c0c3", "4189d04189f94181e11f0000004569c93d0000004121f181e7150000004101f94429ce89f0c3", "4189d041b90a0000004181c1160000004181c1300000004181c90b00000041c1e1034181e9370000004429c74109f94489c8c3", "4189d081c7250000004181f0350000004181f00f0000004181e01c0000004569c00e0000004409c629f781f72d00000089f8c3", "4189d041b93c0000004181c9330000004489c8c3", "4189d04189f14121f9440fafce4489c8c3", "4189d04589c14109f94181c91b0000004509c14489c8c3", "4189d041b9050000004181e9090000004109f14181e9060000004181c12e0000004489c8c3", "4189d041b91c0000004181e1200000004181f11f0000004501c14181e93d000000440fafcf4489c8c3", "4189d04189f94101f14501c14521c14501c14131f94569c9220000004489c8c3", "4189d081ce2900000081e60500000081ee1d00000081c62e00000081ce0500000001fe81ee3400000089f0c3", "4189d04589c14569c9270000004181e9260000004181e10b0000004529c14181f13b0000004181f12a0000004181f1060000004181e9090000004489c8c3", "4189d041b9100000004181e1140000004489c8c3", "4189d04189f14569c93b0000004409ce89f0c3", "4189d04189f14129f94409ce29f789f8c3", "4189d04431c681f60d00000081c63500000081ce2300000089f0c3", "4189d04189f94569c93900000041ba140000004529ca4429d74189f34131fb4401de89f0c3", "4189d081ef1100000041b90e0000004129f94189f2450fafd14409d64589c34121f34521d84489c0c3", "4189d04189f14181e91b0000004181c1220000004589c24529ca4181e23c0000004501d04421c629f789f8c3", "415441554189d04189f14181c93f0000004189fa4531ca4189fb4529d34189fc4501dc4189f54531e5410faff529f781cf3f00000089f8415d415cc3", "4189d041b9280000004181c10f0000004489c8c3", "4189d081c738000000440fafc74489c0c3", "4189d04189f94121f981e6010000004131f14489c8c3", "4189d04569c02800000041b93d0000004181c1240000004181e1390000004521c84489c0c3", "4189d04189f14131f94189f24531ca69f61300000081e6280000004121f24489d0c3", "4189d04589c14181e1320000004189f24531ca4109f041bb2e0000004181f3270000004529d84531c24489d0c3", "4189d041b91b0000004181e93200000081f7270000004129f981c60e00000041ba0d0000004181f2140000004429d64121f14489c8c3", "4189d041b90b0000004181e91e0000004181c009000000450fafc84189f24181e20a00000081e63b00000081f609000000440fafd64521d14489c8c3", "4189d041b9020000004181f12d0000004489c8c3", "4189d081cf0c00000081ef3900000089f8c3", "4189d041b90e0000004181c13e0000004421ce81ce3700000089f0c3", "4189d04189f94181f13a00000041ba2e0000004181c2290000004109fa4521d14489c8c3", "4189d04189f14181c90100000041ba3b0000004129f24569d2360000004509d14401cf89f8c3", "4189d04589c14181c12f0000004129f14531c84181f00b00000081c61c000000440fafc64489c0c3", "4189d04589c14531c14509c821fe4101f04121f84181f0370000004181c0350000004489c0c3", "4189d04189f94529c141c1e1054101f14569c917000000410faff181e62800000069ff2400000021fe89f0c3", "4189d041b9310000004181c12d0000004489c8c3", "4189d04181e8040000004131f84489c0c3", "4189d04589c14121f94531c14521c14489c8c3", "4189d041b90d0000004181c1360000004531c14569c93b0000004181c9280000004489c8c3", "4189d081c73100000081cf0900000081c71000000081c71d00000001f789f8c3", "4189d04401c681e63400000009fe81f60d0000004431c669f62e00000089f0c3", "4189d04589c14501c14181f10d0000004529c14509c14181c9090000004181f1230000004569c9170000004489c8c3", "4189d04189f94109f14129f14129f14181c9300000004181c1130000004501c14531c14129f94489c8c3", "4189d041b9240000004181f12800000081e6110000004121f14489c8c3", "4189d041b93b0000004181e9210000004589c24521ca4521d04489c0c3", "4189d04189f94131f94181c11e0000004181c911000000440fafce4489c8c3", "4189d041b93d0000004181e9370000004489c8c3", "4189d04189f14129f14181c1180000004489c8c3", "4189d04189f94181c10b0000004121f981e62f0000004129f14489c8c3", "4189d04569c03f0000004569c01d0000004489c0c3", "4189d069f63300000081ce0100000089f0c3", "4189d081f62b00000041b9010000004129f14589c24509ca450fafc24181e0040000004181c8100000004181f0040000004489c0c3", "4189d041b9340000004181e10100000041ba1b0000004129f24501d14181e03e0000004569c0150000004501c14109f14489c8c3", "4189d04189f94181f12e0000004189fa450fafd14529c24189fb450fafda4181e3250000004101fb4489d8c3", "4189d04589c1450fafc841ba2e0000004529ca4181e22b0000004529d041bb1c0000004529c34421df81f73700000089f8c3", "4189d04589c1450fafc84409ce89f0c3", "4189d081f6370000004101f04489c0c3", "4189d041b93c0000004569c93200000069ff0c00000041ba3c0000004129fa4501d14489c8c3", "4189d04189f94569c9130000004181e92a0000004109f94531c14131f14101f14101f14489c8c3", "4189d041b9380000004181e9200000004181c1270000004409cf81e60500000021f781e72e00000089f8c3", "4189d04189f14129f14589c24531ca4181c81b00000041bb2d0000004181e3170000004501d84529c24489d0c3", "4189d041b9040000004181f1150000004509c1440fafcf4489c8c3", "4189d04589c14121f94181f0150000004181f0250000004501c14489c8c3", "4189d04189f14501c14131f14181f12c0000004501c14489c8c3", "4189d041b9260000004129f141c1e1034189f24129f24521d0450fafc84489c8c3", "4189d04181f03e00000041b9210000004529c14569c9230000004409cf89f8c3", "4189d04189f14121f14589c24509ca4189f34501d34181cb1b0000004521d84421c681f63400000089f0c3", "4189d081ce1e00000041b90b0000004181f1150000004421ce4589c24569d23c0000004121f84529c2410faff289f0c3", "4189d081cf050000004409c781cf3100000081c71b00000081f62d00000029f789f8c3", "4189d041b9210000004181c11d00000041ba280000004181ea280000004521d14489c8c3", "4189d04189f14181f10e0000004409ce41ba1f0000004181e237000000410faffa0faff789f0c3", "4189d041b9070000004569c90f0000004189fa4529ca4181f21a0000004131fa4181f2250000004569d235000000440fafd74489d0c3", "4189d041b9290000004569c9190000004489c8c3", "4189d081ee3a00000089f0c3", "4189d04189f14181e11600000081ee080000004121f14489c8c3", "4189d041b9250000004181e10b000000440fafcf4489c8c3", "4189d04189f94181c93e0000004181e9110000004181f1150000004521c14531c14131f94181f13e0000004489c8c3", "4189d041b9330000004181c9230000004181c9280000004509c14489c8c3", "4189d041b9090000004181c91e0000004521c14189f24181f2070000004121fa4509d04409c64129f14489c8c3", "4189d04589c14521c141ba0b0000004529ca4489d0c3", "4189d041b90b0000004529c14421cf4101f84569c0380000004181c81d0000004181c8200000004489c0c3", "4189d041b9180000004181e90b0000004181f11d0000004421ce89f0c3", "4189d041b9270000004181f1120000004489c8c3", "4189d041b9360000004181f1380000004489c8c3", "4189d041b92a0000004181e939000000450fafc84569c9160000004489c8c3", "4189d04189f94181c91c0000004401cf81e73a0000004129f84181c0110000004181c01f0000004489c0c3", "4189d081e6390000004421c74121f84431c689f0c3", "4189d04429c769ff2800000081e71b00000081c7300000004109f84489c0c3", "4189d041b93a0000004569c93b0000004569c90d0000004181c10b000000440fafce4489c8c3", "4189d081f62600000089f0c3", "4189d081e71500000089f8c3", "4189d04189f94121f94589c24509ca4531d04489c0c3", "4189d081c63800000001f789f8c3", "4189d04189f94181c10a0000004531c84401c789f8c3", "4189d041b91f0000004181f11e0000004489c8c3", "4189d04189f94181c1380000004189fa4181ca350000004431d74131f94401ce89f0c3", "4189d04589c14569c9290000004501c14489c8c3", "4189d081f63600000089f0c3", "4189d041b9280000004181e1120000004181c9010000004529c14489c8c3", "4189d04589c14181c13a0000004421c7440fafcf4181c1190000004489c8c3", "4189d081f70e00000081cf3300000089f8c3", "4189d04569c018000000440fafc64489c0c3", "4189d04189f94181c12d00000001fe4129f14489c8c3", "4189d04569c00700000041b9270000004181e123000000450fafc14489c0c3", "4189d041c1e0014181c8370000004489c0c3", "4189d04131f04129f04421c609f789f8c3", "4189d04431c681e60f00000081e61100000081f60600000081e6160000000faff789f0c3", "4189d04189f94509c14429c74101f94489c8c3", "4189d04189f9450fafc84189fa4569d2090000004529d10faff781e7380000000faff74109f14489c8c3", "41544189d041b9380000004181e11500000041ba2b0000004181f2070000004531d141bb190000004181cb0600000041bc290000004129f44521e34509d94489c8415cc3", "4189d04409c769ff1400000021f781ef0c0000004421c769ff1500000089f8c3", "4189d04189f14569c9050000004529c14129f14181c1250000004101f94489c8c3", "4189d04181e03e0000004181c8110000004401c689f0c3", "4189d041b9020000004181c1320000004489c8c3", "4189d081ce2500000009fe4429c64431c669f61800000089f0c3", "4189d04589c14181e11c0000004531c84431c769ff1800000069ff2f00000069ff3d00000069ff2f00000089f8c3", "4189d04181c82a0000004131f84569c0180000004489c0c3", "4189d04189f94181c1190000004431cf01fe81ce0400000089f0c3", "4189d081c60200000069f62500000081c62b00000089f0c3", "4189d04189f94569c9210000004181e1210000004129f94101f94181f13d0000004181e1110000004489c8c3", "4189d041b92e0000004181e12300000041ba1a0000004181e23f000000450fafca4489c8c3", "4189d04189f94569c92c00000021f74129f941ba220000004181e21c00000081f60b0000004131f24531d14489c8c3", "4189d04189f94181c1060000004429cf89f8c3", "4189d041b9390000004181e9160000004409cf89f8c3", "4189d041b92e0000004181c11400000041ba190000004181e220000000450fafca4489c8c3", "4189d081e72900000081e73b00000089f8c3", "4189d04181c0320000004489c0c3", "4189d04189f94181e93a00000041ba320000004529ca81c61c00000009f7440fafd74489d0c3", "4189d041b91a0000004181c90c0000004489c8c3", "4189d04421c64181e00c0000004431c681c62c00000069f61f00000081f60200000089f0c3", "4189d041b9130000004181e1390000004131f94569c9180000004129f14489c8c3", "4189d04431c721f70faffe410faff881e70c00000089f8c3", "4189d00faffe4181c0260000004431c741b91f0000004181c90500000081c61c0000004101f1410faff989f8c3", "4189d081ee0e00000081ce1b00000089f0c3", "4189d041b9010000004181e1060000004489c8c3", "4189d041b9260000004181e9070000004489c8c3", "4189d041b9180000004181f1020000004489c8c3", "4189d04181e80d0000004181e0240000004489c0c3", "4189d081c72900000089f8c3", "4189d041b93e0000004569c93b0000004589c2450fafd04181c2010000004521d14489c8c3", "4189d0c1e60581ce0900000081ce2b0000004421c681e61200000089f0c3", "4189d041b9110000004181c9120000004181f1300000004181e9160000004489c8c3", "4189d041b9280000004181f1030000004489c8c3", "4189d041b91f0000004569c93e0000004181e90b0000004131f14489c8c3", "4189d041b9160000004181f1330000004189f24531ca41bb080000004129fb4181c3260000004421de69f60c000000440fafd64489d0c3", "4189d04569c0380000004189f94509c1410faff989f8c3", "4189d069ff1400000029f789f8c3", "4189d04189f94181c91f000000450fafc141ba230000004181f22e0000004189fb4121fb4529da4521d04489c0c3", "4189d041b9110000004181c11f0000004489c8c3", "4189d04189f14181c9260000004181c0010000004529c181c7060000004189f24129f24421d74131f94489c8c3", "4189d04589c14529c14531c14489c8c3", "41544189d04189f94569c9310000004189fa450fafd14589c34529d341bc070000004529dc09fe440fafe64529c44489e0415cc3", "4189d041b9200000004181e9090000004131f14181c1290000004181e9140000004131f14501c1440fafce4489c8c3", "4189d04589c1450fafc84131f8410faff84129f94489c8c3", "4189d04181c0250000004431c641b9160000004129f14489c8c3", "4189d041b9350000004181e90f0000004489c8c3", "4189d04569c02a00000041b9230000004129f94189fa4181ea3a0000004501d14521c84101f04421c789f8c3", "4189d069ff2d00000081f71700000081ef2600000081ef2200000089f8c3", "4189d029fe4401c689f0c3", "4189d041b91e0000004181e10d0000004589c24521ca4531d04421c681ce2b00000089f0c3", "4189d041b92c0000004569c9120000004569c9340000004181f1380000004109f14181e12d0000004489c8c3", "4189d04189f94181f11b0000004129f94409ce0faff789f0c3", "4189d04189f94569c9070000004421ce4189fa4569d2380000004421d70faff789f0c3", "4189d04189f14181c91a000000440fafce4489c8c3", "4189d04189f94129f1440fafce4129f94569c9050000004521c14489c8c3", "4189d04589c14181c9380000004529c84489c0c3", "4189d041b9290000004129f14429cf4189f24109f241bb120000004569db3e0000004509da4429d789f8c3", "4189d04181e0260000004429c789f8c3", "4189d04589c14531c14181f1270000004489c8c3", "4189d041b93f0000004181f10a0000004489c8c3", "4189d04189f94521c14531c8410faff021f781f70600000089f8c3", "4189d04409c681f63300000009fe89f0c3", "4189d04189f14569c92900000081e62f0000004101f14589c24501c241bb380000004181e3220000004521da4531d14489c8c3", "4189d041b9360000004569c91300000081e71e000000440fafcf4489c8c3", "4189d041b9290000004181c1270000004489c8c3", "4189d04189f94569c93e0000004109f9440fafcf4569c90c0000004181c9070000004129f94101f14489c8c3", "4189d041b92b0000004181f1230000004131f14189f24181e20f0000004429d64101f14501c84489c0c3", "4189d001fe4121f84181c0060000004429c689f0c3", "4189d081ce1600000081ce0b0000004121f04489c0c3", "4189d04189f94529c14131f14129f94181e1160000004181c9150000004181e9130000004131f14489c8c3", "4189d04589c14531c14101f10faff74109f14569c01e0000004521c14489c8c3", "4189d081f73100000081f71500000089f8c3", "4189d081ce2f00000029f789f8c3", "4189d081f6090000004189f94569c93b0000004409ce4189fa440fafd64589c34531c34409df4109fa4489d0c3", "4189d04189f94181e11d0000004181e9210000004181c134000000450fafc881e7150000004131f94489c8c3", "4189d081e63400000081c62e00000041b90b0000004129f14181f1350000004189fa4531ca4189fb4501d3410faffb89f8c3", "4189d041b9330000004181c1380000004409ce440fafc64181c03e0000004181c8320000004489c0c3", "4189d04189f14181e9340000004181e1330000004569c9310000004401ce89f0c3", "4189d041b9310000004129f14431ce89f0c3", "4189d04409c769ff1400000089f8c3", "4189d04421c681c6330000004181f00c0000004181f0330000004421c689f0c3", "4189d041b9160000004181e1140000004489c8c3", "4189d041b9100000004181c93f0000004181e11c000000440fafce4569c93d0000004521c14131f1440fafce4489c8c3", "4189d04569c0050000004181c0170000004181f02000000069f63100000081c62600000081c60f0000004101f04489c0c3", "4189d041b9230000004181e9100000004489c8c3", "4189d041b9380000004181e9370000004181f1020000004121f94181f01c00000041c1e0044181c8330000004501c14489c8c3", "4189d041b9020000004181f12b000000440fafce4489c8c3", "4189d041b90a0000004569c9300000004489c8c3", "4189d04189f94181f10d0000004531c14109f94131f14489c8c3", "4189d081cf1d00000029fe81c60d0000004429c689f0c3", "4189d041b9180000004181f1260000004489c8c3", "4189d04189f1450fafc84129f94181f10e0000004529c14569c9300000004181f1200000004129f14489c8c3", "4189d04189f14181c90d0000004189fa4501c24531d181c72e00000081ce1400000021f74129f94489c8c3", "4189d04189f94181c91100000081ef05000000440fafcf4489c8c3", "4189d069f63d00000069f62c00000009fe4429c629fe81c63c00000089f0c3", "4189d04181c0260000004401c741b9310000004569c90e0000004181e1330000004429cf89f8c3", "4189d041b9180000004181f1090000004569c91f0000004489c8c3", "4189d04189f14181c9250000004431c6440fafce4489c8c3", "4189d041b9040000004181e90d0000004181e1380000004131f14181e1090000004181f1200000004181c11c0000004181c12b0000004489c8c3", "4189d041b9300000004181c11d0000004589c24501ca4589c34569db060000004529d84521c24489d0c3", "4189d041b9320000004181f1250000004501c84489c0c3", "4189d041b9200000004181e13c00000041ba0e0000004181ca1d0000004401d74129f94489c8c3", "4189d041b9010000004181f1200000004131f14129f94401ce410faff081ce2600000089f0c3", "4189d081ef0e00000081cf2400000069ff0900000089f8c3", "4189d081c71b00000041b9280000004181e1190000004409ce31f789f8c3", "4189d04189f14521c14189fa4121fa4181f2080000004509d04431c6440fafce4181c1050000004489c8c3", "4189d081f629000000410faff089f0c3", "4189d04189f94181f10f00000041ba1d0000004129fa4429d64129f04521c14489c8c3", "4189d041b93a0000004181e1110000004181e91a0000004181c9050000004121f14489c8c3", "4189d04589c14181c91e0000004529c14181f1320000004501c14101f14121f14569c9380000004489c8c3", "4189d041b9040000004181c11c0000004509c14489c8c3", "4189d04589c14181f11c0000004589c2450fafd04131f2450fafca4429cf4421c74121f84489c0c3", "4189d081ce2d00000089f0c3", "4189d081e63a00000081ce0c00000089f0c3", "4189d04189f14101f14181e83a0000004529c14181f11e0000004489c8c3", "4189d04181c0190000004189f94521c14181e11d0000004121f94489c8c3", "4189d04589c14181e91b0000004181e13e0000004181e12b0000004181f1100000004531c84421c689f0c3", "4189d04189f14569c90c0000004181c13b0000004121f94109f14181c93c0000004489c8c3", "4189d041b91d0000004181f10800000069f60900000081c61b000000440fafce4489c8c3", "4189d041b9090000004181f1020000004489c8c3", "4189d029f701fe4181c0060000004181e00b000000410faff089f0c3", "4189d041b9020000004181f12e0000004121f14489c8c3", "4189d04589c14501c14429c64109f14489c8c3", "4189d081f72200000001fe4589c14129f141ba3d0000004529ca4501d04489c0c3", "41544189d04189f94181c1090000004401cf4189f24101fa4589c3450fafda4589c44501dc450fafc44429c689f0415cc3", "4189d04189f94181e1110000004121f94181f13a0000004121f1440fafce4109f14489c8c3", "4189d04181e0190000004569c0260000004181f02b0000004569c02c0000004489c0c3", "4189d041b9240000004181f10100000069ff1d00000031fe4109f14489c8c3", "4189d041b91e0000004181c9110000004129f141ba370000004529ca4489d0c3", "4189d04189f94181f10e0000004189f2450fafd141bb2e0000004569db1300000029f74109fb4501da4489d0c3", "4189d041b9320000004181e1300000004489c8c3", "4189d081cf0f00000081f70700000081cf0600000031f789f8c3", "4189d081c72600000041b9320000004181c1230000004409cf41ba070000004181e20200000081ee1d0000004121f24429d789f8c3"]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275{
"release": "0.2.0-experimental",
"original_initialization_seconds": 4.416371800005436,
"package_initialization_seconds": 1.2131852000020444,
"device": "NVIDIA GeForce RTX 2060 SUPER",
"torch": "2.13.0+cu132",
"splits": {
"validation": {
"programs": 2000,
"equality": {
"bytes": true,
"byte_tensors": true,
"ast": true,
"ssa": true,
"virtual_mir": true,
"physical_mir": true,
"overflow": true,
"emission_counts": true,
"instruction_lengths": true
},
"semantic_results_equal": true,
"single_vs_batch_equal_32_programs": true,
"original_single_vs_batch_equal": true,
"functions": 2000,
"serializable": 1.0,
"fully_disassembled": 1.0,
"semantic_accuracy": 0.987,
"semantic_correct": 1974,
"by_operations": {
"3": {
"n": 286,
"semantic_correct": 285,
"semantic_accuracy": 0.9965034965034965
},
"4": {
"n": 286,
"semantic_correct": 285,
"semantic_accuracy": 0.9965034965034965
},
"1": {
"n": 286,
"semantic_correct": 286,
"semantic_accuracy": 1.0
},
"2": {
"n": 286,
"semantic_correct": 286,
"semantic_accuracy": 1.0
},
"7": {
"n": 285,
"semantic_correct": 266,
"semantic_accuracy": 0.9333333333333333
},
"6": {
"n": 285,
"semantic_correct": 282,
"semantic_accuracy": 0.9894736842105263
},
"5": {
"n": 286,
"semantic_correct": 284,
"semantic_accuracy": 0.993006993006993
}
},
"by_depth": {
"2": {
"n": 370,
"semantic_correct": 370,
"semantic_accuracy": 1.0
},
"3": {
"n": 520,
"semantic_correct": 517,
"semantic_accuracy": 0.9942307692307693
},
"4": {
"n": 256,
"semantic_correct": 254,
"semantic_accuracy": 0.9921875
},
"1": {
"n": 286,
"semantic_correct": 286,
"semantic_accuracy": 1.0
},
"7": {
"n": 153,
"semantic_correct": 145,
"semantic_accuracy": 0.9477124183006536
},
"6": {
"n": 191,
"semantic_correct": 186,
"semantic_accuracy": 0.9738219895287958
},
"5": {
"n": 224,
"semantic_correct": 216,
"semantic_accuracy": 0.9642857142857143
}
},
"by_origin": {
"balanced_shape": {
"n": 497,
"semantic_correct": 495,
"semantic_accuracy": 0.9959758551307847
},
"right_chain": {
"n": 497,
"semantic_correct": 491,
"semantic_accuracy": 0.9879275653923542
},
"left_chain": {
"n": 502,
"semantic_correct": 501,
"semantic_accuracy": 0.99800796812749
},
"random": {
"n": 504,
"semantic_correct": 487,
"semantic_accuracy": 0.9662698412698413
}
},
"by_balanced": {
"True": {
"n": 441,
"semantic_correct": 440,
"semantic_accuracy": 0.9977324263038548
},
"False": {
"n": 1559,
"semantic_correct": 1534,
"semantic_accuracy": 0.9839640795381654
}
},
"inputs_per_function": 32,
"sample_seed": 20261127,
"exact_reference_bytes": 0.982
},
"test": {
"programs": 2000,
"equality": {
"bytes": true,
"byte_tensors": true,
"ast": true,
"ssa": true,
"virtual_mir": true,
"physical_mir": true,
"overflow": true,
"emission_counts": true,
"instruction_lengths": true
},
"semantic_results_equal": true,
"single_vs_batch_equal_32_programs": true,
"original_single_vs_batch_equal": true,
"functions": 2000,
"serializable": 1.0,
"fully_disassembled": 1.0,
"semantic_accuracy": 0.9815,
"semantic_correct": 1963,
"by_operations": {
"7": {
"n": 285,
"semantic_correct": 265,
"semantic_accuracy": 0.9298245614035088
},
"2": {
"n": 286,
"semantic_correct": 286,
"semantic_accuracy": 1.0
},
"6": {
"n": 285,
"semantic_correct": 273,
"semantic_accuracy": 0.9578947368421052
},
"1": {
"n": 286,
"semantic_correct": 286,
"semantic_accuracy": 1.0
},
"4": {
"n": 286,
"semantic_correct": 286,
"semantic_accuracy": 1.0
},
"3": {
"n": 286,
"semantic_correct": 284,
"semantic_accuracy": 0.993006993006993
},
"5": {
"n": 286,
"semantic_correct": 283,
"semantic_accuracy": 0.9895104895104895
}
},
"by_depth": {
"7": {
"n": 153,
"semantic_correct": 146,
"semantic_accuracy": 0.954248366013072
},
"2": {
"n": 370,
"semantic_correct": 370,
"semantic_accuracy": 1.0
},
"6": {
"n": 182,
"semantic_correct": 175,
"semantic_accuracy": 0.9615384615384616
},
"1": {
"n": 286,
"semantic_correct": 286,
"semantic_accuracy": 1.0
},
"4": {
"n": 256,
"semantic_correct": 253,
"semantic_accuracy": 0.98828125
},
"3": {
"n": 530,
"semantic_correct": 520,
"semantic_accuracy": 0.9811320754716981
},
"5": {
"n": 223,
"semantic_correct": 213,
"semantic_accuracy": 0.9551569506726457
}
},
"by_origin": {
"left_chain": {
"n": 502,
"semantic_correct": 501,
"semantic_accuracy": 0.99800796812749
},
"balanced_shape": {
"n": 497,
"semantic_correct": 489,
"semantic_accuracy": 0.9839034205231388
},
"right_chain": {
"n": 497,
"semantic_correct": 485,
"semantic_accuracy": 0.9758551307847082
},
"random": {
"n": 504,
"semantic_correct": 488,
"semantic_accuracy": 0.9682539682539683
}
},
"by_balanced": {
"False": {
"n": 1559,
"semantic_correct": 1526,
"semantic_accuracy": 0.9788325849903784
},
"True": {
"n": 441,
"semantic_correct": 437,
"semantic_accuracy": 0.9909297052154195
}
},
"inputs_per_function": 32,
"sample_seed": 20261127
}
},
"passed": true
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132{
"programs": 2000,
"equality": {
"bytes": true,
"byte_tensors": true,
"ast": true,
"ssa": true,
"virtual_mir": true,
"physical_mir": true,
"overflow": true,
"emission_counts": true,
"instruction_lengths": true
},
"semantic_results_equal": true,
"single_vs_batch_equal_32_programs": true,
"original_single_vs_batch_equal": true,
"functions": 2000,
"serializable": 1.0,
"fully_disassembled": 1.0,
"semantic_accuracy": 0.9815,
"semantic_correct": 1963,
"by_operations": {
"7": {
"n": 285,
"semantic_correct": 265,
"semantic_accuracy": 0.9298245614035088
},
"2": {
"n": 286,
"semantic_correct": 286,
"semantic_accuracy": 1.0
},
"6": {
"n": 285,
"semantic_correct": 273,
"semantic_accuracy": 0.9578947368421052
},
"1": {
"n": 286,
"semantic_correct": 286,
"semantic_accuracy": 1.0
},
"4": {
"n": 286,
"semantic_correct": 286,
"semantic_accuracy": 1.0
},
"3": {
"n": 286,
"semantic_correct": 284,
"semantic_accuracy": 0.993006993006993
},
"5": {
"n": 286,
"semantic_correct": 283,
"semantic_accuracy": 0.9895104895104895
}
},
"by_depth": {
"7": {
"n": 153,
"semantic_correct": 146,
"semantic_accuracy": 0.954248366013072
},
"2": {
"n": 370,
"semantic_correct": 370,
"semantic_accuracy": 1.0
},
"6": {
"n": 182,
"semantic_correct": 175,
"semantic_accuracy": 0.9615384615384616
},
"1": {
"n": 286,
"semantic_correct": 286,
"semantic_accuracy": 1.0
},
"4": {
"n": 256,
"semantic_correct": 253,
"semantic_accuracy": 0.98828125
},
"3": {
"n": 530,
"semantic_correct": 520,
"semantic_accuracy": 0.9811320754716981
},
"5": {
"n": 223,
"semantic_correct": 213,
"semantic_accuracy": 0.9551569506726457
}
},
"by_origin": {
"left_chain": {
"n": 502,
"semantic_correct": 501,
"semantic_accuracy": 0.99800796812749
},
"balanced_shape": {
"n": 497,
"semantic_correct": 489,
"semantic_accuracy": 0.9839034205231388
},
"right_chain": {
"n": 497,
"semantic_correct": 485,
"semantic_accuracy": 0.9758551307847082
},
"random": {
"n": 504,
"semantic_correct": 488,
"semantic_accuracy": 0.9682539682539683
}
},
"by_balanced": {
"False": {
"n": 1559,
"semantic_correct": 1526,
"semantic_accuracy": 0.9788325849903784
},
"True": {
"n": 441,
"semantic_correct": 437,
"semantic_accuracy": 0.9909297052154195
}
},
"inputs_per_function": 32,
"sample_seed": 20261127
}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133{
"programs": 2000,
"equality": {
"bytes": true,
"byte_tensors": true,
"ast": true,
"ssa": true,
"virtual_mir": true,
"physical_mir": true,
"overflow": true,
"emission_counts": true,
"instruction_lengths": true
},
"semantic_results_equal": true,
"single_vs_batch_equal_32_programs": true,
"original_single_vs_batch_equal": true,
"functions": 2000,
"serializable": 1.0,
"fully_disassembled": 1.0,
"semantic_accuracy": 0.987,
"semantic_correct": 1974,
"by_operations": {
"3": {
"n": 286,
"semantic_correct": 285,
"semantic_accuracy": 0.9965034965034965
},
"4": {
"n": 286,
"semantic_correct": 285,
"semantic_accuracy": 0.9965034965034965
},
"1": {
"n": 286,
"semantic_correct": 286,
"semantic_accuracy": 1.0
},
"2": {
"n": 286,
"semantic_correct": 286,
"semantic_accuracy": 1.0
},
"7": {
"n": 285,
"semantic_correct": 266,
"semantic_accuracy": 0.9333333333333333
},
"6": {
"n": 285,
"semantic_correct": 282,
"semantic_accuracy": 0.9894736842105263
},
"5": {
"n": 286,
"semantic_correct": 284,
"semantic_accuracy": 0.993006993006993
}
},
"by_depth": {
"2": {
"n": 370,
"semantic_correct": 370,
"semantic_accuracy": 1.0
},
"3": {
"n": 520,
"semantic_correct": 517,
"semantic_accuracy": 0.9942307692307693
},
"4": {
"n": 256,
"semantic_correct": 254,
"semantic_accuracy": 0.9921875
},
"1": {
"n": 286,
"semantic_correct": 286,
"semantic_accuracy": 1.0
},
"7": {
"n": 153,
"semantic_correct": 145,
"semantic_accuracy": 0.9477124183006536
},
"6": {
"n": 191,
"semantic_correct": 186,
"semantic_accuracy": 0.9738219895287958
},
"5": {
"n": 224,
"semantic_correct": 216,
"semantic_accuracy": 0.9642857142857143
}
},
"by_origin": {
"balanced_shape": {
"n": 497,
"semantic_correct": 495,
"semantic_accuracy": 0.9959758551307847
},
"right_chain": {
"n": 497,
"semantic_correct": 491,
"semantic_accuracy": 0.9879275653923542
},
"left_chain": {
"n": 502,
"semantic_correct": 501,
"semantic_accuracy": 0.99800796812749
},
"random": {
"n": 504,
"semantic_correct": 487,
"semantic_accuracy": 0.9662698412698413
}
},
"by_balanced": {
"True": {
"n": 441,
"semantic_correct": 440,
"semantic_accuracy": 0.9977324263038548
},
"False": {
"n": 1559,
"semantic_correct": 1534,
"semantic_accuracy": 0.9839640795381654
}
},
"inputs_per_function": 32,
"sample_seed": 20261127,
"exact_reference_bytes": 0.982
}1234567891011from neuro_compiler import NeuralCompiler
def main(): compiler=NeuralCompiler.from_pretrained('chrisuser/neuro-compiler',revision='0.2.0-experimental') source='unsigned f(unsigned a,unsigned b,unsigned c){return ((a+b)*(c-7u));}' print(compiler.compile(source).hex()) print([x.hex() for x in compiler.compile_batch([source,source])]) result=compiler.compile(source,return_intermediates=True) print(result.ast,result.ssa,result.virtual_mir,result.physical_mir,result.diagnostics)
if __name__=='__main__': main()1unsigned f(unsigned a,unsigned b,unsigned c){return ((((((25u+34u)&(34u-c))+20u)|30u)^38u)*(7u+a));}1234"""Experimental neural compiler. Generated machine code may be incorrect or unsafe."""from .compiler import NeuralCompiler, CompilationResult__version__='0.2.0.dev0'__all__=['NeuralCompiler','CompilationResult']1234"""Research compiler: frozen neural frontend plus an explicitly hybrid backend."""from .compiler import NeuralCompiler,CompilationResult__version__='0.3.0'__all__=['NeuralCompiler','CompilationResult']
1234567891011121314"""Isolated entry point: imports no candidate model or Torch runtime."""import importlib.util,json,random,sysfrom pathlib import Path
def load(name,file): spec=importlib.util.spec_from_file_location(name,Path(__file__).with_name(file));module=importlib.util.module_from_spec(spec);spec.loader.exec_module(module);return moduledef main(): request=json.loads(sys.stdin.read());g=load('_reference_schema','neurocc_graph_schema.py');e=load('_bounded_emulation','emulation.py') fixed=[(0,0,0),(1,2,3),(0xffffffff,)*3,(0x80000000,0x7fffffff,1),(0,1,0xffffffff),(0xffffffff,0,1),(0x80000000,)*3,(1,1,1)] rng=random.Random(request['seed']);xs=fixed[:request['samples']]+[tuple(rng.getrandbits(32) for _ in range(3)) for _ in range(max(0,request['samples']-8))] tree=g.parse(request['source']);expected=[g.evaluate(tree,args) for args in xs] abi,semantic,error,instructions=e.emulate(bytes.fromhex(request['code_hex']),expected,xs) print(json.dumps({'serialized':True,'abi':abi,'semantic':semantic,'error':error,'samples':len(xs),'sampled_instructions':instructions,'native_execution':False,'formal_equivalence':False}))if __name__=='__main__':main()1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374"""Pinned frozen six-block backbone; stream an exact tensor prefix into cache."""import hashlib,json,struct,uuidfrom pathlib import Pathimport torchfrom torch import nn
def sha(path): with Path(path).open('rb') as f:return hashlib.file_digest(f,'sha256').hexdigest()
def _extract(source,target,depth): with Path(source).open('rb') as f: size=struct.unpack('<Q',f.read(8))[0] if not 2<=size<=16*1024*1024:raise ValueError('Invalid backbone tensor header') header=json.loads(f.read(size));start=8+size;items=[] for name,value in header.items(): if name=='__metadata__':continue import re layer=re.search(r'(?:^|\.)layers\.(\d+)\.',name) if layer and int(layer[1])>=depth:continue a,b=value['data_offsets'] if not 0<=a<=b<=Path(source).stat().st_size-start:raise ValueError('Invalid tensor offsets') items.append((a,b,name,value)) items.sort();new={'__metadata__':header.get('__metadata__',{'format':'pt'})};offset=0 for a,b,name,value in items:new[name]={**value,'data_offsets':[offset,offset+b-a]};offset+=b-a raw=json.dumps(new,separators=(',',':')).encode();raw+=b' '*((-len(raw))%8) temp=Path(target).with_name(Path(target).name+'.'+uuid.uuid4().hex+'.tmp') try: with temp.open('wb') as out: out.write(struct.pack('<Q',len(raw)));out.write(raw) for a,b,name,value in items: f.seek(start+a);remaining=b-a while remaining: data=f.read(min(1048576,remaining)) if not data:raise ValueError('Truncated backbone tensors') out.write(data);remaining-=len(data) temp.replace(target) finally:temp.unlink(missing_ok=True)
def prefix_cache(spec,expected_sha,expected_config_sha): from huggingface_hub import hf_hub_download from huggingface_hub.constants import HF_HUB_CACHE config_path=Path(hf_hub_download(spec['backbone'],'config.json',revision=spec['revision'])) if sha(config_path)!=expected_config_sha:raise ValueError('Pinned Qwen config hash mismatch') config=json.loads(config_path.read_text());source=Path(hf_hub_download(spec['backbone'],'model.safetensors',revision=spec['revision'])) if sha(source)!=expected_sha:raise ValueError('Pinned Qwen weight hash mismatch') depth=max(spec['depths']);full=config['num_hidden_layers'] if not 0<depth<=full:raise ValueError('Invalid frozen depth') identity={'source_sha256':expected_sha,'config_sha256':sha(config_path),'revision':spec['revision'],'depth':depth,'format':1} key=hashlib.sha256(json.dumps(identity,sort_keys=True).encode()).hexdigest();root=Path(HF_HUB_CACHE).parent/'neuro-compiler-prefix'/key;root.mkdir(parents=True,exist_ok=True) meta=root/'provenance.json';weight=root/'model.safetensors';cp=root/'config.json' if meta.exists(): saved=json.loads(meta.read_text()) if saved['identity']!=identity or sha(weight)!=saved['weight_sha256'] or sha(cp)!=saved['config_sha256']:raise ValueError('Frozen backbone prefix cache integrity failed') else: _extract(source,weight,depth);config={**config,'num_hidden_layers':depth} if isinstance(config.get('layer_types'),list):config['layer_types']=config['layer_types'][:depth] cp.write_text(json.dumps(config,indent=2));temp=meta.with_name(meta.name+'.'+uuid.uuid4().hex+'.tmp') temp.write_text(json.dumps({'identity':identity,'weight_sha256':sha(weight),'config_sha256':sha(cp)},indent=2));temp.replace(meta) return root,full
class Backbone(nn.Module): def __init__(self,spec,dev,expected_sha,expected_config_sha): super().__init__() from transformers import AutoModel root,self.full_depth=prefix_cache(spec,expected_sha,expected_config_sha);self.depths=sorted(spec['depths']) # Same original tensor values and compute dtype; no unused block mapping. self.net=AutoModel.from_pretrained(str(root),local_files_only=True,trust_remote_code=False,torch_dtype=torch.float16 if dev.type=='cuda' else torch.float32,low_cpu_mem_usage=True) self.hidden=self.net.config.hidden_size if max(self.depths)<self.full_depth:self.net.norm=nn.Identity() self.net.requires_grad_(False);self.net.to(dev).eval() def forward(self,ids,mask): if len(self.depths)==1:return (self.net(input_ids=ids,attention_mask=mask,use_cache=False,return_dict=True).last_hidden_state,) states=self.net(input_ids=ids,attention_mask=mask,use_cache=False,output_hidden_states=True,return_dict=True).hidden_states return tuple(states[k] for k in self.depths)1"""Frozen hybrid allocation/lowering/encoding; no reference compiler dependency."""12REGS=(7,6,8,9,10,11,3,5,12,13,14,15,0,1,2)
CALLEE={3,5,12,13,14,15}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120import torch
from torch import nn
from .graph import OPS,GraphPreparation,SHIFT_IDS
from .policy import TensorPolicy
EVENT_OPS = ('<PAD>', 'store', 'load', 'mov', 'release', 'count', 'ret') + OPS[1:] + tuple((o + '_imm' for o in OPS[2:])) + tuple((OPS[i] + '_cl' for i in SHIFT_IDS))
EID = {o: i for i, o in enumerate(EVENT_OPS)}
LANES = 17
class TensorAllocator(nn.Module):
def __init__(self):
super().__init__()
self.policy = TensorPolicy()
self.register_buffer('regular', torch.tensor([0] + [EID[o] for o in OPS[1:]]))
self.register_buffer('immediate_ops', torch.tensor([0, 0] + [EID[o + '_imm'] for o in OPS[2:]]))
self.register_buffer('shift_ops', torch.tensor([EID[o + '_cl'] if i in SHIFT_IDS else 0 for i, o in enumerate(OPS)]))
self.eval().requires_grad_(False)
def forward(self, x):
B, V = x['op'].shape
dev = x['op'].device
last = GraphPreparation.exact(x)
now, future = GraphPreparation.reservations(x)
state = torch.full((B, 15), -1, device=dev, dtype=torch.long)
state[:, :3] = torch.arange(3, device=dev)
dirty = state >= 0
used = torch.zeros_like(dirty)
backed = torch.zeros((B, V), device=dev, dtype=torch.bool)
errors = torch.zeros(B, device=dev, dtype=torch.bool)
events = torch.zeros((B, V + 1, LANES, 3), device=dev, dtype=torch.long)
reg = self.policy.regs[None, :]
zero = torch.zeros(B, device=dev, dtype=torch.long)
minus = zero - 1
empty_mask = torch.zeros_like(dirty)
def get(a, j):
return a.gather(1, j.clamp_min(0)[:, None]).squeeze(1)
def put(a, j, value, mask):
j = j.clamp_min(0)[:, None]
old = a.gather(1, j).squeeze(1)
a.scatter_(1, j, torch.where(mask, value, old)[:, None])
for t in range(3, V + 1):
active = x['n'] > t
ending = x['n'] == t
tv = zero + t
it = min(t, V - 1)
op = x['op'][:, it]
refs = x['refs'][:, it]
imm = x['immediate'][:, it]
isimm = x['isimm'][:, it]
const = active & (op == OPS.index('const'))
arithmetic = active & ~const
varshift = arithmetic & now[:, t, 1]
hasright = arithmetic & (refs[:, 1] >= 0)
reserved = torch.cat((empty_mask[:, :12], now[:, t]), 1)
nxt = torch.cat((torch.full_like(state[:, :12], -1), future[:, t]), 1)
def emit(lane, kind, j, v, mask):
if isinstance(kind, str):
kind = zero + EID[kind]
events[:, t, lane, 0] = torch.where(mask, kind, 0)
events[:, t, lane, 1] = torch.where(mask, j, 0)
events[:, t, lane, 2] = torch.where(mask, v, 0)
def pick(mask, incoming, protect, left, phase, lane):
nonlocal errors
forbidden = reserved | protect
j, save, _, _ = self.policy(state, dirty, used, forbidden, tv, get(last, incoming), left, zero + phase, last.gather(1, state.clamp_min(0)), nxt)
errors = errors | mask & get(forbidden, j)
victim = get(state, j)
spill = mask & save & (victim >= 0)
emit(lane, 'store', j, victim, spill)
put(backed, victim, torch.ones_like(mask), spill)
put(used, j, torch.ones_like(mask), mask)
return j
for i, j0 in enumerate((12, 13, 14)):
j = zero + j0
v = get(state, j)
d = get(dirty, j)
mask = reserved[:, j0]
live = (v >= 0) & (get(last, v) >= t)
key = (v < 0).long() * 16 + live.long() * 8 + d.long() * 4
save = self.policy.base_save[j0, key]
relocate = mask & (v >= 0) & save
k = pick(relocate, v, empty_mask, minus, 0, i * 3)
emit(i * 3 + 1, 'mov', k, j, relocate)
put(state, k, v, relocate)
put(dirty, k, d, relocate)
emit(i * 3 + 2, 'release', j, zero, mask)
put(state, j, minus, mask)
put(dirty, j, torch.zeros_like(mask), mask)
def load(v, mask, protect, lane):
nonlocal errors
hits = state == v[:, None]
found = hits.any(1)
hit = hits.long().argmax(1)
missing = mask & ~found
errors = errors | missing & ~get(backed, v)
j = pick(missing, v, protect, minus, 0, lane)
emit(lane + 1, 'load', j, v, missing)
put(state, j, v, missing)
put(dirty, j, torch.zeros_like(mask), missing)
return torch.where(found, hit, j)
l = load(torch.where(ending, x['ret'], refs[:, 0]), arithmetic | ending, empty_mask, 9)
rr = load(refs[:, 1], hasright, reg == l[:, None], 11)
emit(13, 'count', rr, zero, varshift)
d = pick(active, tv.clamp_max(V - 1), (reg == rr[:, None]) & (hasright & ~varshift)[:, None], torch.where(const, minus, l), 1, 14)
emit(15, 'mov', d, l, arithmetic & (d != l))
kind = torch.where(varshift, self.shift_ops[op], torch.where(isimm[:, 1], self.immediate_ops[op], self.regular[op]))
payload = torch.where(const, imm[:, 0], torch.where(varshift, zero, torch.where(hasright, rr, torch.where(isimm[:, 1], imm[:, 1], zero))))
emit(16, torch.where(ending, zero + EID['ret'], kind), torch.where(ending, l, d), torch.where(ending, zero, payload), active | ending)
put(state, d, tv, active)
put(dirty, d, torch.ones_like(active), active)
return (events, errors)12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849import json
from . import canonical as experiment
class CanonicalMIR:
def __init__(self, config):
self.vocab = list(config['vocab'])
self.width = int(config['operands'])
if self.vocab[:2] != ['<PAD>', '<OOV>'] or len(set(self.vocab)) != len(self.vocab):
raise ValueError('Invalid MIR vocabulary')
self.fields = [None, None] + [json.loads(v)[1] for v in self.vocab[2:]]
for k, operands in enumerate(self.fields[2:], 2):
if len(operands) > self.width or any((len(o) != 6 for o in operands)):
raise ValueError('Invalid MIR operand schema')
for field, rule in [('signature_ref_mask', lambda o: o[0] == 'vreg' and (not o[1])), ('signature_imm_mask', lambda o: o[0] == 'imm')]:
if field in config and list(config[field][k]) != [rule(o) for o in operands] + [False] * (self.width - len(operands)):
raise ValueError('MIR mask differs from vocabulary')
def decode(self, sig, refs, imm):
definitions = set()
padding = False
for i, k in enumerate(sig, 1):
if k < 0 or k >= len(self.vocab) or k == 1:
raise ValueError('OOV MIR signature')
if k == 0:
padding = True
operands = []
else:
if padding:
raise ValueError('Nontrailing MIR padding')
operands = self.fields[k]
for j in range(self.width):
ref = j < len(operands) and operands[j][0] == 'vreg' and (not operands[j][1])
immediate = j < len(operands) and operands[j][0] == 'imm'
if ref and refs[i - 1][j] not in definitions:
raise ValueError('Invalid defining reference')
if not ref and refs[i - 1][j] != 0:
raise ValueError('Unexpected reference payload')
if immediate and (not 0 <= imm[i - 1][j] < 2 ** 32):
raise ValueError('Immediate outside uint32')
if not immediate and imm[i - 1][j] != 0:
raise ValueError('Unexpected immediate payload')
count = sum((o[0] == 'vreg' and o[1] for o in operands))
if count > 1:
raise ValueError('Multiple virtual definitions')
if count:
definitions.add(i)
return experiment.decode_canonical(sig, refs, imm, self.vocab)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125import json,re
MASK = 4294967295
DIVOPS = {'udiv', 'urem', 'sdiv', 'srem'}
BIN = {'ADD': 'add', 'SUB': 'sub', 'XOR': 'xor', 'AND': 'and', 'OR': 'or', 'IMUL': 'mul', 'SHL': 'shl', 'SHR': 'shr', 'SAR': 'sar'}
def decode_canonical(sig, refs, imms, vocab):
"""Accept NeuroCC signature IDs, one-based refs, raw immediates. Fixed ISA lowering."""
defs = {}
phys = {'edi': 0, 'esi': 1, 'edx': 2}
rows = []
ret = None
def materialize(v):
if isinstance(v, tuple) and v[0] == 'div':
_, op, a, b = v
idx = len(rows) + 3
rows.append((op, [('v', a), ('v', b)]))
return idx
if not isinstance(v, int):
raise ValueError('invalid physical state')
return v
for i, k in enumerate(sig, 1):
k = int(k)
if k == 0:
if ret is None:
raise ValueError('early padding')
continue
if k < 2 or k >= len(vocab) or ret is not None:
raise ValueError('bad signature/order')
op, operands = json.loads(vocab[k])
dest = []
args = []
preguse = []
for j, (kind, d, p, c, flags, tied) in enumerate(operands):
if kind == 'preg' and p == 'eflags':
if not d:
raise ValueError('flags use')
continue
if kind == 'vreg' and c not in ('gr32', 'gr32_nosp', ''):
raise ValueError('register class ' + c)
if d:
dest.append((kind, i if kind == 'vreg' else p))
continue
if kind == 'vreg':
args.append(('v', defs[int(refs[i - 1][j])]))
elif kind == 'preg':
args.append(('v', phys[p]))
preguse.append(p)
elif kind == 'imm':
args.append(('i', int(imms[i - 1][j]) & MASK))
else:
raise ValueError('operand kind ' + kind)
if op == 'CDQ':
if set(dest) != {('preg', 'eax'), ('preg', 'edx')} or preguse != ['eax']:
raise ValueError('CDQ shape')
phys['eax'] = materialize(args[0][1])
phys['edx'] = ('sign', phys['eax'])
continue
if op in ('DIV32r', 'IDIV32r'):
if set(dest) != {('preg', 'eax'), ('preg', 'edx')} or preguse != ['eax', 'edx'] or len(args) != 3:
raise ValueError('DIV shape')
b = materialize(args[0][1])
a = materialize(args[1][1])
high = args[2][1]
if op == 'DIV32r':
if not isinstance(high, int) or high < 3 or rows[high - 3] != ('const', [('i', 0)]):
raise ValueError('nonzero high half')
q, rem = ('udiv', 'urem')
else:
if high != ('sign', a):
raise ValueError('not sign extended')
q, rem = ('sdiv', 'srem')
phys['eax'] = ('div', q, a, b)
phys['edx'] = ('div', rem, a, b)
continue
if op == 'RET64':
if dest or len(args) != 1 or operands[-1][2] != 'eax':
raise ValueError('bad ret')
ret = materialize(args[0][1])
continue
if len(dest) != 1:
raise ValueError('bad dest ' + op)
typ, key = dest[0]
if op in ('COPY', 'KILL'):
if len(args) != 1 or args[0][0] != 'v':
raise ValueError('copy')
v = materialize(args[0][1])
if typ == 'preg' and key not in ('eax', 'edx', 'ecx', 'cl'):
raise ValueError('unsupported physical def')
else:
if typ != 'vreg':
raise ValueError('physical arithmetic')
if op == 'MOV32ri':
kind = 'const'
elif op == 'MOV32r0':
kind = 'const'
args = [('i', 0)]
elif op in ('NEG32r', 'NOT32r', 'INC32r', 'DEC32r'):
kind = op[:3].lower()
else:
m = re.fullmatch('(ADD|SUB|XOR|AND|OR|IMUL|SHL|SHR|SAR)32(rr|ri|ri8|rri|rri8|r1|rCL)', op)
if not m:
raise ValueError('unsupported opcode ' + op)
kind = BIN[m[1]]
if m[2] == 'r1':
args.append(('i', 1))
if m[2] == 'rCL' and operands[-1][2] != 'cl':
raise ValueError('missing CL constraint')
if len(args) != (1 if kind in ['const', 'neg', 'not', 'inc', 'dec'] else 2):
raise ValueError('arity ' + op)
if kind == 'const' and args[0][0] != 'i':
raise ValueError('non-immediate const')
if kind != 'const' and args[0][0] != 'v':
raise ValueError('unexpected operand')
args = [(k, materialize(v) if k == 'v' else v) for k, v in args]
v = len(rows) + 3
rows.append((kind, args))
(defs if typ == 'vreg' else phys)[key] = v
if ret is None:
raise ValueError('missing return')
return (rows, ret)1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import torch
from torch import nn
from torch.nn import functional as F
from .physical import OPS
INPUTS = ('signature', 'register', 'immediate', 'stack')
class Encoder(nn.Module):
def __init__(self, width=96):
super().__init__()
self.width = width
self.net = nn.Sequential(nn.Linear(len(OPS) + 34 + 2, width), nn.GELU(), nn.Linear(width, width), nn.GELU(), nn.Linear(width, 42))
def forward(self, sig, reg, imm, stack):
x = torch.cat([F.one_hot(sig, len(OPS)), F.one_hot(reg + 1, 17).flatten(-2), stack.eq(0), stack.le(127)], -1).float()
z = self.net(x)
bits, l, p, src = z.split((32, 5, 3, 2), -1)
return (bits.reshape(*sig.shape, 4, 8), l, p, src)
def decode(self, out, sig, imm, stack):
bits, l, p, src = out
w = 2 ** torch.arange(8, device=sig.device)
prefix = ((bits > 0) * w).sum(-1)
pl = l.argmax(-1)
n = torch.tensor([0, 1, 4], device=sig.device)[p.argmax(-1)]
src = src.argmax(-1)
num = torch.where(src.bool(), stack[..., 0], imm[..., 0])
pos = torch.arange(8, device=sig.device)
k = pos - pl[..., None]
body = num[..., None] >> k.clamp(0, 3) * 8 & 255
v = torch.where(pos < pl[..., None], prefix.gather(-1, pos.clamp_max(3).expand(*sig.shape, 8)), body)
lengths = (pl + n).masked_fill(sig == 0, 0)
if (sig == 1).any():
raise ValueError('OOV physical MIR')
return (v, lengths)
@torch.no_grad()
def encode(self, tensors):
x = tuple((tensors[k] for k in INPUTS))
v, l = self.decode(self(*x), x[0], x[2], x[3])
return pack(v, l)
def pack(v, l):
b, t, w = v.shape
off = l.cumsum(1) - l
pos = torch.arange(w, device=v.device)
mask = pos < l[..., None]
dst = off[..., None] + pos
buf = torch.zeros(b, t * w, dtype=torch.long, device=v.device)
buf.scatter_add_(1, dst.clamp_max(t * w - 1).flatten(1), (v * mask).flatten(1))
return (buf, l.sum(1))123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990import torch
from torch import nn
OPS = ('pad', 'const', 'add', 'sub', 'mul', 'and', 'or', 'xor', 'neg', 'not', 'inc', 'dec', 'shl', 'shr', 'sar', 'udiv', 'urem', 'sdiv', 'srem')
DIV_IDS = tuple((OPS.index(o) for o in ('udiv', 'urem', 'sdiv', 'srem')))
SHIFT_IDS = tuple((OPS.index(o) for o in ('shl', 'shr', 'sar')))
REGS = (12, 13, 14)
def pack(programs):
"""CPU: rows/ret -> tensors, position t is normalized value t; 0..2 args."""
B = len(programs)
V = max((len(rows) + 3 for rows, _ in programs))
op = torch.zeros((B, V), dtype=torch.long)
refs = torch.full((B, V, 2), -1, dtype=torch.long)
imm = torch.zeros_like(refs)
isimm = torch.zeros_like(refs, dtype=torch.bool)
lengths = []
returns = []
for i, (rows, ret) in enumerate(programs):
n = len(rows) + 3
if not 0 <= ret < n:
raise ValueError('invalid return')
lengths.append(n)
returns.append(ret)
for t, (name, args) in enumerate(rows, 3):
op[i, t] = OPS.index(name)
if len(args) > 2:
raise ValueError('arity')
for j, (k, v) in enumerate(args):
if k == 'v':
if not 0 <= v < t:
raise ValueError('invalid ref')
refs[i, t, j] = v
elif k == 'i':
if not 0 <= v < 2 ** 32:
raise ValueError('uint32')
imm[i, t, j] = v
isimm[i, t, j] = True
else:
raise ValueError('operand kind')
return dict(op=op, refs=refs, immediate=imm, isimm=isimm, n=torch.tensor(lengths), ret=torch.tensor(returns))
class GraphPreparation(nn.Module):
@staticmethod
def edges(x):
B, V, K = x['refs'].shape
dev = x['refs'].device
pos = torch.arange(V, device=dev, dtype=torch.long)[None, :]
mask = (x['refs'] >= 0) & (pos[:, :, None] < x['n'][:, None, None])
dst = torch.where(mask, x['refs'], V).reshape(B, -1)
times = pos[:, :, None].expand(B, V, K).reshape(B, -1)
return (torch.cat((dst, x['ret'][:, None]), 1), torch.cat((times, x['n'][:, None]), 1))
@staticmethod
def exact(x):
B, V, _ = x['refs'].shape
dev = x['refs'].device
dst, times = GraphPreparation.edges(x)
ids = torch.arange(V, device=dev)[None, :].expand(B, -1)
base = torch.cat((ids.clamp_min(3) - 1, torch.full((B, 1), -1, device=dev, dtype=torch.long)), 1)
ends = base.scatter_reduce(1, dst, times, reduce='amax')[:, :V]
return torch.where(ids < x['n'][:, None], ends, -1)
@staticmethod
def reservations(x):
"""[B,V+1,3]: current mask and strictly future reservation; -1 if none."""
op = x['op']
B, V = op.shape
dev = op.device
div = torch.zeros_like(op, dtype=torch.bool)
shift = div.clone()
for k in DIV_IDS:
div = div | (op == k)
for k in SHIFT_IDS:
shift = shift | (op == k)
shift = shift & (x['refs'][:, :, 1] >= 0)
valid = torch.arange(V, device=dev)[None, :] < x['n'][:, None]
div = div & valid
shift = shift & valid
now = torch.cat((torch.stack((div, shift, div), -1), torch.zeros((B, 1, 3), device=dev, dtype=torch.bool)), 1)
pos = torch.arange(V + 1, device=dev)[None, :, None]
sentinel = V + 1
inclusive = torch.where(now, pos, sentinel).flip(1).cummin(1).values.flip(1)
future = torch.cat((inclusive[:, 1:], torch.full((B, 1, 3), sentinel, device=dev, dtype=torch.long)), 1)
return (now, torch.where(future == sentinel, -1, future))1234567891011
REGS = tuple((i for i in range(16) if i != 4))
RR = ('mov', 'add', 'sub', 'xor', 'and', 'or', 'mul')
IMM = tuple((x + '_imm' for x in RR if x != 'mov')) + ('shl_imm', 'shr_imm', 'sar_imm')
ONE = ('neg', 'not', 'inc', 'dec', 'shl_cl', 'shr_cl', 'sar_cl', 'div', 'idiv', 'push', 'pop')
OPS = ('<PAD>', '<OOV>') + RR + IMM + ONE + ('const', 'store', 'load', 'frame_sub', 'frame_add', 'cdq', 'ret')1234567891011121314151617181920212223242526272829303132333435363738394041424344import torch
from torch import nn
from . import allocation_constants as c
class TensorPolicy(nn.Module):
"""Preserve CPU-generated base LUT and Python double score arithmetic.
Each row is an independent decision. All 15 candidates are parallel.
Caller supplies at least one allowed candidate per active decision.
"""
def __init__(self):
super().__init__()
self.register_buffer('base_score', torch.empty(15, 32, dtype=torch.float64))
self.register_buffer('base_save', torch.empty(15, 32, dtype=torch.bool))
self.register_buffer('weights', torch.empty(9, dtype=torch.float64))
self.register_buffer('regs', torch.arange(15))
self.register_buffer('callee', torch.tensor([r in c.CALLEE for r in c.REGS]))
self.register_buffer('extended', torch.tensor([r >= 8 for r in c.REGS]))
self.eval().requires_grad_(False)
def forward(self, state, dirty, used, forbidden, t, incoming_end, left, phase, occupant_end, next_reservation):
t = t[:, None]
phase = phase[:, None]
left = left[:, None]
incoming_end = incoming_end[:, None]
empty = state < 0
live = ~empty & torch.where(phase == 0, occupant_end >= t, occupant_end > t)
reuse = self.regs == left
key = empty.long() * 16 + live.long() * 8 + dirty.long() * 4 + reuse.long() * 2 + phase
q = self.base_score[self.regs, key]
save = self.base_save[self.regs, key]
cross = (next_reservation > t) & (next_reservation <= incoming_end)
remaining = torch.where(live, (occupant_end - t).clamp(0, 32), 0).double() / 32
soon = torch.where(cross, 1.0 / (next_reservation - t).clamp_min(1).double(), 0.0)
features = (remaining, cross, self.callee & ~used, self.extended.expand_as(used), reuse, live & dirty, live, empty, soon)
adj = torch.zeros_like(q)
for i, f in enumerate(features):
adj = adj + self.weights[i] * f.double()
scores = (q + adj).masked_fill(forbidden, -torch.inf)
allowed_save = save & ~forbidden
chosen = scores.argmax(1)
spill = allowed_save.gather(1, chosen[:, None]).squeeze(1)
return (chosen, spill, scores, allowed_save)12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485import torch
from torch import nn
from .encoder import Encoder,pack as pack_bytes
from .physical import OPS
from .allocator import TensorAllocator
from .stack import TensorStackLower
class ResidentEncoder(Encoder):
"""Same frozen network/byte packing; tensor error mask replaces scalar OOV check."""
def __init__(self, width=96):
super().__init__(width)
self.register_buffer('op_ids', torch.arange(len(OPS)), persistent=False)
self.register_buffer('reg_ids', torch.arange(-1, 16), persistent=False)
self.register_buffer('byte_weights', 2 ** torch.arange(8), persistent=False)
self.register_buffer('byte_pos', torch.arange(8), persistent=False)
self.register_buffer('payload_sizes', torch.tensor([0, 1, 4]), persistent=False)
self.eval().requires_grad_(False)
def forward(self, sig, reg, imm, stack):
x = torch.cat((sig[..., None] == self.op_ids, (reg[..., None] == self.reg_ids).flatten(-2), stack.eq(0), stack.le(127)), -1).float()
bits, l, p, src = self.net(x).split((32, 5, 3, 2), -1)
prefix = ((bits.reshape(*sig.shape, 4, 8) > 0) * self.byte_weights).sum(-1)
pl = l.argmax(-1)
n = self.payload_sizes[p.argmax(-1)]
num = torch.where(src.argmax(-1).bool(), stack[..., 0], imm[..., 0])
pos = self.byte_pos
k = pos - pl[..., None]
body = num[..., None] >> k.clamp(0, 3) * 8 & 255
v = torch.where(pos < pl[..., None], prefix.gather(-1, pos.clamp_max(3).expand(*sig.shape, 8)), body)
length = (pl + n).masked_fill(sig == 0, 0)
return (v, length)
def encode_resident(self, z, lengths, error, chunk=256):
if chunk < 1:
raise ValueError('positive encoder chunk required')
sig = z['signature']
B, T = sig.shape
pos = torch.arange(T, device=sig.device)[None, :]
active = pos < lengths[:, None]
reg = z['register']
imm = z['immediate']
stack = z['stack']
bad = (sig < 0) | (sig >= len(OPS)) | (sig == 1) | ((sig != 0) != active)
bad |= ((reg < -1) | (reg > 15) | (reg == 4)).any(-1)
bad |= ((imm < 0) | (imm >= 2 ** 32) | (stack < 0) | (stack >= 2 ** 31)).any(-1)
error = error | bad.any(1) | (lengths <= 0) | (lengths > T)
vs = []
ls = []
for i in range(0, T, chunk):
j = min(i + chunk, T)
good = ~error[:, None]
s = torch.where(good, sig[:, i:j], 0)
r = torch.where(good[..., None], reg[:, i:j], -1)
m = torch.where(good[..., None], imm[:, i:j], 0)
st = torch.where(good[..., None], stack[:, i:j], 0)
v, l = self(s, r, m, st)
error = error | ((s != 0) & ((l < 1) | (l > 8))).any(1)
vs.append(v)
ls.append(l)
v = torch.cat(vs, 1)
l = torch.cat(ls, 1)
l = l.masked_fill(error[:, None], 0)
buf, n = pack_bytes(v, l)
return (buf, n, error)
class TensorBackend(nn.Module):
def __init__(self, encoder_chunk=256, encoder_width=96):
super().__init__()
self.allocator = TensorAllocator()
self.lower = TensorStackLower()
self.encoder = ResidentEncoder(encoder_width)
if encoder_chunk < 1:
raise ValueError('positive encoder chunk required')
self.encoder_chunk = encoder_chunk
self.eval().requires_grad_(False)
@torch.inference_mode()
def forward(self, x, capacity=None):
events, ae = self.allocator(x)
z, lengths, routed, metrics, le = self.lower(x, events, capacity)
buf, n, error = self.encoder.encode_resident(z, lengths, ae | le, self.encoder_chunk)
return dict(code=buf, byte_length=n, error=error, physical_length=lengths, allocation_error=ae, lower_error=le, metrics=metrics)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153import torch
from torch import nn
from .allocator import EID,EVENT_OPS,LANES
from .graph import GraphPreparation
from . import physical as p
from . import allocation_constants as d
from . import allocation_constants as e
PID = {o: i for i, o in enumerate(p.OPS)}
class TensorStackLower(nn.Module):
def __init__(self):
super().__init__()
self.register_buffer('regmap', torch.tensor(d.REGS))
self.register_buffer('callee', torch.tensor(sorted(e.CALLEE)))
self.register_buffer('ordinary', torch.tensor([PID.get(o, 0) for o in EVENT_OPS]))
self.eval().requires_grad_(False)
def stack(self, x, events):
B, V = x['op'].shape
dev = events.device
flat = events.reshape(B, -1, 3)
T = flat.shape[1]
op, r, v = flat.unbind(-1)
store = op == EID['store']
load = op == EID['load']
mem = store | load
idx = torch.arange(T, device=dev)[None, :].expand(B, -1)
t = idx // LANES
valid = (v >= 0) & (v < V)
safe = v.clamp(0, V - 1)
dest = torch.where(store & valid, safe, V)
first = torch.full((B, V + 1), T, device=dev, dtype=torch.long).scatter_reduce(1, dest, idx, reduce='amin')[:, :V]
order = first.argsort(dim=1, stable=True)
last = GraphPreparation.exact(x)
owners = torch.full((B, V), -1, device=dev, dtype=torch.long)
mapping = owners.clone()
slots = torch.zeros(B, device=dev, dtype=torch.long)
peak = slots.clone()
reuses = slots.clone()
error = (mem & ~valid).any(1)
ar = torch.arange(V, device=dev)[None, :]
for j in range(V):
val = order[:, j:j + 1]
pos = first.gather(1, val).squeeze(1)
active = pos < T
time = pos // LANES
occupied = (owners >= 0) & (last.gather(1, owners.clamp_min(0)) >= time[:, None])
free = ~occupied
k = free.long().argmax(1)
error = error | active & ~free.any(1)
old = owners.gather(1, k[:, None]).squeeze(1)
reuses += (active & (k < slots)).long()
slots = torch.maximum(slots, torch.where(active, k + 1, slots))
peak = torch.maximum(peak, torch.where(active, occupied.sum(1) + 1, peak))
owners.scatter_(1, k[:, None], torch.where(active, val[:, 0], old)[:, None])
mapping.scatter_(1, val, torch.where(active, k, -1)[:, None])
homes = mapping.gather(1, safe)
error = error | (mem & ((homes < 0) | (first.gather(1, safe) > idx) | (last.gather(1, safe) < t))).any(1)
routed = torch.stack((op, r, torch.where(mem, homes, v)), dim=-1).reshape_as(events)
return (routed, dict(slots=slots, distinct_spilled=(first < T).sum(1), reuses=reuses, peak_backed=peak, frame=(4 * slots + 15) // 16 * 16), error)
def lower(self, events, metrics, capacity):
B = events.shape[0]
dev = events.device
op, r, s = events.reshape(B, -1, 3).unbind(-1)
frame = metrics['frame']
slots = metrics['slots']
regs = self.regmap[r.clamp(0, 14)]
src = self.regmap[s.clamp(0, 14)]
active = (op != 0) & (op != EID['release'])
ret = op == EID['ret']
count = op == EID['count']
store = op == EID['store']
load = op == EID['load']
mem = store | load
div = torch.zeros_like(active)
signed = div.clone()
rem = div.clone()
for name in ('udiv', 'urem', 'sdiv', 'srem'):
m = op == EID[name]
div |= m
if name.startswith('s'):
signed |= m
if name.endswith('rem'):
rem |= m
saveable = active & ~(store | ret | count)
saved = torch.stack([((regs == k) & saveable).any(1) for k in self.callee.unbind()], 1)
nsave = saved.sum(1)
hasframe = frame > 0
prefix = nsave + hasframe.long() + 1
lengths = torch.where(active & ~ret, torch.where(div, 4, 1), 0)
offset = lengths.cumsum(1) - lengths + prefix[:, None]
body_end = prefix + lengths.sum(1)
retreg = (regs * ret).sum(1)
retmov = retreg != 0
suffix = retmov.long() + hasframe.long() + nsave + 1
total = body_end + suffix
error = (total > capacity) | (ret.sum(1) != 1) | (active & ((r < 0) | (r >= 15))).any(1) | (mem & ((s < 0) | (s >= slots[:, None]))).any(1)
buf = torch.zeros((B, capacity, 5), device=dev, dtype=torch.long)
def emit(pos, mask, kind, a=-1, b=-1, imm=0, stack=0):
pos = pos.reshape(B, -1)
mask = mask.reshape_as(pos) & (pos >= 0) & (pos < capacity)
def field(z):
if isinstance(z, int):
return torch.full_like(pos, z)
return z.reshape(B, -1).expand_as(pos)
data = torch.stack((field(kind), field(a) + 1, field(b) + 1, field(imm), field(stack)), dim=-1)
buf.scatter_add_(1, pos.clamp(0, capacity - 1)[..., None].expand(-1, -1, 5), data * mask[..., None])
rank = saved.long().cumsum(1) - 1
cr = self.callee[None, :].expand(B, -1)
emit(rank, saved, PID['push'], cr)
emit(nsave, hasframe, PID['frame_sub'], imm=frame)
emit(prefix - 1, torch.ones_like(hasframe), PID['mov'], 8, 2)
rr = torch.zeros_like(active)
im = torch.zeros_like(active)
shift = torch.zeros_like(active)
for name in p.RR:
rr |= op == EID[name]
for name in p.IMM:
m = op == EID[name]
im |= m
if name.startswith(('shl', 'shr', 'sar')):
shift |= m
const = op == EID['const']
ordinary = active & ~(ret | div | count)
k = self.ordinary[op]
error |= (ordinary & (k == 0)).any(1)
emit(offset, ordinary, k, regs, torch.where(rr, src, -1), torch.where(const | im, torch.where(shift, s & 31, s), 0), torch.where(mem, s * 4, 0))
emit(offset, count, PID['mov'], 1, regs)
emit(offset, div, PID['mov'], 0, regs)
emit(offset + 1, div, torch.where(signed, PID['cdq'], PID['xor']), torch.where(signed, -1, 2), torch.where(signed, -1, 2))
emit(offset + 2, div, torch.where(signed, PID['idiv'], PID['div']), src)
emit(offset + 3, div, PID['mov'], regs, torch.where(rem, 2, 0))
emit(body_end, retmov, PID['mov'], 0, retreg)
post = body_end + retmov.long()
emit(post, hasframe, PID['frame_add'], imm=frame)
popbase = post + hasframe.long()
emit(popbase[:, None] + nsave[:, None] - rank - 1, saved, PID['pop'], cr)
emit(total - 1, torch.ones_like(hasframe), PID['ret'])
return (dict(signature=buf[:, :, 0].contiguous(), register=(buf[:, :, 1:3] - 1).contiguous(), immediate=buf[:, :, 3:4].contiguous(), stack=buf[:, :, 4:5].contiguous()), total, error)
def forward(self, x, events, capacity=None):
capacity = capacity or 8 * x['op'].shape[1] + 32
if capacity < 1:
raise ValueError('positive physical capacity required')
routed, metrics, error = self.stack(x, events)
physical, lengths, lower_error = self.lower(routed, metrics, capacity)
return (physical, lengths, routed, metrics, error | lower_error)1234567891011121314151617181920import argparsefrom pathlib import Pathfrom . import NeuralCompilerdef main():p=argparse.ArgumentParser(description='Experimental neural compiler; callable x86-64 SysV bytes, no native execution.')source=p.add_mutually_exclusive_group(required=True); source.add_argument('--source'); source.add_argument('--file',type=Path)p.add_argument('--model',default='chrisuser/neuro-compiler'); p.add_argument('--revision'); p.add_argument('--device',choices=['auto','cuda','cpu'],default='auto'); p.add_argument('--output',type=Path); p.add_argument('--verify',action='store_true')a=p.parse_args(); text=a.source if a.source is not None else a.file.read_text(encoding='utf8')code=NeuralCompiler.from_pretrained(a.model,device=a.device,revision=a.revision).compile(text)if a.verify:from .verification import verifyimport jsonreport=verify(text,code); print(json.dumps(report))if not report['semantic']: raise SystemExit('Sampled semantics failed; output file not written')if a.output:with a.output.open('xb') as f: f.write(code)else: print(code.hex(' '))if __name__=='__main__': main()1234567891011121314151617import argparse,jsonfrom pathlib import Pathfrom . import NeuralCompilerdef main():p=argparse.ArgumentParser(description='Frozen hybrid compiler; raw x86-64 SysV bytes, never native execution')group=p.add_mutually_exclusive_group(required=True);group.add_argument('--source');group.add_argument('--file',type=Path)p.add_argument('--model',default='chrisuser/neuro-compiler');p.add_argument('--revision',default='0.3.0');p.add_argument('--device',choices=('auto','cpu','cuda'),default='auto');p.add_argument('--output',type=Path);p.add_argument('--verify',action='store_true');a=p.parse_args()source=a.source if a.source is not None else a.file.read_text(encoding='utf-8');code=NeuralCompiler.from_pretrained(a.model,revision=a.revision,device=a.device).compile(source)if a.verify:from .verification import verifyreport=verify(source,code);print(json.dumps(report))if not report['semantic'] or not report['abi']:raise SystemExit('Sampled verification failed; no output written')if a.output:with a.output.open('xb') as f:f.write(code)else:print(code.hex(' '))if __name__=='__main__':main()
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110from dataclasses import dataclassfrom pathlib import Pathimport hashlibimport jsonimport reimport warningsimport torchfrom safetensors.torch import load_filefrom . import neurocc as ncfrom .neurocc_graph_live import Runtime, raw_bytesfrom .neurocc_graph_ast_grounded import GroundedASTfrom .neurocc_graph_ssa import GraphSSAfrom .neurocc_graph_isel import GraphISELfrom .neurocc_graph_regalloc_occupancy import OccupancyAllocatorfrom .neurocc_graph_binary import BinaryEncoder@dataclassclass CompilationResult:machine_code: bytesast: dictssa: dictvirtual_mir: dictphysical_mir: dictdiagnostics: dictclass NeuralCompiler:@classmethoddef from_pretrained(cls,model_id='chrisuser/neuro-compiler',device='auto',revision=None):root=Path(model_id)if not root.is_dir():from huggingface_hub import snapshot_downloadroot=Path(snapshot_download(str(model_id),revision=revision,allow_patterns=['manifest.json','config.json','weights/*.safetensors']))try: manifest=json.loads((root/'manifest.json').read_text())except FileNotFoundError as e: raise FileNotFoundError(f'Missing model manifest: {root}') from eif manifest.get('architecture')=='NeuroCC V2':from .legacy import NeuralCompiler as Legacyreturn Legacy.from_pretrained(root,device=device)if manifest.get('architecture')!='NeuroCC graph resource streams': raise ValueError('Unsupported compiler architecture')spec=manifest['spec']if spec!=dict(backbone='Qwen/Qwen2.5-Coder-0.5B',revision='0576a1bc0ae53f21860e905e081807bd7ff4a4c7',tokens=96,depths=[6]): raise ValueError('Incompatible backbone configuration')self=cls(); self.manifest=manifest; self.root=rootdev=nc.device() if device=='auto' else torch.device(device)if dev.type not in ('cuda','cpu'): raise ValueError('Only CPU and CUDA inference are supported')if dev.type=='cuda' and not torch.cuda.is_available(): raise ValueError('CUDA requested but unavailable')rt=Runtime(); rt.dev=dev; rt.spec=specmodels=[]; configs=[]for name,factory,attribute in [('ast',GroundedAST,'ast'),('ssa',GraphSSA,'ssa'),('isel',GraphISEL,'isel'),('regalloc',OccupancyAllocator,'ra'),('binary',BinaryEncoder,'binary')]:entry=manifest['stages'][name]; path=root/'weights'/(name+'.safetensors')if not path.is_file(): raise FileNotFoundError(f'Missing {name} weights: {path}')with path.open('rb') as f: digest=hashlib.file_digest(f,'sha256').hexdigest()if digest!=entry['weight_sha256']: raise ValueError(f'Weight integrity check failed: {name}')cfg=entry['config']; model=factory(cfg)try: model.load_state_dict(load_file(str(path)),strict=True)except RuntimeError as e: raise ValueError(f'Incompatible {name} model configuration or weights') from eif sum(p.numel() for p in model.parameters())!=entry['parameters']: raise ValueError(f'Parameter count mismatch: {name}')setattr(rt,attribute,model.to(dev).eval().requires_grad_(False)); models.append(model); configs.append(cfg)rt.ac,rt.sc,rt.ic,rt.rc,rt.bc=configsif rt.ac['mode']!='source_indexed' or rt.rc['candidate']!='resource_streams' or rt.rc['occupancy_mode']!='occupancy' or rt.bc['mode']!='independent': raise ValueError('Incompatible stage architecture')if rt.sc['ast_checkpoint_sha256']!=manifest['stages']['ast']['original_sha256'] or rt.ic['ir_checkpoint_sha256']!=manifest['stages']['ssa']['original_sha256'] or rt.rc['isel_checkpoint_sha256']!=manifest['stages']['isel']['original_sha256']: raise ValueError('Incompatible checkpoint provenance')if rt.ic['vocab']!=rt.rc['pre_vocab'] or rt.rc['vocab']!=rt.bc['source_vocab'] or any(rt.rc[k]!=rt.bc[k] for k in ('register_vocab','immediate_vocab','stack_vocab')): raise ValueError('Incompatible vocabulary configuration')rt.tokenizer=nc.tokenizer_for(spec); rt.backbone=nc.Backbone(spec,dev).eval().requires_grad_(False)if rt.backbone.hidden!=rt.ac['hidden']: raise ValueError('Backbone hidden-width mismatch')self.runtime=rt; self.dev=devwarnings.warn('Experimental compiler: generated machine code may be incorrect or unsafe. No native execution or formal verification is performed.',UserWarning,stacklevel=2)return self@staticmethoddef _inputs(sources):if isinstance(sources,str): raise TypeError('Expected a sequence of source strings')sources=list(sources)for source in sources:if not isinstance(source,str) or not source.strip() or not source.isascii() or '\x00' in source: raise ValueError('Expected nonempty ASCII source without NUL characters')# Lexical validation only; no syntax graph or compilation decisions.m=re.fullmatch(r'\s*unsigned\s+f\s*\(\s*unsigned\s+a\s*,\s*unsigned\s+b\s*,\s*unsigned\s+c\s*\)\s*\{\s*return\s+([abc0-9u()+*^&|\s-]+)\s*;\s*\}\s*',source)if not m: raise ValueError('Unsupported function signature or source characters; see the restricted grammar')expression=m.group(1)operations=len(re.findall(r'[+*^&|-]',expression))if not 1<=operations<=7: raise ValueError('This release supports one through seven binary operations')for literal in re.findall(r'\d+u?',expression):if not literal.endswith('u') or not 1<=int(literal[:-1])<=63: raise ValueError('Supported literals are 1u through 63u')return sources@torch.inference_mode()def predict(self,sources,details=False):sources=self._inputs(sources)if not sources: raise ValueError('Empty prediction batch')try: return self.runtime.forward_batch(sources,details=details)except RuntimeError as e:if 'Source exceeds' in str(e): raise ValueError('Source exceeds the 96-token capacity; no truncation performed') from eraisedef compile_batch(self,sources,return_intermediates=False,batch_size=32):sources=self._inputs(sources)if not isinstance(batch_size,int) or batch_size<1: raise ValueError('batch_size must be a positive integer')result=[]for i in range(0,len(sources),batch_size):out=self.predict(sources[i:i+batch_size],details=return_intermediates)y,details=out if return_intermediates else (out,None)for j,row in enumerate(y):code=raw_bytes(row)if code is None: raise ValueError(f'Malformed neural output at batch index {i+j}; invalid byte/EOS/padding sequence or allocation overflow')if details is None: result.append(code)else:fields={k:{n:v[j] for n,v in details[k].items()} for k in ('ast','ssa','virtual_mir','physical_mir')}diagnostic={k:v[j] for k,v in details.items() if k not in fields}result.append(CompilationResult(code,**fields,diagnostics=diagnostic))return resultdef compile(self,source,return_intermediates=False):return self.compile_batch([source],return_intermediates=return_intermediates)[0]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121"""Portable source-to-bytes graph compiler with the frozen 15E hybrid backend."""from dataclasses import dataclassfrom pathlib import Pathimport hashlib,json,re,warningsimport torchfrom safetensors.torch import load_filefrom . import neurocc as ncfrom . import neurocc_graph_ast_grounded as gafrom . import neurocc_graph_ssa as ssfrom . import neurocc_graph_isel as gifrom .backbone import Backbonefrom .backend.boundary import CanonicalMIRfrom .backend.graph import packfrom .backend.resident import TensorBackend@dataclassclass CompilationResult:machine_code: bytes | Noneast: dict | Nonessa: dict | Nonevirtual_mir: dict | Nonephysical_mir: dict | Nonediagnostics: dictdef sha(path):with Path(path).open('rb') as f:return hashlib.file_digest(f,'sha256').hexdigest()class NeuralCompiler:@classmethoddef from_pretrained(cls,model_id='chrisuser/neuro-compiler',device='auto',revision='0.3.0',load_backbone=True):root=Path(model_id)if not root.is_dir():from huggingface_hub import snapshot_downloadroot=Path(snapshot_download(str(model_id),revision=revision,allow_patterns=['manifest.json','config.json','weights/*.safetensors']))m=json.loads((root/'manifest.json').read_text())if m.get('architecture')!='NeuroCC graph + frozen 15E hybrid' or m.get('release_version')!='0.3.0':raise ValueError('This package requires the 0.3.0 hybrid manifest; install the matching older package for older releases')if m['spec']!=dict(backbone='Qwen/Qwen2.5-Coder-0.5B',revision='0576a1bc0ae53f21860e905e081807bd7ff4a4c7',tokens=96,depths=[6]):raise ValueError('Incompatible frozen backbone')if m['max_operations']!=8 or m['frozen_backend']['slot_rank_weight']>=0:raise ValueError('Incompatible frozen backend configuration')self=cls();self.root=root;self.manifest=m;self.dev=nc.device() if device=='auto' else torch.device(device)if self.dev.type not in ('cpu','cuda') or self.dev.type=='cuda' and not torch.cuda.is_available():raise ValueError('Requested device is unavailable')def load(entry,model):path=root/entry['weight_file']if not path.is_file() or sha(path)!=entry['weight_sha256']:raise ValueError('Weight integrity check failed: '+str(path.name))model.load_state_dict(load_file(str(path)),strict=True)if sum(p.numel() for p in model.parameters())!=entry['parameters']:raise ValueError('Parameter count mismatch')return model.to(self.dev).eval().requires_grad_(False)self.ac=m['stages']['ast']['config'];self.sc=m['stages']['ssa']['config'];self.ic=m['stages']['isel']['config']if self.sc['ast_checkpoint_sha256']!=m['stages']['ast']['original_sha256'] or self.ic['ir_checkpoint_sha256']!=m['stages']['ssa']['original_sha256']:raise ValueError('Upstream checkpoint relationship mismatch')self.ast=load(m['stages']['ast'],ga.GroundedAST(self.ac));self.ssa=load(m['stages']['ssa'],ss.GraphSSA(self.sc));self.isel=load(m['stages']['isel'],gi.GraphISEL(self.ic))b=m['frozen_backend'];self.backend=load(b,TensorBackend(encoder_chunk=b['encoder_chunk'],encoder_width=b['encoder_width']));self.normalizer=CanonicalMIR(self.ic)self.tokenizer=self.backbone=Noneif load_backbone:self.tokenizer=nc.tokenizer_for(m['spec']);self.backbone=Backbone(m['spec'],self.dev,m['backbone_weight_sha256'],m['backbone_config_sha256'])if self.backbone.hidden!=self.ac['hidden']:raise ValueError('Backbone hidden-width mismatch')return selfdef _inputs(self,sources):if isinstance(sources,str):raise TypeError('Expected a sequence of source strings')sources=list(sources)for source in sources:if not isinstance(source,str) or not source.strip() or not source.isascii() or '\x00' in source:raise ValueError('Expected nonempty ASCII source without NUL')match=re.fullmatch(r'\s*unsigned\s+f\s*\(\s*unsigned\s+a\s*,\s*unsigned\s+b\s*,\s*unsigned\s+c\s*\)\s*\{\s*return\s+([abc0-9u()+*^&|\s-]+)\s*;\s*\}\s*',source)if not match:raise ValueError('Unsupported function signature or characters')expression=match[1]if not 1<=len(re.findall(r'[+*^&|-]',expression))<=8:raise ValueError('Supported range is one through eight binary operations')if len(source)>self.manifest['character_capacity']:raise ValueError('Source exceeds trained raw-character capacity; no truncation')for literal in re.findall(r'\d+u?',expression):if not literal.endswith('u') or not 1<=int(literal[:-1])<=63:raise ValueError('Supported literals are 1u through 63u')return sources@torch.inference_mode()def _frontend(self,features,mask,raw):raw={k:v.to(self.dev) for k,v in raw.items()};mask=mask.to(self.dev)output=self.ast(features.to(self.dev),mask,self.ac['capacity'],raw);ast=self.ast.decode(output);ast['features']=output['features'].half()output=self.ssa({k:ast[k] for k in ss.FIELDS},self.sc['capacity']);ssa=self.ssa.decode(output);ssa['features']=output['features'].half()sx={k:ssa[k] for k in gi.FIELDS};h=self.isel.encode(sx,self.ic['slots']).half();mir=self.isel.decode(self.isel.heads(h.float(),sx))return ast,ssa,mir@torch.inference_mode()def _encode(self,mir,ast=None,ssa=None,details=False,capacity=None):sig,refs,imm=mir;programs=[];accepted=[];out=[CompilationResult(None,None,None,None,None,{'status':'isel_rejected','error':None}) for _ in range(len(sig))]for i,(a,b,c) in enumerate(zip(*(x.detach().cpu().tolist() for x in mir))):try:program=self.normalizer.decode(a,b,c)except (ValueError,KeyError,IndexError,TypeError,OverflowError) as error:out[i].diagnostics['error']=str(error)else:programs.append(program);accepted.append(i)if not programs:return outx={k:v.to(self.dev) for k,v in pack(programs).items()};physical=Noneif details:events,ae=self.backend.allocator(x);physical,lengths,routed,metrics,le=self.backend.lower(x,events,capacity)code,n,error=self.backend.encoder.encode_resident(physical,lengths,ae|le,self.backend.encoder_chunk)result={'code':code,'byte_length':n,'error':error,'physical_length':lengths,'metrics':metrics}else:result=self.backend(x,capacity)flags=result['error'].cpu().tolist();n=result['byte_length'].cpu().tolist();code=result['code'].cpu();lengths=result['physical_length'].cpu().tolist();slots=result['metrics']['slots'].cpu().tolist()for j,i in enumerate(accepted):if flags[j]:out[i].diagnostics.update(status='backend_rejected',error='Frozen allocator/lowering/encoder rejected this row');continueif not 0<n[j]<=code.shape[1]:raise ValueError('Malformed byte length')value=out[i];value.machine_code=bytes(code[j,:n[j]].tolist());value.diagnostics.update(status='compiled',backend='frozen15E hybrid',physical_instructions=lengths[j],spill_slots=slots[j])if details:value.ast=None if ast is None else {k:v[i].detach().cpu() for k,v in ast.items()};value.ssa=None if ssa is None else {k:v[i].detach().cpu() for k,v in ssa.items()};value.virtual_mir={k:v[i].detach().cpu() for k,v in zip(('signature','refs','immediate'),mir)};value.physical_mir={k:v[j,:lengths[j]].detach().cpu() for k,v in physical.items()}return out@torch.inference_mode()def predict(self,sources,details=False):sources=self._inputs(sources)if not sources:raise ValueError('Empty prediction batch')if self.backbone is None:raise RuntimeError('Source inference requires load_backbone=True')ids,mask=nc.tokenize(self.tokenizer,sources,self.manifest['spec']['tokens']);raw,check=ga.encode_sources(self.tokenizer,sources,self.manifest['spec']['tokens'],self.manifest['character_capacity'])if not torch.equal(mask,check):raise ValueError('Tokenizer mask mismatch')with nc.amp(self.dev):features=self.backbone(ids.to(self.dev),mask.to(self.dev))[0].half()ast,ssa,mir=self._frontend(features,mask,raw);return self._encode(mir,ast,ssa,details)def compile_batch(self,sources,return_intermediates=False,batch_size=16,strict=True):sources=self._inputs(sources)if type(batch_size) is not int or batch_size<1:raise ValueError('batch_size must be a positive integer')results=[]for start in range(0,len(sources),batch_size):for j,value in enumerate(self.predict(sources[start:start+batch_size],return_intermediates)):if strict and value.machine_code is None:raise ValueError(f'Compilation rejected row {start+j}: {value.diagnostics}')results.append(value if return_intermediates else value.machine_code)return resultsdef compile(self,source,return_intermediates=False):return self.compile_batch([source],return_intermediates)[0]
12345678910111213141516171819202122232425262728293031323334353637383940import struct
def emulate(raw,expected,xs):
import capstone
import unicorn as u
import unicorn.x86_const as x
allowed={'mov','or','sub','add','and','ret','imul','xor','shl','sal','shr','sar','neg','not','inc','dec','push','pop','div','idiv','cdq'}
if not isinstance(raw,bytes) or not 0<len(raw)<1048576:return False,False,'Invalid byte length',0
base=0x100000;ins=list(capstone.Cs(capstone.CS_ARCH_X86,capstone.CS_MODE_64).disasm(raw,base))
if not ins or sum(i.size for i in ins)!=len(raw) or any(i.mnemonic not in allowed for i in ins) or ins[-1].mnemonic!='ret' or any(i.mnemonic=='ret' for i in ins[:-1]):return False,False,'Unsupported or incomplete straight-line code',0
code_size=((len(raw)+4095)//4096)*4096;end=base+code_size
stack=0x400000;rsp=stack+0x1f000;boundaries={i.address for i in ins}
uc=u.Uc(u.UC_ARCH_X86,u.UC_MODE_64);uc.mem_map(base,code_size);uc.mem_write(base,raw);uc.mem_protect(base,code_size,u.UC_PROT_READ|u.UC_PROT_EXEC);uc.mem_map(stack,0x20000,u.UC_PROT_READ|u.UC_PROT_WRITE)
fault=[];written=set();instructions=[0]
def memory(engine,access,address,size,value,user):
if address<stack or address+size>rsp+8:fault.append('Memory outside bounded stack')
elif access==u.UC_MEM_WRITE:
if address+size>rsp:fault.append('Return-address overwrite')
else:written.update(range(address,address+size))
elif any(v not in written for v in range(address,address+size)):fault.append('Uninitialized stack read')
if fault:engine.emu_stop()
def control(engine,address,size,user):
instructions[0]+=1;sp=engine.reg_read(x.UC_X86_REG_RSP)
if address not in boundaries or not stack<=sp<=rsp:fault.append('Invalid control flow or stack pointer');engine.emu_stop()
uc.hook_add(u.UC_HOOK_MEM_READ|u.UC_HOOK_MEM_WRITE,memory);uc.hook_add(u.UC_HOOK_CODE,control)
callee=[getattr(x,'UC_X86_REG_'+n) for n in ('RBX','RBP','R12','R13','R14','R15')]
caller=[getattr(x,'UC_X86_REG_'+n) for n in ('RAX','RCX','RDX','RSI','RDI','R8','R9','R10','R11')]
correct=True
try:
for i,args in enumerate(xs):
fault.clear();written.clear();written.update(range(rsp,rsp+8));uc.mem_write(rsp,struct.pack('<Q',end));uc.reg_write(x.UC_X86_REG_RSP,rsp);uc.reg_write(x.UC_X86_REG_EFLAGS,2)
for j,reg in enumerate(callee):uc.reg_write(reg,0x1122334400000000+j)
for j,reg in enumerate(caller):uc.reg_write(reg,0x8877665500000000+j)
for reg,value in zip((x.UC_X86_REG_EDI,x.UC_X86_REG_ESI,x.UC_X86_REG_EDX),args):uc.reg_write(reg,value)
uc.emu_start(base,end,timeout=100000,count=max(4096,len(ins)*2))
if fault or uc.reg_read(x.UC_X86_REG_RIP)!=end or uc.reg_read(x.UC_X86_REG_RSP)!=rsp+8 or any(uc.reg_read(reg)!=0x1122334400000000+j for j,reg in enumerate(callee)):
return False,False,','.join(fault) or 'Return/stack/callee-save ABI failure',instructions[0]
correct &= uc.reg_read(x.UC_X86_REG_EAX)==expected[i]
except u.UcError as error:return False,False,str(error),instructions[0]
return True,bool(correct),None,instructions[0]1234"""Experimental non-autoregressive neural compiler. Generated code may be unsafe."""from .compiler import NeuralCompiler, CompilationResult__version__ = '0.1.0.dev0'__all__ = ['NeuralCompiler', 'CompilationResult']123456789101112131415161718import argparsefrom pathlib import Pathfrom . import NeuralCompiler
def main(): p=argparse.ArgumentParser(description='Experimental x86-64 SysV neural compiler; generated bytes may be unsafe.') g=p.add_mutually_exclusive_group(required=True); g.add_argument('--source'); g.add_argument('--file',type=Path) p.add_argument('--model',default='orthagonal/neuro-compiler'); p.add_argument('--device',choices=['auto','cpu','cuda'],default='auto'); p.add_argument('--output',type=Path); p.add_argument('--verify',action='store_true') a=p.parse_args(); source=a.source if a.source is not None else a.file.read_text(encoding='utf-8') code=NeuralCompiler.from_pretrained(a.model,device=a.device).compile(source) if a.output: a.output.write_bytes(code) else: print(code.hex(' ')) if a.verify: import json from .verification import verify print(json.dumps(verify(source,code)))
if __name__=='__main__': main()1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586from dataclasses import dataclassfrom pathlib import Pathimport hashlibimport jsonimport warningsimport torchfrom safetensors.torch import load_filefrom . import neurocc as ncfrom .neurocc_live_v2 import NeuralCompiler as Pipeline, raw_bytesfrom .neurocc_ast import ASTStagefrom .neurocc_ir_unfolded import IRStagefrom .neurocc_isel_v2 import ISELStageV2from .neurocc_regalloc_v2 import RegisterStageV2from .neurocc_binary import BinaryStage
@dataclassclass CompilationResult: machine_code: bytes ast: dict ssa: tuple virtual_mir: tuple physical_mir: tuple
class NeuralCompiler: """Load frozen V2 stages; compile without a parser, assembler, or native execution.""" @classmethod def from_pretrained(cls, model_id='orthagonal/neuro-compiler', device='auto', revision=None): root=Path(model_id) if not root.is_dir(): from huggingface_hub import snapshot_download root=Path(snapshot_download(str(model_id),revision=revision,allow_patterns=['manifest.json','config.json','weights/*.safetensors'])) self=cls(); self.root=root try: self.manifest=json.loads((root/'manifest.json').read_text()) except FileNotFoundError as e: raise FileNotFoundError(f'Missing release manifest in {root}') from e m=self.manifest if m['architecture']!='NeuroCC V2' or m['spec']['depths']!=[6] or m['spec']['revision']!='0576a1bc0ae53f21860e905e081807bd7ff4a4c7': raise ValueError('Incompatible compiler architecture or backbone revision') self.spec=m['spec']; self.dev=nc.device() if device=='auto' else torch.device(device) if self.dev.type not in ('cpu','cuda'): raise ValueError('Only CPU and CUDA inference are supported') if self.dev.type=='cuda' and not torch.cuda.is_available(): raise ValueError('CUDA requested but unavailable') stages=[] for name,factory,mode in zip(('ast','ssa','isel','regalloc','binary'),(ASTStage,IRStage,ISELStageV2,RegisterStageV2,BinaryStage),('deps','deps','discrete_copy','aligned_copy','copy')): entry=m['stages'][name]; path=root/'weights'/f'{name}.safetensors' if not path.is_file(): raise FileNotFoundError(f'Missing stage weights: {path}') if hashlib.sha256(path.read_bytes()).hexdigest()!=entry['sha256']: raise ValueError(f'Weight integrity check failed: {name}') if entry['config']['mode']!=mode or entry['config']['width']!=128: raise ValueError(f'Incompatible stage configuration: {name}') stage=factory(entry['config']); stage.load_state_dict(load_file(str(path)),strict=True) if sum(p.numel() for p in stage.parameters())!=entry['parameters']: raise ValueError(f'Parameter count mismatch: {name}') stages.append(stage) self.tokenizer=nc.tokenizer_for(self.spec) bb=nc.Backbone(self.spec,self.dev) self.model=Pipeline(bb,*stages,self.dev).to(self.dev).eval() warnings.warn('Experimental neural compiler: generated machine code may be incorrect or unsafe. No native execution or formal verification is performed.',UserWarning,stacklevel=2) return self
@torch.inference_mode() def predict(self,sources): """Return raw byte IDs and stage tensors for reproducibility tools.""" if isinstance(sources,str): raise TypeError('Expected a sequence of source strings') if not sources: raise ValueError('Empty batch') for source in sources: if not isinstance(source,str) or not source.strip(): raise ValueError('Source must be a nonempty string') if len(source.encode('utf-8'))>192: raise ValueError('Source exceeds the trained 192-byte source capacity') import re if not re.fullmatch(r'[\x20-\x7e\r\n\t]+',source) or re.search(r'[/%=<>!~?:\[\]]|\b(if|while|for|goto|switch)\b',source): raise ValueError('Unsupported source characters or control flow; see the trained grammar') try: ids,mask=nc.tokenize(self.tokenizer,sources,self.spec['tokens']) except RuntimeError as e: raise ValueError(f'Source exceeds the trained {self.spec["tokens"]}-token limit; no truncation performed') from e return self.model.stages(ids.to(self.dev),mask.to(self.dev))
def compile_batch(self,sources,return_intermediates=False,batch_size=32): if isinstance(sources,str): raise TypeError('Expected a sequence of source strings') sources=list(sources) if batch_size<1: raise ValueError('batch_size must be positive') results=[] for i in range(0,len(sources),batch_size): bp,stages=self.predict(sources[i:i+batch_size]); a,h,ip,m,mp,r,rp=stages nodes=self.model.ast.node(a.float()).argmax(-1) if return_intermediates else None for j,row in enumerate(bp[-1]): code=raw_bytes(row.cpu()) if code is None: raise ValueError(f'Malformed neural byte output at batch index {i+j}: invalid EOS, padding, or byte value') results.append(CompilationResult(code,{'nodes':nodes[j].cpu(),'features':a[j].cpu()},tuple(x[j].cpu() for x in ip),tuple(x[j].cpu() for x in mp),tuple(x[j].cpu() for x in rp)) if return_intermediates else code) return results
def compile(self,source,return_intermediates=False): return self.compile_batch([source],return_intermediates=return_intermediates)[0]123456789101112131415161718192021222324252627282930313233343536373839404142434445464748from __future__ import annotations
import torch
from torch import nn
SRC, OUT, PAD, EOS = 192, 64, 256, 257
def device(): return torch.device('cuda' if torch.cuda.is_available() else 'cpu')
def amp(dev): return torch.autocast(dev.type,dtype=torch.float16,enabled=dev.type=='cuda')
def tokenizer_for(spec):
from transformers import AutoTokenizer
tok=AutoTokenizer.from_pretrained(spec['backbone'],revision=spec['revision'],trust_remote_code=False)
if tok.pad_token_id is None: tok.pad_token=tok.eos_token
tok.padding_side='right'; return tok
def tokenize(tok,sources,tokens):
result=tok(sources,add_special_tokens=False,padding='max_length',max_length=tokens,truncation=False,return_tensors=None)
# HF does not truncate; check before converting ragged lists into a tensor.
if any(len(row)!=tokens for row in result['input_ids']): raise RuntimeError(f'Source exceeds --tokens {tokens}; increase limit and rebuild cache')
return torch.tensor(result['input_ids'],dtype=torch.long),torch.tensor(result['attention_mask'],dtype=torch.bool)
class Backbone(nn.Module):
"""Use AutoModel (not AutoModelForCausalLM). Depth k = output of k blocks.
Intermediate features are raw block output; full depth has Qwen final norm.
Truncated inference uses identical features to full-model caching.
"""
def __init__(self,spec,dev):
super().__init__()
from transformers import AutoModel
self.net=AutoModel.from_pretrained(spec['backbone'],revision=spec['revision'],trust_remote_code=False,torch_dtype=torch.float16 if dev.type=='cuda' else torch.float32)
self.depths=sorted(spec['depths']); self.full_depth=len(self.net.layers); self.hidden=self.net.config.hidden_size
depth=max(self.depths)
if depth>self.full_depth: raise RuntimeError(f'Model only has {self.full_depth} blocks')
# Remove unused blocks physically, avoiding their computation and resident weights.
self.net.layers=nn.ModuleList(list(self.net.layers)[:depth])
self.net.config.num_hidden_layers=depth
if depth<self.full_depth: self.net.norm=nn.Identity()
self.net.requires_grad_(False); self.net.to(dev).eval()
def forward(self,ids,mask):
if max(self.depths)==0: return (self.net.get_input_embeddings()(ids),)
# HF returns input embeddings, intermediate block outputs, and final norm output.
if len(self.depths)==1:
return (self.net(input_ids=ids,attention_mask=mask,use_cache=False,return_dict=True).last_hidden_state,)
states=self.net(input_ids=ids,attention_mask=mask,use_cache=False,output_hidden_states=True,return_dict=True).hidden_states
return tuple(states[k] for k in self.depths)123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102from __future__ import annotations
import math
import torch
from torch import nn
CLASSES = ['absent', '+', '-', '*', '^', '&', '|', 'a', 'b', 'c', *[f'{i}u' for i in range(1,64)]]
SLOTS = 15
def tree_depth(i): return (i+1).bit_length()-1
def tree_paths():
return [bin(i+1)[3:] for i in range(SLOTS)]
def tree_relations():
"""Fixed, directed relations. No target-tree information enters attention."""
paths = tree_paths(); keys = []
for p in paths:
for q in paths:
k = 0
while k < min(len(p),len(q)) and p[k] == q[k]: k += 1
up, down = len(p)-k, len(q)-k
# Distinguish ancestor/descendant distances and left/right branches.
keys.append((up, down, p[k:k+1], q[k:k+1]))
vocab = {v:i for i,v in enumerate(sorted(set(keys)))}
return torch.tensor([vocab[k] for k in keys]).reshape(SLOTS,SLOTS), len(vocab)
class Block(nn.Module):
def __init__(self,d,heads,dropout,self_attention,tree=False):
super().__init__(); self.heads=heads
self.cross=nn.MultiheadAttention(d,heads,dropout=dropout,batch_first=True)
self.cn=nn.LayerNorm(d); self.sn=nn.LayerNorm(d); self.fn=nn.LayerNorm(d)
self.self_attn=nn.MultiheadAttention(d,heads,dropout=dropout,batch_first=True) if self_attention else None
if tree:
rel,n=tree_relations(); self.register_buffer('relations',rel,persistent=False)
self.bias=nn.Embedding(n,heads); nn.init.zeros_(self.bias.weight)
else: self.bias=None
self.ff=nn.Sequential(nn.Linear(d,4*d),nn.GELU(),nn.Dropout(dropout),nn.Linear(4*d,d))
self.drop=nn.Dropout(dropout)
def forward(self,q,m,mask):
z=self.cn(q); q=q+self.drop(self.cross(z,m,m,key_padding_mask=~mask,need_weights=False)[0])
if self.self_attn is not None:
z=self.sn(q); bias=None
if self.bias is not None:
bias=self.bias(self.relations).permute(2,0,1).unsqueeze(0).expand(len(q),-1,-1,-1).reshape(-1,SLOTS,SLOTS).to(z.dtype)
q=q+self.drop(self.self_attn(z,z,z,attn_mask=bias,need_weights=False)[0])
return q+self.drop(self.ff(self.fn(q)))
class ASTStage(nn.Module):
"""encode() is the reusable continuous compiler stage, independent of all labels."""
def __init__(self,cfg):
super().__init__(); self.cfg=dict(cfg); d=cfg['width']; mode=cfg['mode']; heads=cfg['heads']; drop=cfg['dropout']
self.project=nn.Sequential(nn.Linear(cfg['hidden'],d),nn.LayerNorm(d))
self.query=nn.Parameter(torch.randn(SLOTS,d)*.02)
self.tree=mode in ('tree','span','deps','recursive')
if self.tree:
self.depth_emb=nn.Embedding(4,d); self.path_emb=nn.Embedding(6,d)
nn.init.normal_(self.depth_emb.weight,std=.02); nn.init.normal_(self.path_emb.weight,std=.02)
p=torch.zeros(SLOTS,6)
for i,path in enumerate(tree_paths()):
for j,s in enumerate(path): p[i,2*j+int(s)]=1
self.register_buffer('paths',p,persistent=False)
self.register_buffer('depths',torch.tensor([tree_depth(i) for i in range(SLOTS)]),persistent=False)
if mode=='recursive':
self.blocks=nn.ModuleList([Block(d,heads,drop,True) for _ in range(cfg['layers'])])
self.child=nn.Sequential(nn.Linear(d,d),nn.GELU(),nn.LayerNorm(d))
self.side=nn.Embedding(2,d)
else:
self.blocks=nn.ModuleList([Block(d,heads,drop,mode!='cross',self.tree) for _ in range(1 if mode=='cross' else cfg['layers'])])
self.norm=nn.LayerNorm(d); self.node=nn.Linear(d,len(CLASSES))
if mode in ('span','deps'):
self.span_q=nn.ModuleList([nn.Linear(d,d,bias=False) for _ in range(2)])
self.span_k=nn.ModuleList([nn.Linear(d,d,bias=False) for _ in range(2)])
else: self.span_q=None
self.dep=nn.Linear(d,3) if mode=='deps' else None
def _encode(self,features,mask):
m=self.project(features.float()); mask=mask.bool(); base=self.query
if self.tree: base=base+self.depth_emb(self.depths)+self.paths@self.path_emb.weight
if self.cfg['mode']=='recursive':
levels=[]; q=base[:1].unsqueeze(0).expand(len(m),-1,-1)
for depth in range(4):
if depth:
n=2**depth; start=n-1
q=self.child(levels[-1]).repeat_interleave(2,dim=1)+self.side(torch.arange(n,device=m.device)%2)[None]+base[start:start+n][None]
for block in self.blocks: q=block(q,m,mask)
levels.append(q)
q=torch.cat(levels,dim=1)
else:
q=base.unsqueeze(0).expand(len(m),-1,-1)
for block in self.blocks: q=block(q,m,mask)
return self.norm(q),m
def encode(self,features,mask): return self._encode(features,mask)[0]
def forward(self,features,mask):
h,m=self._encode(features,mask); out={'nodes':self.node(h)}
if self.span_q is not None:
z=[(q(h)@k(m).transpose(1,2))/math.sqrt(h.shape[-1]) for q,k in zip(self.span_q,self.span_k)]
out['spans']=torch.stack(z,dim=2).masked_fill(~mask.bool()[:,None,None,:],-1e4)
if self.dep is not None: out['deps']=self.dep(h)
return out1234567891011121314151617181920212223242526272829303132333435363738from __future__ import annotations
import random
import struct
MASK=0xffffffff
def evaluate(op,args,values,x):
results=[]
for i,k in enumerate(op):
def get(j):
a=args[i][j]
return values[i][j] if a==12 else x[a-1] if 1<=a<=3 else results[a-4]
a=get(0)
if k==7: return a
b=get(1); results.append((a+b,a-b,a*b,a^b,a&b,a|b)[k-1]&MASK)
raise ValueError('no ret')
def samples(n):
edge=[(0,0,0),(1,1,1),(MASK,MASK,MASK),(0,MASK,1),(MASK,0,1),(1,0,MASK),(0x80000000,0x7fffffff,0x55555555),(0xaaaaaaaa,0x55555555,0x80000000)]
rng=random.Random(971); return edge[:n]+[tuple(rng.getrandbits(32) for _ in range(3)) for _ in range(max(0,n-len(edge)))]
def verify_binary(raw,row,xs):
from unicorn import Uc, UC_ARCH_X86, UC_MODE_64, UC_PROT_READ, UC_PROT_WRITE, UC_PROT_EXEC
from unicorn.x86_const import UC_X86_REG_RSP, UC_X86_REG_RIP, UC_X86_REG_EAX, UC_X86_REG_EDI, UC_X86_REG_ESI, UC_X86_REG_EDX, UC_X86_REG_RAX, UC_X86_REG_RBX, UC_X86_REG_RCX, UC_X86_REG_RBP, UC_X86_REG_R8, UC_X86_REG_R9, UC_X86_REG_R10, UC_X86_REG_R11, UC_X86_REG_R12, UC_X86_REG_R13, UC_X86_REG_R14, UC_X86_REG_R15, UC_X86_REG_RDI, UC_X86_REG_RSI, UC_X86_REG_RDX, UC_X86_REG_EFLAGS
base=0x100000; stack=0x200000; size=0x10000; stop=base+0x1000
if len(raw)>=0x1000: raise ValueError('function exceeds emulator code page')
uc=Uc(UC_ARCH_X86,UC_MODE_64); uc.mem_map(base,0x2000,UC_PROT_READ|UC_PROT_WRITE|UC_PROT_EXEC); uc.mem_write(base,raw); uc.mem_protect(base,0x2000,UC_PROT_READ|UC_PROT_EXEC); uc.mem_map(stack,size,UC_PROT_READ|UC_PROT_WRITE)
rsp=stack+size//2-8
regs=(UC_X86_REG_RAX,UC_X86_REG_RBX,UC_X86_REG_RCX,UC_X86_REG_RBP,UC_X86_REG_R8,UC_X86_REG_R9,UC_X86_REG_R10,UC_X86_REG_R11,UC_X86_REG_R12,UC_X86_REG_R13,UC_X86_REG_R14,UC_X86_REG_R15,UC_X86_REG_RDI,UC_X86_REG_RSI,UC_X86_REG_RDX)
for x in xs:
for reg in regs: uc.reg_write(reg,0)
uc.reg_write(UC_X86_REG_EFLAGS,2); uc.mem_write(rsp-4096,b'\0'*8192); uc.mem_write(rsp,struct.pack('<Q',stop)); uc.reg_write(UC_X86_REG_RSP,rsp)
for reg,v in zip((UC_X86_REG_EDI,UC_X86_REG_ESI,UC_X86_REG_EDX),x): uc.reg_write(reg,v)
uc.emu_start(base,stop,count=512)
actual=uc.reg_read(UC_X86_REG_EAX); expected=evaluate(*row[1:],x)
if uc.reg_read(UC_X86_REG_RIP)!=stop or uc.reg_read(UC_X86_REG_RSP)!=rsp+8 or actual!=expected: raise ValueError(f'row {row[0]}: emulator mismatch on {x}, {actual} != {expected}').gitattributes+1-1
.gitignore+5-9
ARCHITECTURE.md+5-52
CHANGELOG.md+8-17
README.md+80-279
REPRODUCIBILITY.md+12-67
SHA256SUMSAdded+53
THIRD_PARTY_NOTICES.md+19-17
config.json+5-5
dist/neuro_compiler-0.3.0-py3-none-any.whlAdded
evaluation/README.mdDeleted-19
evaluation/benchmark.jsonDeleted-294
evaluation/cases.jsonAdded
evaluation/clean_final_wheel.jsonAdded+11
evaluation/contract_tests.jsonAdded+9
evaluation/evaluate.pyAdded+19
evaluation/export_parity.jsonAdded+14
evaluation/fresh_package_parity.jsonAdded+10
evaluation/portability.json+19-17
evaluation/qualification.jsonAdded
evaluation/qualified_codes.jsonAdded+602
evaluation/regression.jsonDeleted-275
evaluation/test.jsonDeleted-132
evaluation/validation.jsonDeleted-133
examples/compile_example.pyDeleted-11
examples/eight_operations.cppAdded+1
manifest.json
neuro_compiler/__init__.py+3-3
neuro_compiler/_verify_worker.pyAdded+14
neuro_compiler/backbone.pyAdded+74
neuro_compiler/backend/__init__.pyAdded+1
neuro_compiler/backend/allocation_constants.pyAdded+2
neuro_compiler/backend/allocator.pyAdded+120
neuro_compiler/backend/boundary.pyAdded+49
neuro_compiler/backend/canonical.pyAdded+125
neuro_compiler/backend/encoder.pyAdded+53
neuro_compiler/backend/graph.pyAdded+90
neuro_compiler/backend/physical.pyAdded+11
neuro_compiler/backend/policy.pyAdded+44
neuro_compiler/backend/resident.pyAdded+85
neuro_compiler/backend/stack.pyAdded+153
neuro_compiler/cli.py+17-20
neuro_compiler/compiler.py+121-110
neuro_compiler/emulation.pyAdded+40
neuro_compiler/legacy/__init__.pyDeleted-4
neuro_compiler/legacy/cli.pyDeleted-18
neuro_compiler/legacy/compiler.pyDeleted-86
neuro_compiler/legacy/neurocc.pyDeleted-48
neuro_compiler/legacy/neurocc_ast.pyDeleted-102
neuro_compiler/legacy/neurocc_backend_trace.pyDeleted-38