"""tools/mtp_fetch.py - plan v0.3, P0.3/P6: the MTP block from the BF16 checkpoint, without the checkpoint. The GSQ-RCO GGUF ships no MTP head. The BF16 checkpoint (Qwen/Qwen3.8-Flash-Next, 360 GB in 131 shards) does: 31 `mtp.*` tensors scattered over 28 shards. Safetensors puts a JSON header (name -> dtype, shape, byte range) at the start of each shard, so HTTP range requests can read the headers and then only the MTP tensors. python tools/mtp_fetch.py inventory --out DIR # headers only (a few KB per shard) python tools/mtp_fetch.py fetch --out DIR [--only SUBSTR] # the MTP tensors themselves, resumable `fetch` writes one raw file per tensor plus `mtp-manifest.json` (dtype, shape, source shard, byte range, sha256). It never downloads anything but the ranges named in the headers. Nothing here runs a model. """ import argparse import hashlib import json import os import struct import sys import time import urllib.request REPO = "https://huggingface.co/Qwen/Qwen3.8-Flash-Next/resolve/main/" DTYPE_BYTES = {"BF16": 2, "F16": 2, "F32": 4, "F8_E4M3": 1, "I64": 8, "I32": 4} def get(url, start=None, end=None, retries=4): for attempt in range(retries): try: req = urllib.request.Request(url, headers={"User-Agent": "strata-mtp-fetch"}) if start is not None: req.add_header("Range", "bytes=%d-%d" % (start, end)) with urllib.request.urlopen(req, timeout=120) as r: data = r.read() if start is not None and len(data) != end - start + 1: raise IOError("short range read: %d of %d" % (len(data), end - start + 1)) return data except Exception as e: # network errors are retried, then surfaced if attempt == retries - 1: raise time.sleep(2 ** attempt) print("retry %s: %s" % (url, e), file=sys.stderr) def shard_header(shard): url = REPO + shard n = struct.unpack("