DeepGrove logo

Maple-Preview

MaplevPreviewCurrent
byDeepGroveDeepGrove(ai lab)
Released August 8, 2026
Context131.1K tokens
CategoryLarge Language Model

About Maple-Preview

Maple-Preview is DeepGrove’s open-source 20B-A1B ternary-weight reasoning LLM for efficient on-device inference. The model card reports 20.2B total parameters, 1.49B active parameters, a 131,072-token context window, and 5.31 GB checkpoint size. The model card specifies 131,072 tokens of context but does not establish a separate maximum output-token limit.

Capabilities

textreasoningcodeon device inference

Input Modalities

text

Output Modalities

text

Technical Details

API Identifier
deepgrove/maple-preview
Category
Large Language Model
Context Window
131,072 tokens

Tags

llmreasoning-modelon-device-aiternary-weightslow-precisionmoe

Run this model yourself

Local and cloud setup for Maple-Preview, with exact configurations, sources and clear evidence limits.

Find a model for your hardware
Local hardwareDocumented setupSources checked Oct 17, 2026

Host Maple Preview reasoning and code on a private Apple M4 with publisher MLX dense decoding

Run the complete selected publisher Maple representation with its own template, retained reasoning and two-turn code history. The private fixed-task service requires true EOS, closed thinking and complete input budgets. All four packed files remain verified, with optional approximate FlashHead disabled. Capacity, quality and speed remain unmeasured.

Hardware
Existing Apple M4 mini configured with vendor 32 GB unified memory
Runtime
Publisher Maple packed MLX dense-head runtime Publisher mlx-lm commit 151f62d; MLX 0.32.0; native kernel wheel 0.1.0; Transformers 5.11.0 · Metal
Model format
Publisher packed MLX safetensors · Publisher ternary 2-bit experts, per-row scaling and 4-bit embedding/head; all four source files retained, optional FlashHead disabled · Publisher ternary 2-bit experts, per-row scaling and 4-bit embedding/head; all four source files retained, optional FlashHead disabled
Workload
8,192 token context · 1 concurrent

Based on source documentation; this setup has not been executed by OpenTools. Memory: unknown. No compatible measurement available.

Read the complete setup guide

Before you start

  • Use an existing Apple M4 mini with vendor 32 GB unified memory, macOS 26.2 or newer and Python 3.12. Allocate 40 GiB local disk with at least 25 GiB free before downloads. Exact usable RAM and native fit remain unmeasured.
  • Review the exact publisher MIT and MLX runtime notices. No license acceptance, model download, native execution or legal clearance was performed by the author. Provider API byte equivalence and native versus frozen release dates are not established.
  • The exact publisher packed representation differs from native CUDA in precision, global RoPE and context. Its complete four-file package is retained and approximate FlashHead is disabled; no numerical equivalence or headline speed claim is made.
  • 8,192 total positions and 4,096 output per turn are bounded author choices. All actual retained history is counted with no truncation. Full native context, tools, other samplers and production service remain separate open scopes.

Exact model and requirements

Artifact:
DeepGrove AI / Maple Preview publisher packed ternary MLX, dense decoding · checkpoint deepgrove/maple-preview-2bit-mlx
Publisher revision:
e8be321fb325c40beb7b621bd98e8e57a324ec42
Artifact digest:
No composite whole-package digest is published. Every required file has exact size and LFS SHA-256 or native Git blob SHA-1 in the embedded mandatory manifest.
Download size:
4.95 GiB
Memory requirement (unknown):
Unknown — No complete native runtime, cache, activation, loading-buffer or OS peak was measured.
System RAM / disk:
Unknown / Unknown
Placement:
single device. One selected accelerator; all layers and experts remain present. Complete model and caches use the integrated GPU/unified pool, with no disk or CPU weight offload.
KV cache:
Native MLX cache dtype follows packed model activations; exact realized dtype/peak is not measured
Workload:
8,192 token context; Unknown; Unknown; concurrency 1; batch 1; cache cold; repetitions Unknown.
Tokenizer:
Exact native Maple tokenizer and 3,292-byte publisher Jinja, with no added BOS · e8be321fb325c40beb7b621bd98e8e57a324ec42
Sampling / reasoning:
Dense greedy argmax is an author-selected fixed-task setting. Native packed dense head is selected explicitly; no FlashHead approximation or performance transfer. The publisher template opens thinking. Preserve complete reasoning_content and final answer in the second turn. Require exactly closed thinking and true raw native EOS; reject partial/reopened/tool/control output. 8,192 total context and 4,096 output cap are walkthrough bounds, not the native full-context recommendation.
Runtime prerequisites:
macOS 26.2 or newer, arm64, Python 3.12; Apple Metal GPU and exact MLX native ABI.

Official artifact · License

Exact publisher MIT license is archived. Retain its copyright and permission notice in copies or substantial portions; software is provided without warranty or liability. The separate publisher MLX fork is also MIT. No terms are accepted or legal clearance granted by this guide.

  • README.md · 0 GiB · revision e8be321fb325c40beb7b621bd98e8e57a324ec42
  • added_tokens.json · 0 GiB · revision e8be321fb325c40beb7b621bd98e8e57a324ec42
  • chat_template.jinja · 0 GiB · revision e8be321fb325c40beb7b621bd98e8e57a324ec42
  • config.json · 0 GiB · revision e8be321fb325c40beb7b621bd98e8e57a324ec42
  • maple.py · 0 GiB · revision e8be321fb325c40beb7b621bd98e8e57a324ec42
  • merges.txt · 0 GiB · revision e8be321fb325c40beb7b621bd98e8e57a324ec42
  • model.safetensors.index.json · 0 GiB · revision e8be321fb325c40beb7b621bd98e8e57a324ec42
  • special_tokens_map.json · 0 GiB · revision e8be321fb325c40beb7b621bd98e8e57a324ec42
  • tokenizer.json · 0.01 GiB · revision e8be321fb325c40beb7b621bd98e8e57a324ec42
  • tokenizer_config.json · 0 GiB · revision e8be321fb325c40beb7b621bd98e8e57a324ec42
  • vocab.json · 0 GiB · revision e8be321fb325c40beb7b621bd98e8e57a324ec42
  • 5314328134 serialized weight bytes do not include complete runtime memory.
  • All experts, caches, native extension workspaces, activations, loading buffers and OS overhead remain additional and unmeasured.

One-time setup and hardware

hardware
Unknown — Existing machine acquisition and incremental setup cost are unknown.
Existing machine acquisition and incremental setup cost are unknown. Tax: unknown.
setup
Unknown — Reader setup time and labor cost are unmeasured.
Reader setup time and labor cost are unmeasured. Tax: unknown.

Recurring costs

electricity
Unknown — Actual wall power, tariff and powered hours are unknown; no TDP conversion.
Actual wall power, tariff and powered hours are unknown; no TDP conversion. Tax: unknown.
storage
Unknown — Incremental local storage cost is unknown.
Incremental local storage cost is unknown. Tax: unknown.
egress
Unknown — Actual transfers and usage charges remain unknown.
Actual transfers and usage charges remain unknown. Tax: unknown.
administration
Unknown — Maintenance time and rate are unknown.
Maintenance time and rate are unknown. Tax: unknown.

Install the runtime

  1. 1. Prepare the existing reader machine

    Use the exact platform in prerequisites. Record actual capacity before downloading. These are planning checks, not measured model fit.

    Command
    set -eu
    mkdir -p "$HOME/maple-preview-local-m4-32gb-mlx-dense"
    cd "$HOME/maple-preview-local-m4-32gb-mlx-dense"
    test "$(uname -m)" = arm64
    sw_vers
    sysctl -n hw.memsize
    command -v python3.12
    python3.12 -m venv .venv
    python3.12 - <<'PYPREFLIGHT'
    import shutil
    assert shutil.disk_usage('.').free >= 26843545600
    print('Reader prescribed free space passed; fit remains unmeasured.')
    PYPREFLIGHT

    Expected result: An existing compatible machine, Python 3.12 environment and prescribed free space are recorded. Stop on platform, GPU, driver or disk failure.

Download the model

  1. 1. Write the mandatory streaming asset checker (1/1)

    Write this exact source section in order. Writing source does not execute native code.

    Command
    set -eu
    cd "$HOME/maple-preview-local-m4-32gb-mlx-dense"
    cat > reader_assets.py <<'MAPLEFILE'
    """Reader-only exact full Maple asset verification; no native imports."""
    import hashlib,json,pathlib,sys,urllib.request
    ROOT=pathlib.Path(__file__).resolve().parent
    PINS={'cuda':('deepgrove/maple-preview','ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07','3ab6ce508a608d0af564c6683497eb7d166178d8c992e33dd41404c9e2be92eb',23),'mlx':('deepgrove/maple-preview-2bit-mlx','e8be321fb325c40beb7b621bd98e8e57a324ec42','d236df54f11ada042e099c2ae15942b246c611420495ee39ac3a470a38b5a182',15)}
    def manifest(mode):
        repo,pin,digest,count=PINS[mode];data=(ROOT/'assets.json').read_bytes()
        if hashlib.sha256(data).hexdigest()!=digest:raise ValueError('manifest_hash')
        m=json.loads(data)
        if m['mode']!=mode or m['repo']!=repo or m['revision']!=pin or len(m['files'])!=count:raise ValueError('manifest_identity')
        return m
    
    def check(path,row):
        h=hashlib.sha256()if row['algorithm']=='sha256'else hashlib.sha1();n=0
        if row['algorithm']=='git-sha1':h.update(b'blob '+str(row['bytes']).encode()+b'\0')
        with path.open('rb')as f:
            for b in iter(lambda:f.read(1024*1024),b''):n+=len(b);h.update(b)
        if n!=row['bytes']or h.hexdigest()!=row['digest']:raise ValueError('asset_integrity_'+row['path'])
    
    def verify(mode,download=False):
        m=manifest(mode)
        for category,dirname in [('files','model'),('runtime_files','runtime')]:
            root=ROOT/dirname;root.mkdir(exist_ok=True)
            for row in m[category]:
                if pathlib.PurePosixPath(row['path']).name!=row['path']:raise ValueError('asset_path')
                path=root/row['path']
                if download and not path.exists():
                    temp=path.with_suffix(path.suffix+'.partial');n=0
                    with urllib.request.urlopen(row['url'],timeout=120)as src,temp.open('wb')as dst:
                        for chunk in iter(lambda:src.read(1024*1024),b''):
                            n+=len(chunk)
                            if n>row['bytes']:raise ValueError('download_size')
                            dst.write(chunk)
                    check(temp,row);temp.replace(path)
                check(path,row)
        index=json.loads((ROOT/'model/model.safetensors.index.json').read_text())['weight_map'];parts={x['path']for x in m['files']if x['path'].endswith('.safetensors')}
        # Publisher MLX index covers the three main parts; FlashHead is a mandatory
        # separately shipped fourth asset, loaded by publisher model*.safetensors glob.
        indexed=parts-({'model-flashhead.safetensors'}if mode=='mlx'else set())
        if set(index.values())!=indexed:raise ValueError('complete_weight_index')
        print('All exact native or publisher-packed files verified; no fit or numerical equivalence proof.')
    if __name__=='__main__':
        if len(sys.argv)!=3 or sys.argv[1]not in PINS or sys.argv[2]not in ('download','verify'):raise SystemExit('Use cuda|mlx download|verify')
        verify(sys.argv[1],sys.argv[2]=='download')
    MAPLEFILE

    Expected result: The exact source section is written. Continue through every section before verification.

  2. 2. Write the exact complete publisher asset manifest (1/1)

    Write this exact source section in order. Writing source does not execute native code.

    Command
    set -eu
    cd "$HOME/maple-preview-local-m4-32gb-mlx-dense"
    cat > assets.json <<'MAPLEFILE'
    {"mode":"mlx","repo":"deepgrove/maple-preview-2bit-mlx","revision":"e8be321fb325c40beb7b621bd98e8e57a324ec42","files":[{"path":"README.md","bytes":107,"algorithm":"git-sha1","digest":"8cec12c472d936a3b1e0043e2cabe97450156788","url":"https://huggingface.co/deepgrove/maple-preview-2bit-mlx/resolve/e8be321fb325c40beb7b621bd98e8e57a324ec42/README.md"},{"path":"added_tokens.json","bytes":707,"algorithm":"git-sha1","digest":"b54f9135e44c1e81047e8d05cb027af8bc039eed","url":"https://huggingface.co/deepgrove/maple-preview-2bit-mlx/resolve/e8be321fb325c40beb7b621bd98e8e57a324ec42/added_tokens.json"},{"path":"chat_template.jinja","bytes":3292,"algorithm":"git-sha1","digest":"b5509b8aef363d7262fb86370db1eb41f554959b","url":"https://huggingface.co/deepgrove/maple-preview-2bit-mlx/resolve/e8be321fb325c40beb7b621bd98e8e57a324ec42/chat_template.jinja"},{"path":"config.json","bytes":2710,"algorithm":"git-sha1","digest":"f71e7d2c090c3da042828e4f6b6fc292f7e04cb8","url":"https://huggingface.co/deepgrove/maple-preview-2bit-mlx/resolve/e8be321fb325c40beb7b621bd98e8e57a324ec42/config.json"},{"path":"maple.py","bytes":71017,"algorithm":"git-sha1","digest":"7190efe661bef2df8aff90ebd42962e37129f421","url":"https://huggingface.co/deepgrove/maple-preview-2bit-mlx/resolve/e8be321fb325c40beb7b621bd98e8e57a324ec42/maple.py"},{"path":"merges.txt","bytes":1671853,"algorithm":"git-sha1","digest":"31349551d90c7606f325fe0f11bbb8bd5fa0d7c7","url":"https://huggingface.co/deepgrove/maple-preview-2bit-mlx/resolve/e8be321fb325c40beb7b621bd98e8e57a324ec42/merges.txt"},{"path":"model-00001-of-00003.safetensors","bytes":2162084350,"algorithm":"sha256","digest":"1444bbc92e2842e9a612c32b6d6f30f0f026a107c8094a4ac273819a22eb84e1","url":"https://huggingface.co/deepgrove/maple-preview-2bit-mlx/resolve/e8be321fb325c40beb7b621bd98e8e57a324ec42/model-00001-of-00003.safetensors"},{"path":"model-00002-of-00003.safetensors","bytes":2187444586,"algorithm":"sha256","digest":"d051e252c46570f989b65c5e037b94402d22f892e96dc91f5fb83dbb06b50d30","url":"https://huggingface.co/deepgrove/maple-preview-2bit-mlx/resolve/e8be321fb325c40beb7b621bd98e8e57a324ec42/model-00002-of-00003.safetensors"},{"path":"model-00003-of-00003.safetensors","bytes":958711742,"algorithm":"sha256","digest":"85c97321214c864597562d5b7286b9e8a0dac36e5abd622f11f9b8425ee88705","url":"https://huggingface.co/deepgrove/maple-preview-2bit-mlx/resolve/e8be321fb325c40beb7b621bd98e8e57a324ec42/model-00003-of-00003.safetensors"},{"path":"model-flashhead.safetensors","bytes":6087456,"algorithm":"sha256","digest":"67d1af06cd8ec6f434ea57b9e066dedf1f7572a95d1af14c56a525cb8b7b03cd","url":"https://huggingface.co/deepgrove/maple-preview-2bit-mlx/resolve/e8be321fb325c40beb7b621bd98e8e57a324ec42/model-flashhead.safetensors"},{"path":"model.safetensors.index.json","bytes":40054,"algorithm":"git-sha1","digest":"6bbc2e03c0de04a8feca573322479e1a3ea78738","url":"https://huggingface.co/deepgrove/maple-preview-2bit-mlx/resolve/e8be321fb325c40beb7b621bd98e8e57a324ec42/model.safetensors.index.json"},{"path":"special_tokens_map.json","bytes":613,"algorithm":"git-sha1","digest":"ac23c0aaa2434523c494330aeb79c58395378103","url":"https://huggingface.co/deepgrove/maple-preview-2bit-mlx/resolve/e8be321fb325c40beb7b621bd98e8e57a324ec42/special_tokens_map.json"},{"path":"tokenizer.json","bytes":11422654,"algorithm":"sha256","digest":"aeb13307a71acd8fe81861d94ad54ab689df773318809eed3cbe794b4492dae4","url":"https://huggingface.co/deepgrove/maple-preview-2bit-mlx/resolve/e8be321fb325c40beb7b621bd98e8e57a324ec42/tokenizer.json"},{"path":"tokenizer_config.json","bytes":5432,"algorithm":"git-sha1","digest":"f4b91854389fd13e964c436e576a0011e588104b","url":"https://huggingface.co/deepgrove/maple-preview-2bit-mlx/resolve/e8be321fb325c40beb7b621bd98e8e57a324ec42/tokenizer_config.json"},{"path":"vocab.json","bytes":2776833,"algorithm":"git-sha1","digest":"4783fe10ac3adce15ac8f358ef5462739852c569","url":"https://huggingface.co/deepgrove/maple-preview-2bit-mlx/resolve/e8be321fb325c40beb7b621bd98e8e57a324ec42/vocab.json"}],"runtime_files":[{"path":"mlx_lm_maple_kernels-0.1.0-cp312-cp312-macosx_26_0_arm64.whl","bytes":49175,"algorithm":"git-sha1","digest":"a6cd4f72c2ef5b8d6d8a901061c4ad5c8b1e39cc","url":"https://huggingface.co/deepgrove/maple-preview-2bit-mlx/resolve/ad3e2a0a772a2131271483ba6770a7cbb9846b6f/wheels/mlx_lm_maple_kernels-0.1.0-cp312-cp312-macosx_26_0_arm64.whl"}]}
    MAPLEFILE

    Expected result: The exact source section is written. Continue through every section before verification.

  3. 3. Verify the manifest and download every required asset

    Only the reader runs this download. All model parts, tokenizer auxiliaries, remote code and the Apple kernel wheel are mandatory. Existing mismatched files fail closed; no byte range or alternate checkpoint is used.

    Command
    set -eu
    cd "$HOME/maple-preview-local-m4-32gb-mlx-dense"
    .venv/bin/python - <<'PYHASH'
    import hashlib,pathlib
    for n,h in [('reader_assets.py', 'e12f5b1a39737ba1649b235702ebe76404406d7422e1593c3a20b20a34fe56fe'), ('assets.json', 'd236df54f11ada042e099c2ae15942b246c611420495ee39ac3a470a38b5a182')]:
     assert hashlib.sha256(pathlib.Path(n).read_bytes()).hexdigest()==h
    PYHASH
    .venv/bin/python reader_assets.py mlx download

    Expected result: All required per-file sizes and streaming hashes pass before any native loading. This establishes exact bytes, not model quality or fit.

Configure

  1. 1. Install the exact native-facing reader runtime

    Reader installation is source-qualified and unexecuted here. Use a fresh environment; no FA3, Liger, alternate MLX fork or floating kernel build. Stop on wheel ABI, dependency or native import failure. Save actual transitive versions; this is not an executed lockfile.

    Command
    set -eu
    cd "$HOME/maple-preview-local-m4-32gb-mlx-dense"
    git clone https://github.com/deepgrove-ai/mlx-lm-deepgrove.git runtime-src
    git -C runtime-src checkout --detach 151f62d1b811bd0af7c5365ab0fbaa57e3a64113
    test "$(git -C runtime-src rev-parse HEAD)" = 151f62d1b811bd0af7c5365ab0fbaa57e3a64113
    .venv/bin/python -m pip install "https://files.pythonhosted.org/packages/0f/01/02110ceacf4efd00ec172f60b4cd42c8b1509ac50ffa65a6a77d723133aa/mlx-0.32.0-cp312-cp312-macosx_26_0_arm64.whl#sha256=8dfb577faa4dc413cfd0d6eb78f230d3b3b6169df4473e84408abdeb21346e9d" transformers==5.11.0 numpy==2.2.3 sentencepiece==0.2.1 protobuf==6.32.1 PyYAML==6.0.2 Jinja2==3.1.6
    .venv/bin/python reader_assets.py mlx verify
    .venv/bin/python -m pip install --no-deps "runtime/mlx_lm_maple_kernels-0.1.0-cp312-cp312-macosx_26_0_arm64.whl"
    .venv/bin/python -m pip install --no-deps ./runtime-src
    .venv/bin/python -m pip check
    .venv/bin/python -m pip freeze > realized-environment.txt

    Expected result: Exact native-facing versions install and pip check passes only after reader execution. Record realized versions; no compatibility or fit was measured by the author.

  2. 2. Write the complete private native reasoning service (1/3)

    Write this exact source section in order. Writing source does not execute native code.

    Command
    set -eu
    cd "$HOME/maple-preview-local-m4-32gb-mlx-dense"
    cat > maple_server.py <<'MAPLEFILE'
    """Reader-authored fixed Maple reasoning/code harness. Native imports occur only in reader startup."""
    import hashlib,hmac,json,pathlib,sys
    from http.server import BaseHTTPRequestHandler,HTTPServer
    ROOT=pathlib.Path(__file__).resolve().parent
    CONTEXT=8192;CAP=4096;EOS=151645;OPEN=151667;CLOSE=151668
    PROMPTS=['A library opens at 09:00 and closes at 17:00 on the same day. Work out its opening duration, then give a small Python function opening_hours() returning that integer. Do not execute code or call tools.','Now closing changes to 18:00 with the same opening time. Recompute and update the function. Do not execute code or call tools.']
    def native_forward(model,input_ids,cache):
        # Exact native no-mask, no-explicit-position path. Never model.generate().
        return model(input_ids=input_ids,attention_mask=None,position_ids=None,
            past_key_values=cache,use_cache=True,cache_position=None,return_dict=True,logits_to_keep=1)
    
    def parse_output(ids,text):
        if type(ids)is not list or not 1<=len(ids)<=CAP or any(type(x)is not int or x<0 for x in ids):raise ValueError('raw_output_ids')
        if ids[-1]!=EOS or ids.count(EOS)!=1 or ids.count(CLOSE)!=1 or OPEN in ids:raise ValueError('native_end_or_think')
        end=ids.index(CLOSE)
        if any(x>=151643 and x not in (OPEN,CLOSE,EOS)for x in ids):raise ValueError('unexpected_native_control_id')
        if type(text)is not str or text.count('</think>')!=1:raise ValueError('decoded_thinking_boundary')
        reasoning,answer=text.split('</think>')
        if not reasoning.strip()or not answer.strip()or any(x in reasoning+answer for x in ('<think','</think','<tool','</tool','<|','|>')):raise ValueError('nonfinal_control_or_empty')
        return reasoning,answer
    
    def checked_result(mode,d):
        if type(d)is not dict or set(d)!={'backend','turns','context_limit','output_cap','head'}or d['backend']!=mode or d['context_limit']!=CONTEXT or d['output_cap']!=CAP or d['head']!='dense':raise ValueError('result_identity')
        if type(d['turns'])is not list or len(d['turns'])!=2:raise ValueError('two_turns_required')
        for r in d['turns']:
            if type(r)is not dict or set(r)!={'reasoning','answer','input_tokens','output_tokens','stop_id'}:raise ValueError('turn_schema')
            if any(type(r[k])is not int for k in ('input_tokens','output_tokens','stop_id'))or not 1<=r['input_tokens']<=CONTEXT-CAP or not 1<=r['output_tokens']<=CAP or r['input_tokens']+r['output_tokens']>CONTEXT or r['stop_id']!=EOS:raise ValueError('turn_budget_stop')
            if any(type(r[k])is not str or not r[k].strip() or len(r[k])>65536 for k in ('reasoning','answer')):raise ValueError('turn_text')
            if any(c in r['reasoning']+r['answer']for c in ('<think','</think','<tool','</tool','<|','|>')):raise ValueError('turn_control')
        return d
    
    def publisher_native_extension(model):
        # Publisher loader executes custom_model without registering sys.modules.
        # The verified source-defined class initializer retains that module globals.
        init=model.__class__.__init__
        context=getattr(init,'__globals__',None)
        if type(context)is not dict or context.get('__name__')!=model.__class__.__module__:
            raise RuntimeError('publisher_loaded_context_required')
        native=context.get('_maple_native')
        if native is None:raise RuntimeError('pinned_publisher_kernel_required')
        return native
    
    def make_engine(mode):
        from reader_assets import verify
        verify(mode)
        path=ROOT/'model';cfg=json.loads((path/'config.json').read_text())
        if cfg['num_hidden_layers']!=24 or cfg['num_experts']!=256 or cfg['num_experts_per_tok']!=8 or cfg['sliding_window']!=512:raise RuntimeError('wrong_maple_architecture')
        if mode=='cuda':
            import torch
            from transformers import AutoTokenizer,AutoModelForCausalLM
            if torch.__version__.split('+')[0]!='2.6.0'or torch.version.cuda!='12.4'or torch.cuda.device_count()!=1 or 'H100'not in torch.cuda.get_device_name(0):raise RuntimeError('exact_cuda_runtime_required')
            # Select only the explicit FA2 fallback; FA3 is deliberately not installed.
            import importlib.util
            if importlib.util.find_spec('flash_attn_interface')is not None:raise RuntimeError('unexpected_fa3_interface')
            import flash_attn
            if flash_attn.__version__!='2.8.3':raise RuntimeError('flash_attention_version')
            import inspect
            if 'window_size'not in inspect.signature(flash_attn.flash_attn_func).parameters or importlib.util.find_spec('liger_kernel')is not None:raise RuntimeError('exact_unfused_sliding_attention_backend')
            if cfg['max_position_embeddings']!=131072 or cfg['nope_on_global_attention']is not True:raise RuntimeError('native_cuda_config')
            tok=AutoTokenizer.from_pretrained(path,local_files_only=True,trust_remote_code=False)
    MAPLEFILE

    Expected result: The exact source section is written. Continue through every section before verification.

  3. 3. Write the complete private native reasoning service (2/3)

    Write this exact source section in order. Writing source does not execute native code.

    Command
    set -eu
    cd "$HOME/maple-preview-local-m4-32gb-mlx-dense"
    cat >> maple_server.py <<'MAPLEFILE'
            model,info=AutoModelForCausalLM.from_pretrained(path,local_files_only=True,trust_remote_code=True,torch_dtype=torch.bfloat16,device_map=None,use_safetensors=True,output_loading_info=True,ignore_mismatched_sizes=False)
            keys={'missing_keys','unexpected_keys','mismatched_keys','error_msgs'}
            if type(info)is not dict or set(info)!=keys or any(info[k]for k in keys):raise RuntimeError('native_load_diagnostics')
            model=model.to('cuda:0').eval()
            if len(model.model.layers)!=24 or any(p.dtype!=torch.bfloat16 or p.device.type!='cuda' or not torch.isfinite(p).all()for p in model.parameters()):raise RuntimeError('full_native_gpu_parameters')
            def generate(ids):
                tokens=[];cache=None;current=torch.tensor([ids],dtype=torch.long,device='cuda:0')
                with torch.inference_mode():
                    for _ in range(CAP):
                        out=native_forward(model,current,cache);cache=out.past_key_values;scores=out.logits[0,-1]
                        if not torch.isfinite(scores).all():raise RuntimeError('nonfinite_native_logits')
                        token=int(torch.argmax(scores));tokens.append(token)
                        if token==EOS:break
                        current=torch.tensor([[token]],dtype=torch.long,device='cuda:0')
                return tokens,tok.decode(tokens[:-1]if tokens and tokens[-1]==EOS else tokens,skip_special_tokens=False)
        elif mode=='mlx':
            import platform,subprocess
            if platform.machine()!='arm64'or tuple(map(int,platform.mac_ver()[0].split('.')[:2]))<(26,2):raise RuntimeError('native_apple_platform')
            import mlx.core as mx
            from mlx_lm import load
            from mlx_lm.generate import stream_generate
            if mx.__version__!='0.32.0'or mx.default_device()!=mx.gpu:raise RuntimeError('exact_mlx_metal_runtime')
            if cfg['max_position_embeddings']!=128000 or cfg.get('nope_on_global_attention')is not False:raise RuntimeError('publisher_mlx_config')
            model,tok=load(str(path),model_config={'use_flash_head':False},trust_remote_code=True)
            if model.lm_head_flash is not None or len(model.model.layers)!=24:raise RuntimeError('dense_complete_maple_required')
            import importlib.metadata
            native=publisher_native_extension(model)
            if importlib.metadata.version('mlx-lm-maple-kernels')!='0.1.0'or native is None:raise RuntimeError('pinned_publisher_kernel_required')
            def sampler(logprobs):
                if bool(mx.any(mx.isnan(logprobs)))or bool(mx.any(mx.isinf(logprobs)&(logprobs>0)))or not bool(mx.any(mx.isfinite(logprobs))):raise RuntimeError('nonfinite_dense_logits')
                return mx.argmax(logprobs,axis=-1)
            def generate(ids):
                tokens=[];last=None
                for item in stream_generate(model,tok,ids,max_tokens=CAP,sampler=sampler):
                    tokens.append(item.token);last=item
                if last is None or last.finish_reason!='stop' or last.generation_tokens!=len(tokens):raise RuntimeError('native_mlx_completion')
                return tokens,tok.decode(tokens[:-1]if tokens and tokens[-1]==EOS else tokens,skip_special_tokens=False)
        else:raise ValueError('backend')
        if tok.eos_token_id!=EOS or tok.convert_tokens_to_ids('</think>')!=CLOSE:raise RuntimeError('native_token_identity')
        def engine():
            messages=[];turns=[]
            for prompt in PROMPTS:
                messages.append({'role':'user','content':prompt})
                rendered=tok.apply_chat_template(messages,tokenize=False,add_generation_prompt=True)
                ids=tok.encode(rendered,add_special_tokens=False)
                if not 1<=len(ids)<=CONTEXT-CAP:raise ValueError('full_native_history_budget')
                raw,text=generate(ids);reasoning,answer=parse_output(raw,text)
                turns.append({'reasoning':reasoning,'answer':answer,'input_tokens':len(ids),'output_tokens':len(raw),'stop_id':raw[-1]})
                messages.append({'role':'assistant','content':answer,'reasoning_content':reasoning})
            return checked_result(mode,{'backend':mode,'turns':turns,'context_limit':CONTEXT,'output_cap':CAP,'head':'dense'})
        return engine
    
    def create_server(engine,key,mode,port=9008):
        if type(key)is not str or len(key)!=64 or any(x not in '0123456789abcdef'for x in key):raise ValueError('key_format')
        class Handler(BaseHTTPRequestHandler):
            def setup(self):super().setup();self.connection.settimeout(5)
            def log_message(self,*_):pass
            def reply(self,status,d):
                data=json.dumps(d,allow_nan=False).encode()
                if len(data)>131072:status=500;data=b'{"error":"response_limit"}'
    MAPLEFILE

    Expected result: The exact source section is written. Continue through every section before verification.

  4. 4. Write the complete private native reasoning service (3/3)

    Write this exact source section in order. Writing source does not execute native code.

    Command
    set -eu
    cd "$HOME/maple-preview-local-m4-32gb-mlx-dense"
    cat >> maple_server.py <<'MAPLEFILE'
                self.send_response(status);self.send_header('Content-Type','application/json');self.send_header('Content-Length',str(len(data)));self.send_header('Connection','close');self.end_headers();self.wfile.write(data);self.close_connection=True
            def auth(self):
                values=self.headers.get_all('Authorization',[])
                return len(values)==1 and hmac.compare_digest(values[0].encode(),('Bearer '+key).encode())
            def do_GET(self):
                if not self.auth():return self.reply(401,{'error':'unauthorized'})
                if self.path!='/health':return self.reply(404,{'error':'not_found'})
                return self.reply(200,{'ready':True,'backend':mode,'context_limit':CONTEXT,'output_cap':CAP,'head':'dense'})
            def do_POST(self):
                if not self.auth():return self.reply(401,{'error':'unauthorized'})
                if self.path!='/v1/fixed-reasoning-code':return self.reply(404,{'error':'not_found'})
                lengths=self.headers.get_all('Content-Length',[])
                if self.headers.get('Transfer-Encoding')is not None or len(lengths)!=1:return self.reply(400,{'error':'framing'})
                value=lengths[0]
                if not value or len(value)>3 or any(x not in '0123456789'for x in value)or not 1<=int(value)<=128:return self.reply(413,{'error':'body_limit'})
                if self.headers.get_content_type()!='application/json':return self.reply(415,{'error':'json_required'})
                try:
                    body=self.rfile.read(int(value))
                    if len(body)!=int(value):raise ValueError('incomplete')
                    def unique(pairs):
                        d={}
                        for k,v in pairs:
                            if k in d:raise ValueError('duplicate')
                            d[k]=v
                        return d
                    d=json.loads(body.decode(),object_pairs_hook=unique,parse_constant=lambda _:(_ for _ in ()).throw(ValueError('nonfinite')))
                    if type(d)is not dict or d!={'job':'reasoning-code'}:raise ValueError('fixed_job')
                except (ValueError,UnicodeError,TimeoutError,OSError,RecursionError):return self.reply(400,{'error':'invalid_request'})
                try:return self.reply(200,checked_result(mode,engine()))
                except Exception:return self.reply(500,{'error':'native_generation_or_boundary_failure'})
        return HTTPServer(('127.0.0.1',port),Handler)
    if __name__=='__main__':
        if sys.argv[1:]not in (['cuda'],['mlx']):raise SystemExit('Use cuda or mlx')
        mode=sys.argv[1];key=(ROOT/'.api-key').read_text().strip()
        if len(key)!=64 or any(x not in '0123456789abcdef'for x in key):raise SystemExit('private_key_format')
        engine=make_engine(mode)
        with create_server(engine,key,mode)as server:server.serve_forever()
    MAPLEFILE

    Expected result: The exact source section is written. Continue through every section before verification.

  5. 5. Bind helper integrity and stable private access

    Generate a key only when absent. Every startup verifies all assets again before remote code/model loading. Keep the key private; it is never printed.

    Command
    set -eu
    cd "$HOME/maple-preview-local-m4-32gb-mlx-dense"
    umask 077
    if [ ! -e .api-key ]; then openssl rand -hex 32 > .api-key; fi
    chmod 600 .api-key
    .venv/bin/python - <<'PYCHECK'
    import hashlib,pathlib,ast
    p=pathlib.Path("maple_server.py");assert hashlib.sha256(p.read_bytes()).hexdigest()=="da4d1448e28fd704b8bad98249a657053c055caaec29415951da23966564f0dd"
    ast.parse(p.read_text())
    k=pathlib.Path(".api-key").read_text().strip();assert len(k)==64 and all(c in "0123456789abcdef" for c in k)
    PYCHECK

    Expected result: The complete helper checksum, syntax and stable key format pass without model execution.

Start the model

  1. 1. Start the serial native loopback service

    Run in the foreground. Readiness is returned only after exact native assets and full loading checks pass. Native compute has no hard cancellation deadline; close the process explicitly after a failed or timed-out run.

    Command
    set -eu
    cd "$HOME/maple-preview-local-m4-32gb-mlx-dense"
    export HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=1 TOKENIZERS_PARALLELISM=false
    .venv/bin/python reader_assets.py mlx verify
    exec .venv/bin/python maple_server.py mlx

    Expected result: After actual reader startup, authenticated health reports the selected backend, dense head and bounded workload. Stop on loading, kernel, platform, memory or checksum failure.

Connect to your endpoint

http://127.0.0.1:9008/v1/fixed-reasoning-code

Machine loopback only; all shown checks run locally.

Access: loopback. Stable private 64-character hexadecimal Bearer key protects health and fixed-job routes. Single trusted reader only; no public or multiuser service. HTTP remains on local loopback only.

Verify the setup

  1. 1. Verify private access and complete native two-turn output

    Use a second terminal on the same machine and the exact virtual-environment Python. The request contains only a fixed job name. The client timeout does not cancel native computation. Record actual output and inspect arithmetic and code; no semantic gold result is forced.

    Command
    set -eu
    cd "$HOME/maple-preview-local-m4-32gb-mlx-dense"
    .venv/bin/python - <<'PYVERIFY'
    import urllib.request,urllib.error,pathlib,json,importlib.util
    k=pathlib.Path('.api-key').read_text().strip();base='http://127.0.0.1:9008'
    try:urllib.request.urlopen(base+'/health',timeout=5);raise AssertionError('unauthenticated health accepted')
    except urllib.error.HTTPError as e:assert e.code==401
    def call(path,data=None,timeout=5):
     r=urllib.request.Request(base+path,data=data,headers={'Authorization':'Bearer '+k,'Content-Type':'application/json'})
     with urllib.request.urlopen(r,timeout=timeout)as x:return json.load(x)
    h=call('/health');assert h=={'ready':True,'backend':'mlx','context_limit':8192,'output_cap':4096,'head':'dense'}
    r=call('/v1/fixed-reasoning-code',b'{"job":"reasoning-code"}',timeout=3600)
    s=importlib.util.spec_from_file_location('reader_boundary','maple_server.py');m=importlib.util.module_from_spec(s);s.loader.exec_module(m)
    m.checked_result('mlx',r);pathlib.Path('actual-reader-result.json').write_text(json.dumps(r,indent=2)+'\n')
    for i,t in enumerate(r['turns'],1):print('Turn',i,'input/output tokens',t['input_tokens'],t['output_tokens'],'\nReasoning:',t['reasoning'],'\nFinal:',t['answer'])
    print('Inspect arithmetic 8 then 9 and function update manually; no returned code is executed and no model correctness is assumed.')
    PYVERIFY

    Expected result: Unauthenticated access returns 401. Authenticated health and two complete raw-EOS, closed-thinking turns pass exact token-budget checks. Human inspection determines actual task quality; code is not executed.

Performance evidence

No compatible measurement available. Documented support and estimated memory do not establish response speed.

Limits and troubleshooting

  • Only exact source and metadata plus stdlib fake/AST checks were executed. Native environment, weights, kernels, model quality, memory peak and speed remain unmeasured.
  • The five-second socket timeout bounds request framing only. Serial generation can run much longer and requires explicit process shutdown; this is not an inference SLA.
  • The fixed reasoning/code inputs do not establish unrestricted tool, production, public API or whole-family coverage. Required guide totals remain null.
Asset, native import, GPU, extension or loading failure
Stop and retain diagnostics without secret values. Do not bypass checks, omit experts, change source math, substitute another checkpoint or enable an approximate head. A different platform or backend requires its own qualification.
Length exhaustion, missing EOS or malformed thinking/control output
Treat the result as incomplete. Preserve actual output and token counts; do not strip native control fragments, fabricate a final answer or execute returned code.
Out of memory or client timeout
Stop the foreground process and verify endpoint closure. Native compute is not cancelled by the socket or client timeout. Record actual failure; no fit or latency was measured.

Stop the model

  1. 1. Stop and verify endpoint closure

    Press Ctrl-C in the foreground service terminal. Then verify the private endpoint is closed.

    Command
    set -eu
    cd "$HOME/maple-preview-local-m4-32gb-mlx-dense"
    .venv/bin/python - <<'PYSTOP'
    import socket
    with socket.socket()as s:
     s.settimeout(3);assert s.connect_ex(('127.0.0.1',9008))!=0
    print('Private service endpoint is closed.')
    PYSTOP

    Expected result: The native Python process has stopped and the loopback endpoint is closed.

Uninstall

  1. 1. Remove only this named reader workspace

    After stopping and saving any needed result/version records, remove this exact workspace and its downloaded native assets/environment. Do not remove shared system drivers or unrelated files.

    Command
    set -eu
    python3 - <<'PYCLEAN'
    from pathlib import Path
    import shutil
    p=Path.home()/"maple-preview-local-m4-32gb-mlx-dense"
    assert p.name=="maple-preview-local-m4-32gb-mlx-dense" and p.parent==Path.home() and not p.is_symlink()
    if p.exists():shutil.rmtree(p)
    PYCLEAN

    Expected result: Only the named private workspace is removed; shared machine software remains separate.

Sources and verification

Sources checked Oct 17, 2026. Verification source

Compare this configuration
Cloud serverDocumented setupSources checked Oct 17, 2026

Host Maple Preview reasoning and code on a private AWS H100 with the complete native CUDA checkpoint

Run the complete selected publisher Maple representation with its own template, retained reasoning and two-turn code history. The private fixed-task service requires true EOS, closed thinking and complete input budgets. All nine native BF16 parts and experts remain verified, using the source-qualified no-mask native attention path. Capacity, quality and speed remain unmeasured.

Hardware
AWS p5.4xlarge with one NVIDIA H100 80 GB
Runtime
Native Maple CUDA direct unpadded cached forward Transformers 4.57.1; Torch 2.6.0 CUDA 12.4; ABI-matched official FlashAttention 2.8.3 · CUDA
Model format
Native HF sharded safetensors · Publisher BF16 serialization of native trained ternary MoE weights; no reader quantization or expert stripping · Publisher BF16 serialization of native trained ternary MoE weights; no reader quantization or expert stripping
Workload
8,192 token context · 1 concurrent

Based on source documentation; this setup has not been executed by OpenTools. Memory: unknown. No compatible measurement available.

Read the complete setup guide

Before you start

  • Use an existing AWS p5.4xlarge Ubuntu 24.04 x86_64 instance in us-east-1, one H100 advertised 80 GB, 256 GiB host RAM and chosen 256 GiB gp3 root disk, with at least 160 GiB free. Require driver >= 550.54.14. Keep TCP 9008 closed publicly; restrict SSH to your client.
  • Review the exact publisher MIT and MLX runtime notices. No license acceptance, model download, native execution or legal clearance was performed by the author. Provider API byte equivalence and native versus frozen release dates are not established.
  • The complete native nine-part BF16 package is retained. Use only the documented unpadded direct-forward reader path: no attention mask or explicit position IDs. The upstream masked-path dimension hazard remains, without source math changes.
  • 8,192 total positions and 4,096 output per turn are bounded author choices. All actual retained history is counted with no truncation. Full native context, tools, other samplers and production service remain separate open scopes.
  • Use Python 3.12 for this exact native runtime.

Exact model and requirements

Artifact:
DeepGrove AI / Maple Preview complete native BF16 CUDA checkpoint · checkpoint deepgrove/maple-preview
Publisher revision:
ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07
Artifact digest:
No composite whole-package digest is published. Every required file has exact size and LFS SHA-256 or native Git blob SHA-1 in the embedded mandatory manifest.
Download size:
37.65 GiB
Memory requirement (unknown):
Unknown — No complete native runtime, cache, activation, loading-buffer or OS peak was measured.
System RAM / disk:
Unknown / Unknown
Placement:
single device. One selected accelerator; all layers and experts remain present. Complete model and caches use one H100; no CPU or disk weight offload. Host loading buffers remain additional.
KV cache:
Native BF16 attention KV on the selected CUDA model path; exact realized peak remains unmeasured
Workload:
8,192 token context; Unknown; Unknown; concurrency 1; batch 1; cache cold; repetitions Unknown.
Tokenizer:
Exact native Maple tokenizer and 3,292-byte publisher Jinja, with no added BOS · ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07
Sampling / reasoning:
Dense full-vocabulary greedy argmax is an author-selected fixed-task setting. Native direct forward and causal/sliding FA2 mathematics are unchanged. The publisher template opens thinking. Preserve complete reasoning_content and final answer in the second turn. Require exactly closed thinking and true raw native EOS; reject partial/reopened/tool/control output. 8,192 total context and 4,096 output cap are walkthrough bounds, not the native full-context recommendation.
Runtime prerequisites:
Ubuntu 24.04 x86_64; NVIDIA driver >= 550.54.14 for CUDA 12.4; working H100 visibility, Exact FA2 wheel ABI selected from actual Torch build; FA3 and Liger absent, Python 3.12.

Official artifact · License

Exact publisher MIT license is archived. Retain its copyright and permission notice in copies or substantial portions; software is provided without warranty or liability. The separate publisher MLX fork is also MIT. No terms are accepted or legal clearance granted by this guide.

  • LICENSE · 0 GiB · revision ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07
  • README.md · 0 GiB · revision ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07
  • added_tokens.json · 0 GiB · revision ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07
  • chat_template.jinja · 0 GiB · revision ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07
  • config.json · 0 GiB · revision ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07
  • configuration_maple.py · 0 GiB · revision ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07
  • fa3.py · 0 GiB · revision ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07
  • merges.txt · 0 GiB · revision ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07
  • model.safetensors.index.json · 0 GiB · revision ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07
  • modeling_maple.py · 0 GiB · revision ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07
  • special_tokens_map.json · 0 GiB · revision ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07
  • tokenizer.json · 0.01 GiB · revision ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07
  • tokenizer_config.json · 0 GiB · revision ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07
  • vocab.json · 0 GiB · revision ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07
  • 40430372376 serialized weight bytes do not include complete runtime memory.
  • All experts, caches, native extension workspaces, activations, loading buffers and OS overhead remain additional and unmeasured.

One-time setup and hardware

hardware
Unknown — Hardware is rented; separate acquisition cost is not established.
Hardware is rented; separate acquisition cost is not established. Tax: unknown.
setup
Unknown — Provisioning and setup labor remain unmeasured.
Provisioning and setup labor remain unmeasured. Tax: unknown.

Recurring costs

compute
$6.88 / hour
Exact us-east-1 Linux On-Demand quote USD 6.88/hour, original publication 2026-10-15T19:13:16Z. Eight hours USD 55.04 compute only; running idle hours bill. No Spot/reservation discount or capacity guarantee. Storage/egress/tax/labor/IP resources separate. Region: us-east-1. SKU: p5.4xlarge Linux On-Demand. Tax: excluded. Price dated Oct 15, 2026. Price source
storage
$0.08 / GB month
US East gp3 baseline USD 0.08 per AWS binary GB-month. Chosen 256 GiB root volume USD 20.48 per full month, prorated independently of compute hours; baseline 3000 IOPS / 125 MB/s. Local 1 × 3,840 GB SSD is included instance storage, not retained EBS; snapshots and public IPs separate. Region: us-east-1. SKU: EBS gp3 baseline. Tax: excluded. Price dated Oct 17, 2026. Price source
egress
Unknown — Actual transfer, public IPv4/IP and associated service charges depend on usage/resources; unknown.
Actual transfer, public IPv4/IP and associated service charges depend on usage/resources; unknown. Tax: unknown.
administration
Unknown — Maintenance time and rate remain unknown.
Maintenance time and rate remain unknown. Tax: unknown.

Install the runtime

  1. 1. Prepare the existing reader machine

    Use the exact platform in prerequisites. Record actual capacity before downloading. These are planning checks, not measured model fit.

    Command
    set -eu
    mkdir -p "$HOME/maple-preview-aws-p5-4xlarge-bf16-native"
    cd "$HOME/maple-preview-aws-p5-4xlarge-bf16-native"
    sudo apt-get update
    sudo apt-get install -y python3.12-venv python3.12 curl ca-certificates openssl git
    nvidia-smi --query-gpu=name,memory.total,driver_version --format=csv,noheader
    python3.12 -m venv .venv
    python3.12 - <<'PYPREFLIGHT'
    import shutil
    assert shutil.disk_usage('.').free >= 171798691840
    print('Reader prescribed free space passed; fit remains unmeasured.')
    PYPREFLIGHT

    Expected result: An existing compatible machine, Python 3.12 environment and prescribed free space are recorded. Stop on platform, GPU, driver or disk failure.

Download the model

  1. 1. Write the mandatory streaming asset checker (1/1)

    Write this exact source section in order. Writing source does not execute native code.

    Command
    set -eu
    cd "$HOME/maple-preview-aws-p5-4xlarge-bf16-native"
    cat > reader_assets.py <<'MAPLEFILE'
    """Reader-only exact full Maple asset verification; no native imports."""
    import hashlib,json,pathlib,sys,urllib.request
    ROOT=pathlib.Path(__file__).resolve().parent
    PINS={'cuda':('deepgrove/maple-preview','ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07','3ab6ce508a608d0af564c6683497eb7d166178d8c992e33dd41404c9e2be92eb',23),'mlx':('deepgrove/maple-preview-2bit-mlx','e8be321fb325c40beb7b621bd98e8e57a324ec42','d236df54f11ada042e099c2ae15942b246c611420495ee39ac3a470a38b5a182',15)}
    def manifest(mode):
        repo,pin,digest,count=PINS[mode];data=(ROOT/'assets.json').read_bytes()
        if hashlib.sha256(data).hexdigest()!=digest:raise ValueError('manifest_hash')
        m=json.loads(data)
        if m['mode']!=mode or m['repo']!=repo or m['revision']!=pin or len(m['files'])!=count:raise ValueError('manifest_identity')
        return m
    
    def check(path,row):
        h=hashlib.sha256()if row['algorithm']=='sha256'else hashlib.sha1();n=0
        if row['algorithm']=='git-sha1':h.update(b'blob '+str(row['bytes']).encode()+b'\0')
        with path.open('rb')as f:
            for b in iter(lambda:f.read(1024*1024),b''):n+=len(b);h.update(b)
        if n!=row['bytes']or h.hexdigest()!=row['digest']:raise ValueError('asset_integrity_'+row['path'])
    
    def verify(mode,download=False):
        m=manifest(mode)
        for category,dirname in [('files','model'),('runtime_files','runtime')]:
            root=ROOT/dirname;root.mkdir(exist_ok=True)
            for row in m[category]:
                if pathlib.PurePosixPath(row['path']).name!=row['path']:raise ValueError('asset_path')
                path=root/row['path']
                if download and not path.exists():
                    temp=path.with_suffix(path.suffix+'.partial');n=0
                    with urllib.request.urlopen(row['url'],timeout=120)as src,temp.open('wb')as dst:
                        for chunk in iter(lambda:src.read(1024*1024),b''):
                            n+=len(chunk)
                            if n>row['bytes']:raise ValueError('download_size')
                            dst.write(chunk)
                    check(temp,row);temp.replace(path)
                check(path,row)
        index=json.loads((ROOT/'model/model.safetensors.index.json').read_text())['weight_map'];parts={x['path']for x in m['files']if x['path'].endswith('.safetensors')}
        # Publisher MLX index covers the three main parts; FlashHead is a mandatory
        # separately shipped fourth asset, loaded by publisher model*.safetensors glob.
        indexed=parts-({'model-flashhead.safetensors'}if mode=='mlx'else set())
        if set(index.values())!=indexed:raise ValueError('complete_weight_index')
        print('All exact native or publisher-packed files verified; no fit or numerical equivalence proof.')
    if __name__=='__main__':
        if len(sys.argv)!=3 or sys.argv[1]not in PINS or sys.argv[2]not in ('download','verify'):raise SystemExit('Use cuda|mlx download|verify')
        verify(sys.argv[1],sys.argv[2]=='download')
    MAPLEFILE

    Expected result: The exact source section is written. Continue through every section before verification.

  2. 2. Write the exact complete publisher asset manifest (1/2)

    Write this exact source section in order. Writing source does not execute native code.

    Command
    set -eu
    cd "$HOME/maple-preview-aws-p5-4xlarge-bf16-native"
    cat > assets.json <<'MAPLEFILE'
    MAPLEFILE

    Expected result: The exact source section is written. Continue through every section before verification.

  3. 3. Write the exact complete publisher asset manifest (2/2)

    Write this exact source section in order. Writing source does not execute native code.

    Command
    set -eu
    cd "$HOME/maple-preview-aws-p5-4xlarge-bf16-native"
    cat >> assets.json <<'MAPLEFILE'
    {"mode":"cuda","repo":"deepgrove/maple-preview","revision":"ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07","files":[{"path":"LICENSE","bytes":1066,"algorithm":"git-sha1","digest":"26a36c1b035374c2e22090ddc52c1a00a727ecb6","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/LICENSE"},{"path":"README.md","bytes":1941,"algorithm":"git-sha1","digest":"70a6cdf094695e092f3b9e62475ab8a17221a68e","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/README.md"},{"path":"added_tokens.json","bytes":707,"algorithm":"git-sha1","digest":"b54f9135e44c1e81047e8d05cb027af8bc039eed","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/added_tokens.json"},{"path":"chat_template.jinja","bytes":3292,"algorithm":"git-sha1","digest":"b5509b8aef363d7262fb86370db1eb41f554959b","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/chat_template.jinja"},{"path":"config.json","bytes":1893,"algorithm":"git-sha1","digest":"679618c2e5d73619b9809dfbe77e5e049f1db99c","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/config.json"},{"path":"configuration_maple.py","bytes":2149,"algorithm":"git-sha1","digest":"d78f1d1b06f397f02192a8c157d71c1e0fe9d91c","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/configuration_maple.py"},{"path":"fa3.py","bytes":9681,"algorithm":"git-sha1","digest":"cf5d5d07a7076d6cdb1f541e929b67e084c97cb0","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/fa3.py"},{"path":"merges.txt","bytes":1671853,"algorithm":"git-sha1","digest":"31349551d90c7606f325fe0f11bbb8bd5fa0d7c7","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/merges.txt"},{"path":"model-00001-of-00009.safetensors","bytes":4998990664,"algorithm":"sha256","digest":"a0e75504d43e41c5aa1796abac3266e8626706742f2c6da8a67a48d31d9a4f77","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/model-00001-of-00009.safetensors"},{"path":"model-00002-of-00009.safetensors","bytes":4999904624,"algorithm":"sha256","digest":"166113ab0c8f485d5d8a6060c4f1714ed4a7103ba703fd5c51316fb70c5abdd6","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/model-00002-of-00009.safetensors"},{"path":"model-00003-of-00009.safetensors","bytes":4999904624,"algorithm":"sha256","digest":"82c08761b18236f95e06b04ebb24ef55e2a54d0abda95afe6ee8ad963ce712dd","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/model-00003-of-00009.safetensors"},{"path":"model-00004-of-00009.safetensors","bytes":4999905768,"algorithm":"sha256","digest":"dda74a69c9ac24dfaf135b0d459b47307e134dc5dc2cd7c4171f249a6c267fa0","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/model-00004-of-00009.safetensors"},{"path":"model-00005-of-00009.safetensors","bytes":4999907000,"algorithm":"sha256","digest":"73b5a1edfcc317374305ea29c79b0ddb184f8f069163f9083bffe0b0181a00ec","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/model-00005-of-00009.safetensors"},{"path":"model-00006-of-00009.safetensors","bytes":4999907000,"algorithm":"sha256","digest":"f8533087e0a88695d8bb43fa82d2be16e396e8fbc1e32357d8cfa99af6860446","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/model-00006-of-00009.safetensors"},{"path":"model-00007-of-00009.safetensors","bytes":4999906992,"algorithm":"sha256","digest":"efcb94993cb5d9062c879c4d132489f58687b5e21ff20d2913b011d6504127dd","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/model-00007-of-00009.safetensors"},{"path":"model-00008-of-00009.safetensors","bytes":4999907000,"algorithm":"sha256","digest":"79be22027606cf7efde7d6f409a6cf369380132d1baf625bcc90f4280a7baab0","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/model-00008-of-00009.safetensors"},{"path":"model-00009-of-00009.safetensors","bytes":432038704,"algorithm":"sha256","digest":"4761e38c77d93f4807181eb972557f44649336c0d261064578a9d3c1587cbebb","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/model-00009-of-00009.safetensors"},{"path":"model.safetensors.index.json","bytes":1685937,"algorithm":"git-sha1","digest":"371d69d9b4c178f2bd1efc223f394d5f6e2e81c9","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/model.safetensors.index.json"},{"path":"modeling_maple.py","bytes":28642,"algorithm":"git-sha1","digest":"d33d1aedfa2bdbd4defea9123c3f2b9b56f5ed21","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/modeling_maple.py"},{"path":"special_tokens_map.json","bytes":613,"algorithm":"git-sha1","digest":"ac23c0aaa2434523c494330aeb79c58395378103","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/special_tokens_map.json"},{"path":"tokenizer.json","bytes":11422654,"algorithm":"sha256","digest":"aeb13307a71acd8fe81861d94ad54ab689df773318809eed3cbe794b4492dae4","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/tokenizer.json"},{"path":"tokenizer_config.json","bytes":5432,"algorithm":"git-sha1","digest":"f4b91854389fd13e964c436e576a0011e588104b","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/tokenizer_config.json"},{"path":"vocab.json","bytes":2776833,"algorithm":"git-sha1","digest":"4783fe10ac3adce15ac8f358ef5462739852c569","url":"https://huggingface.co/deepgrove/maple-preview/resolve/ac1ddd79d2b5cb4406f5d2bebdf95406ce505a07/vocab.json"}],"runtime_files":[]}
    MAPLEFILE

    Expected result: The exact source section is written. Continue through every section before verification.

  4. 4. Verify the manifest and download every required asset

    Only the reader runs this download. All model parts, tokenizer auxiliaries, remote code and the Apple kernel wheel are mandatory. Existing mismatched files fail closed; no byte range or alternate checkpoint is used.

    Command
    set -eu
    cd "$HOME/maple-preview-aws-p5-4xlarge-bf16-native"
    .venv/bin/python - <<'PYHASH'
    import hashlib,pathlib
    for n,h in [('reader_assets.py', 'e12f5b1a39737ba1649b235702ebe76404406d7422e1593c3a20b20a34fe56fe'), ('assets.json', '3ab6ce508a608d0af564c6683497eb7d166178d8c992e33dd41404c9e2be92eb')]:
     assert hashlib.sha256(pathlib.Path(n).read_bytes()).hexdigest()==h
    PYHASH
    .venv/bin/python reader_assets.py cuda download

    Expected result: All required per-file sizes and streaming hashes pass before any native loading. This establishes exact bytes, not model quality or fit.

Configure

  1. 1. Install the exact native-facing reader runtime

    Reader installation is source-qualified and unexecuted here. Use a fresh environment; no FA3, Liger, alternate MLX fork or floating kernel build. Stop on wheel ABI, dependency or native import failure. Save actual transitive versions; this is not an executed lockfile.

    Command
    set -eu
    cd "$HOME/maple-preview-aws-p5-4xlarge-bf16-native"
    .venv/bin/python -m pip install "https://download-r2.pytorch.org/whl/cu124/torch-2.6.0%2Bcu124-cp312-cp312-linux_x86_64.whl#sha256=a393b506844035c0dac2f30ea8478c343b8e95a429f06f3b3cadfc7f53adb597" transformers==4.57.1 huggingface-hub==0.36.0 tokenizers==0.22.2 safetensors==0.5.3 numpy==2.2.3 einops==0.8.1 PyYAML==6.0.2 Jinja2==3.1.6
    .venv/bin/python - <<'PYFA'
    import torch,urllib.request,hashlib,pathlib,subprocess,sys
    assert torch.__version__.split("+")[0]=="2.6.0" and torch.version.cuda=="12.4"
    abi=bool(torch._C._GLIBCXX_USE_CXX11_ABI)
    label="TRUE" if abi else "FALSE"
    h={False:"51100460844b0cb4bd5adc38af60c56adff8904508861aeb5ef7a1c2e41f529a",True:"ae3b8b402ca649e0974f20a9b8641cc5a72233722674cf0f7b524fbdf736fdb7"}[abi]
    name="flash_attn-2.8.3+cu12torch2.6cxx11abi"+label+"-cp312-cp312-linux_x86_64.whl"
    u="https://github.com/Dao-AILab/flash-attention/releases/download/v2.8.3/"+name.replace("+","%2B")
    p=pathlib.Path(name);digest=hashlib.sha256()
    with urllib.request.urlopen(u,timeout=120)as r,p.open("wb")as f:
     while b:=r.read(1024*1024):digest.update(b);f.write(b)
    assert digest.hexdigest()==h
    subprocess.run([sys.executable,"-m","pip","install","--no-deps",str(p)],check=True)
    PYFA
    .venv/bin/python -m pip check
    .venv/bin/python -m pip freeze > realized-environment.txt

    Expected result: Exact native-facing versions install and pip check passes only after reader execution. Record realized versions; no compatibility or fit was measured by the author.

  2. 2. Write the complete private native reasoning service (1/3)

    Write this exact source section in order. Writing source does not execute native code.

    Command
    set -eu
    cd "$HOME/maple-preview-aws-p5-4xlarge-bf16-native"
    cat > maple_server.py <<'MAPLEFILE'
    """Reader-authored fixed Maple reasoning/code harness. Native imports occur only in reader startup."""
    import hashlib,hmac,json,pathlib,sys
    from http.server import BaseHTTPRequestHandler,HTTPServer
    ROOT=pathlib.Path(__file__).resolve().parent
    CONTEXT=8192;CAP=4096;EOS=151645;OPEN=151667;CLOSE=151668
    PROMPTS=['A library opens at 09:00 and closes at 17:00 on the same day. Work out its opening duration, then give a small Python function opening_hours() returning that integer. Do not execute code or call tools.','Now closing changes to 18:00 with the same opening time. Recompute and update the function. Do not execute code or call tools.']
    def native_forward(model,input_ids,cache):
        # Exact native no-mask, no-explicit-position path. Never model.generate().
        return model(input_ids=input_ids,attention_mask=None,position_ids=None,
            past_key_values=cache,use_cache=True,cache_position=None,return_dict=True,logits_to_keep=1)
    
    def parse_output(ids,text):
        if type(ids)is not list or not 1<=len(ids)<=CAP or any(type(x)is not int or x<0 for x in ids):raise ValueError('raw_output_ids')
        if ids[-1]!=EOS or ids.count(EOS)!=1 or ids.count(CLOSE)!=1 or OPEN in ids:raise ValueError('native_end_or_think')
        end=ids.index(CLOSE)
        if any(x>=151643 and x not in (OPEN,CLOSE,EOS)for x in ids):raise ValueError('unexpected_native_control_id')
        if type(text)is not str or text.count('</think>')!=1:raise ValueError('decoded_thinking_boundary')
        reasoning,answer=text.split('</think>')
        if not reasoning.strip()or not answer.strip()or any(x in reasoning+answer for x in ('<think','</think','<tool','</tool','<|','|>')):raise ValueError('nonfinal_control_or_empty')
        return reasoning,answer
    
    def checked_result(mode,d):
        if type(d)is not dict or set(d)!={'backend','turns','context_limit','output_cap','head'}or d['backend']!=mode or d['context_limit']!=CONTEXT or d['output_cap']!=CAP or d['head']!='dense':raise ValueError('result_identity')
        if type(d['turns'])is not list or len(d['turns'])!=2:raise ValueError('two_turns_required')
        for r in d['turns']:
            if type(r)is not dict or set(r)!={'reasoning','answer','input_tokens','output_tokens','stop_id'}:raise ValueError('turn_schema')
            if any(type(r[k])is not int for k in ('input_tokens','output_tokens','stop_id'))or not 1<=r['input_tokens']<=CONTEXT-CAP or not 1<=r['output_tokens']<=CAP or r['input_tokens']+r['output_tokens']>CONTEXT or r['stop_id']!=EOS:raise ValueError('turn_budget_stop')
            if any(type(r[k])is not str or not r[k].strip() or len(r[k])>65536 for k in ('reasoning','answer')):raise ValueError('turn_text')
            if any(c in r['reasoning']+r['answer']for c in ('<think','</think','<tool','</tool','<|','|>')):raise ValueError('turn_control')
        return d
    
    def publisher_native_extension(model):
        # Publisher loader executes custom_model without registering sys.modules.
        # The verified source-defined class initializer retains that module globals.
        init=model.__class__.__init__
        context=getattr(init,'__globals__',None)
        if type(context)is not dict or context.get('__name__')!=model.__class__.__module__:
            raise RuntimeError('publisher_loaded_context_required')
        native=context.get('_maple_native')
        if native is None:raise RuntimeError('pinned_publisher_kernel_required')
        return native
    
    def make_engine(mode):
        from reader_assets import verify
        verify(mode)
        path=ROOT/'model';cfg=json.loads((path/'config.json').read_text())
        if cfg['num_hidden_layers']!=24 or cfg['num_experts']!=256 or cfg['num_experts_per_tok']!=8 or cfg['sliding_window']!=512:raise RuntimeError('wrong_maple_architecture')
        if mode=='cuda':
            import torch
            from transformers import AutoTokenizer,AutoModelForCausalLM
            if torch.__version__.split('+')[0]!='2.6.0'or torch.version.cuda!='12.4'or torch.cuda.device_count()!=1 or 'H100'not in torch.cuda.get_device_name(0):raise RuntimeError('exact_cuda_runtime_required')
            # Select only the explicit FA2 fallback; FA3 is deliberately not installed.
            import importlib.util
            if importlib.util.find_spec('flash_attn_interface')is not None:raise RuntimeError('unexpected_fa3_interface')
            import flash_attn
            if flash_attn.__version__!='2.8.3':raise RuntimeError('flash_attention_version')
            import inspect
            if 'window_size'not in inspect.signature(flash_attn.flash_attn_func).parameters or importlib.util.find_spec('liger_kernel')is not None:raise RuntimeError('exact_unfused_sliding_attention_backend')
            if cfg['max_position_embeddings']!=131072 or cfg['nope_on_global_attention']is not True:raise RuntimeError('native_cuda_config')
            tok=AutoTokenizer.from_pretrained(path,local_files_only=True,trust_remote_code=False)
    MAPLEFILE

    Expected result: The exact source section is written. Continue through every section before verification.

  3. 3. Write the complete private native reasoning service (2/3)

    Write this exact source section in order. Writing source does not execute native code.

    Command
    set -eu
    cd "$HOME/maple-preview-aws-p5-4xlarge-bf16-native"
    cat >> maple_server.py <<'MAPLEFILE'
            model,info=AutoModelForCausalLM.from_pretrained(path,local_files_only=True,trust_remote_code=True,torch_dtype=torch.bfloat16,device_map=None,use_safetensors=True,output_loading_info=True,ignore_mismatched_sizes=False)
            keys={'missing_keys','unexpected_keys','mismatched_keys','error_msgs'}
            if type(info)is not dict or set(info)!=keys or any(info[k]for k in keys):raise RuntimeError('native_load_diagnostics')
            model=model.to('cuda:0').eval()
            if len(model.model.layers)!=24 or any(p.dtype!=torch.bfloat16 or p.device.type!='cuda' or not torch.isfinite(p).all()for p in model.parameters()):raise RuntimeError('full_native_gpu_parameters')
            def generate(ids):
                tokens=[];cache=None;current=torch.tensor([ids],dtype=torch.long,device='cuda:0')
                with torch.inference_mode():
                    for _ in range(CAP):
                        out=native_forward(model,current,cache);cache=out.past_key_values;scores=out.logits[0,-1]
                        if not torch.isfinite(scores).all():raise RuntimeError('nonfinite_native_logits')
                        token=int(torch.argmax(scores));tokens.append(token)
                        if token==EOS:break
                        current=torch.tensor([[token]],dtype=torch.long,device='cuda:0')
                return tokens,tok.decode(tokens[:-1]if tokens and tokens[-1]==EOS else tokens,skip_special_tokens=False)
        elif mode=='mlx':
            import platform,subprocess
            if platform.machine()!='arm64'or tuple(map(int,platform.mac_ver()[0].split('.')[:2]))<(26,2):raise RuntimeError('native_apple_platform')
            import mlx.core as mx
            from mlx_lm import load
            from mlx_lm.generate import stream_generate
            if mx.__version__!='0.32.0'or mx.default_device()!=mx.gpu:raise RuntimeError('exact_mlx_metal_runtime')
            if cfg['max_position_embeddings']!=128000 or cfg.get('nope_on_global_attention')is not False:raise RuntimeError('publisher_mlx_config')
            model,tok=load(str(path),model_config={'use_flash_head':False},trust_remote_code=True)
            if model.lm_head_flash is not None or len(model.model.layers)!=24:raise RuntimeError('dense_complete_maple_required')
            import importlib.metadata
            native=publisher_native_extension(model)
            if importlib.metadata.version('mlx-lm-maple-kernels')!='0.1.0'or native is None:raise RuntimeError('pinned_publisher_kernel_required')
            def sampler(logprobs):
                if bool(mx.any(mx.isnan(logprobs)))or bool(mx.any(mx.isinf(logprobs)&(logprobs>0)))or not bool(mx.any(mx.isfinite(logprobs))):raise RuntimeError('nonfinite_dense_logits')
                return mx.argmax(logprobs,axis=-1)
            def generate(ids):
                tokens=[];last=None
                for item in stream_generate(model,tok,ids,max_tokens=CAP,sampler=sampler):
                    tokens.append(item.token);last=item
                if last is None or last.finish_reason!='stop' or last.generation_tokens!=len(tokens):raise RuntimeError('native_mlx_completion')
                return tokens,tok.decode(tokens[:-1]if tokens and tokens[-1]==EOS else tokens,skip_special_tokens=False)
        else:raise ValueError('backend')
        if tok.eos_token_id!=EOS or tok.convert_tokens_to_ids('</think>')!=CLOSE:raise RuntimeError('native_token_identity')
        def engine():
            messages=[];turns=[]
            for prompt in PROMPTS:
                messages.append({'role':'user','content':prompt})
                rendered=tok.apply_chat_template(messages,tokenize=False,add_generation_prompt=True)
                ids=tok.encode(rendered,add_special_tokens=False)
                if not 1<=len(ids)<=CONTEXT-CAP:raise ValueError('full_native_history_budget')
                raw,text=generate(ids);reasoning,answer=parse_output(raw,text)
                turns.append({'reasoning':reasoning,'answer':answer,'input_tokens':len(ids),'output_tokens':len(raw),'stop_id':raw[-1]})
                messages.append({'role':'assistant','content':answer,'reasoning_content':reasoning})
            return checked_result(mode,{'backend':mode,'turns':turns,'context_limit':CONTEXT,'output_cap':CAP,'head':'dense'})
        return engine
    
    def create_server(engine,key,mode,port=9008):
        if type(key)is not str or len(key)!=64 or any(x not in '0123456789abcdef'for x in key):raise ValueError('key_format')
        class Handler(BaseHTTPRequestHandler):
            def setup(self):super().setup();self.connection.settimeout(5)
            def log_message(self,*_):pass
            def reply(self,status,d):
                data=json.dumps(d,allow_nan=False).encode()
                if len(data)>131072:status=500;data=b'{"error":"response_limit"}'
    MAPLEFILE

    Expected result: The exact source section is written. Continue through every section before verification.

  4. 4. Write the complete private native reasoning service (3/3)

    Write this exact source section in order. Writing source does not execute native code.

    Command
    set -eu
    cd "$HOME/maple-preview-aws-p5-4xlarge-bf16-native"
    cat >> maple_server.py <<'MAPLEFILE'
                self.send_response(status);self.send_header('Content-Type','application/json');self.send_header('Content-Length',str(len(data)));self.send_header('Connection','close');self.end_headers();self.wfile.write(data);self.close_connection=True
            def auth(self):
                values=self.headers.get_all('Authorization',[])
                return len(values)==1 and hmac.compare_digest(values[0].encode(),('Bearer '+key).encode())
            def do_GET(self):
                if not self.auth():return self.reply(401,{'error':'unauthorized'})
                if self.path!='/health':return self.reply(404,{'error':'not_found'})
                return self.reply(200,{'ready':True,'backend':mode,'context_limit':CONTEXT,'output_cap':CAP,'head':'dense'})
            def do_POST(self):
                if not self.auth():return self.reply(401,{'error':'unauthorized'})
                if self.path!='/v1/fixed-reasoning-code':return self.reply(404,{'error':'not_found'})
                lengths=self.headers.get_all('Content-Length',[])
                if self.headers.get('Transfer-Encoding')is not None or len(lengths)!=1:return self.reply(400,{'error':'framing'})
                value=lengths[0]
                if not value or len(value)>3 or any(x not in '0123456789'for x in value)or not 1<=int(value)<=128:return self.reply(413,{'error':'body_limit'})
                if self.headers.get_content_type()!='application/json':return self.reply(415,{'error':'json_required'})
                try:
                    body=self.rfile.read(int(value))
                    if len(body)!=int(value):raise ValueError('incomplete')
                    def unique(pairs):
                        d={}
                        for k,v in pairs:
                            if k in d:raise ValueError('duplicate')
                            d[k]=v
                        return d
                    d=json.loads(body.decode(),object_pairs_hook=unique,parse_constant=lambda _:(_ for _ in ()).throw(ValueError('nonfinite')))
                    if type(d)is not dict or d!={'job':'reasoning-code'}:raise ValueError('fixed_job')
                except (ValueError,UnicodeError,TimeoutError,OSError,RecursionError):return self.reply(400,{'error':'invalid_request'})
                try:return self.reply(200,checked_result(mode,engine()))
                except Exception:return self.reply(500,{'error':'native_generation_or_boundary_failure'})
        return HTTPServer(('127.0.0.1',port),Handler)
    if __name__=='__main__':
        if sys.argv[1:]not in (['cuda'],['mlx']):raise SystemExit('Use cuda or mlx')
        mode=sys.argv[1];key=(ROOT/'.api-key').read_text().strip()
        if len(key)!=64 or any(x not in '0123456789abcdef'for x in key):raise SystemExit('private_key_format')
        engine=make_engine(mode)
        with create_server(engine,key,mode)as server:server.serve_forever()
    MAPLEFILE

    Expected result: The exact source section is written. Continue through every section before verification.

  5. 5. Bind helper integrity and stable private access

    Generate a key only when absent. Every startup verifies all assets again before remote code/model loading. Keep the key private; it is never printed.

    Command
    set -eu
    cd "$HOME/maple-preview-aws-p5-4xlarge-bf16-native"
    umask 077
    if [ ! -e .api-key ]; then openssl rand -hex 32 > .api-key; fi
    chmod 600 .api-key
    .venv/bin/python - <<'PYCHECK'
    import hashlib,pathlib,ast
    p=pathlib.Path("maple_server.py");assert hashlib.sha256(p.read_bytes()).hexdigest()=="da4d1448e28fd704b8bad98249a657053c055caaec29415951da23966564f0dd"
    ast.parse(p.read_text())
    k=pathlib.Path(".api-key").read_text().strip();assert len(k)==64 and all(c in "0123456789abcdef" for c in k)
    PYCHECK

    Expected result: The complete helper checksum, syntax and stable key format pass without model execution.

Start the model

  1. 1. Start the serial native loopback service

    Run in the foreground. Readiness is returned only after exact native assets and full loading checks pass. Native compute has no hard cancellation deadline; close the process explicitly after a failed or timed-out run.

    Command
    set -eu
    cd "$HOME/maple-preview-aws-p5-4xlarge-bf16-native"
    export HF_HUB_OFFLINE=1 TRANSFORMERS_OFFLINE=1 TOKENIZERS_PARALLELISM=false
    export CUDA_VISIBLE_DEVICES=0
    .venv/bin/python reader_assets.py cuda verify
    exec .venv/bin/python maple_server.py cuda

    Expected result: After actual reader startup, authenticated health reports the selected backend, dense head and bounded workload. Stop on loading, kernel, platform, memory or checksum failure.

Connect to your endpoint

http://127.0.0.1:9008/v1/fixed-reasoning-code

VM loopback only. Run shown checks through the existing SSH session. Optional client-side tunnel: ssh -N -L 9008:127.0.0.1:9008 USER@VM_IP. Keep the service port closed publicly.

Access: loopback. Stable private 64-character hexadecimal Bearer key protects health and fixed-job routes. Single trusted reader only; no public or multiuser service. SSH protects remote transport; HTTP is loopback-only.

Verify the setup

  1. 1. Verify private access and complete native two-turn output

    Use a second terminal on the same machine and the exact virtual-environment Python. The request contains only a fixed job name. The client timeout does not cancel native computation. Record actual output and inspect arithmetic and code; no semantic gold result is forced.

    Command
    set -eu
    cd "$HOME/maple-preview-aws-p5-4xlarge-bf16-native"
    .venv/bin/python - <<'PYVERIFY'
    import urllib.request,urllib.error,pathlib,json,importlib.util
    k=pathlib.Path('.api-key').read_text().strip();base='http://127.0.0.1:9008'
    try:urllib.request.urlopen(base+'/health',timeout=5);raise AssertionError('unauthenticated health accepted')
    except urllib.error.HTTPError as e:assert e.code==401
    def call(path,data=None,timeout=5):
     r=urllib.request.Request(base+path,data=data,headers={'Authorization':'Bearer '+k,'Content-Type':'application/json'})
     with urllib.request.urlopen(r,timeout=timeout)as x:return json.load(x)
    h=call('/health');assert h=={'ready':True,'backend':'cuda','context_limit':8192,'output_cap':4096,'head':'dense'}
    r=call('/v1/fixed-reasoning-code',b'{"job":"reasoning-code"}',timeout=3600)
    s=importlib.util.spec_from_file_location('reader_boundary','maple_server.py');m=importlib.util.module_from_spec(s);s.loader.exec_module(m)
    m.checked_result('cuda',r);pathlib.Path('actual-reader-result.json').write_text(json.dumps(r,indent=2)+'\n')
    for i,t in enumerate(r['turns'],1):print('Turn',i,'input/output tokens',t['input_tokens'],t['output_tokens'],'\nReasoning:',t['reasoning'],'\nFinal:',t['answer'])
    print('Inspect arithmetic 8 then 9 and function update manually; no returned code is executed and no model correctness is assumed.')
    PYVERIFY

    Expected result: Unauthenticated access returns 401. Authenticated health and two complete raw-EOS, closed-thinking turns pass exact token-budget checks. Human inspection determines actual task quality; code is not executed.

Performance evidence

No compatible measurement available. Documented support and estimated memory do not establish response speed.

Limits and troubleshooting

  • Only exact source and metadata plus stdlib fake/AST checks were executed. Native environment, weights, kernels, model quality, memory peak and speed remain unmeasured.
  • The five-second socket timeout bounds request framing only. Serial generation can run much longer and requires explicit process shutdown; this is not an inference SLA.
  • The fixed reasoning/code inputs do not establish unrestricted tool, production, public API or whole-family coverage. Required guide totals remain null.
Asset, native import, GPU, extension or loading failure
Stop and retain diagnostics without secret values. Do not bypass checks, omit experts, change source math, substitute another checkpoint or enable an approximate head. A different platform or backend requires its own qualification.
Length exhaustion, missing EOS or malformed thinking/control output
Treat the result as incomplete. Preserve actual output and token counts; do not strip native control fragments, fabricate a final answer or execute returned code.
Out of memory or client timeout
Stop the foreground process and verify endpoint closure. Native compute is not cancelled by the socket or client timeout. Record actual failure; no fit or latency was measured.

Stop the model

  1. 1. Stop and verify endpoint closure

    Press Ctrl-C in the foreground service terminal. Then use this second-terminal check. A stopped service ends native work, not cloud resource billing.

    Command
    set -eu
    cd "$HOME/maple-preview-aws-p5-4xlarge-bf16-native"
    .venv/bin/python - <<'PYSTOP'
    import socket
    with socket.socket()as s:
     s.settimeout(3);assert s.connect_ex(('127.0.0.1',9008))!=0
    print('Private service endpoint is closed.')
    PYSTOP

    Expected result: The native Python process has stopped and the loopback endpoint is closed.

Uninstall

  1. 1. Remove only this named reader workspace

    After stopping and saving any needed result/version records, remove this exact workspace and its downloaded native assets/environment. Do not remove shared system drivers or unrelated files.

    Command
    set -eu
    python3 - <<'PYCLEAN'
    from pathlib import Path
    import shutil
    p=Path.home()/"maple-preview-aws-p5-4xlarge-bf16-native"
    assert p.name=="maple-preview-aws-p5-4xlarge-bf16-native" and p.parent==Path.home() and not p.is_symlink()
    if p.exists():shutil.rmtree(p)
    PYCLEAN

    Expected result: Only the named private workspace is removed; shared machine software remains separate.

Shut down cloud resources

  1. 1. End compute and retained-resource billing

    In EC2 us-east-1 stop for later reuse or terminate this exact instance. Review root-volume Delete on termination; delete unwanted detached EBS volumes, snapshots and retained public or Elastic IP resources. Local NVMe is ephemeral. Check final billing. Stopping Python alone does not stop VM or storage charges.

    Expected result: Compute billing ends only after the actual instance lifecycle transition; retained storage, snapshots and IP resources may still bill.

Sources and verification

Sources checked Oct 17, 2026. Verification source

Compare this configuration

Benchmarks

Performance scores for Maple-Preview across standard benchmarks.

LiveCodeBench v6DeepGrove model card · Aug 2026
75.1
AIME 2026DeepGrove model card · Aug 2026
87.5
HMMT 2026DeepGrove model card · Aug 2026
78.8
GPQA DiamondDeepGrove model card · Aug 2026
73.5

Pricing and access

Open-source model card; no hosted API pricing found in the official source. Local inference costs depend on user hardware and runtime.

DeepGrove logo
DeepGroveai lab

Efficient low-precision language models for devices

Founded 2026Unknown
View full profile