Verify uploaded Source identities and provide a pinned 27-Source downloader
Browse files
basis/releases/source_ratios_20260917/README.md
CHANGED
|
@@ -14,18 +14,18 @@ Added 2026-09-17. These files fill the seven missing method/backbone/ratio candi
|
|
| 14 |
|
| 15 |
## Download and load
|
| 16 |
|
| 17 |
-
Existing BASIS checkouts may pin an older manifest. This standalone command
|
| 18 |
|
| 19 |
```python
|
| 20 |
import json
|
| 21 |
from pathlib import Path
|
| 22 |
-
from huggingface_hub import
|
| 23 |
from basis.compression.checkpoints import load_checkpoint
|
| 24 |
from basis.utils.io import sha256_file
|
| 25 |
|
| 26 |
repo = "Duke-CEI-SVD/FlashSVD"
|
| 27 |
source_id = "qwen3/swiftsvd_r050"
|
| 28 |
-
revision =
|
| 29 |
root = Path("data/flashsvd")
|
| 30 |
snapshot_download(repo, revision=revision, local_dir=root,
|
| 31 |
allow_patterns=[f"basis/sources/{source_id}/*"])
|
|
@@ -47,3 +47,13 @@ All seven use `kind=null` in the Source record and a native BASIS `model.pt`; th
|
|
| 47 |
- Suggested BASIS capacity is recorded and lies within 11M ±5%. Full recovery preflight, Avg7, pressure, and three-seed recovery remain subsequent experiments. New Sources must not silently reuse old gradient caches.
|
| 48 |
- The seven checkpoints total 67.324 GiB. Per-Source `provenance/manifest.json` retains construction/calibration lineage; `validation.json` records the local checks. [Aggregate audit](validation.json).
|
| 49 |
- All prior Source entries and identities are preserved. The package now has 27 Sources: 23 hosted checkpoints and four pinned LowRankArena imports. Prior frozen revisions remain available.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
## Download and load
|
| 16 |
|
| 17 |
+
Existing BASIS checkouts may pin an older manifest. This standalone command pins the verified release commit and downloads one complete Source; change `source_id` for another row above. Install `huggingface_hub` and the BASIS package in the usual environment.
|
| 18 |
|
| 19 |
```python
|
| 20 |
import json
|
| 21 |
from pathlib import Path
|
| 22 |
+
from huggingface_hub import snapshot_download
|
| 23 |
from basis.compression.checkpoints import load_checkpoint
|
| 24 |
from basis.utils.io import sha256_file
|
| 25 |
|
| 26 |
repo = "Duke-CEI-SVD/FlashSVD"
|
| 27 |
source_id = "qwen3/swiftsvd_r050"
|
| 28 |
+
revision = "08d28e1337c4fec6a106c959c4ca8a6e2a0d6acb" # verified release commit
|
| 29 |
root = Path("data/flashsvd")
|
| 30 |
snapshot_download(repo, revision=revision, local_dir=root,
|
| 31 |
allow_patterns=[f"basis/sources/{source_id}/*"])
|
|
|
|
| 47 |
- Suggested BASIS capacity is recorded and lies within 11M ±5%. Full recovery preflight, Avg7, pressure, and three-seed recovery remain subsequent experiments. New Sources must not silently reuse old gradient caches.
|
| 48 |
- The seven checkpoints total 67.324 GiB. Per-Source `provenance/manifest.json` retains construction/calibration lineage; `validation.json` records the local checks. [Aggregate audit](validation.json).
|
| 49 |
- All prior Source entries and identities are preserved. The package now has 27 Sources: 23 hosted checkpoints and four pinned LowRankArena imports. Prior frozen revisions remain available.
|
| 50 |
+
|
| 51 |
+
## Updated selective downloader
|
| 52 |
+
|
| 53 |
+
Download [download_inputs.py](download_inputs.py) and [data_bundle.json](data_bundle.json) into the same folder, then run:
|
| 54 |
+
|
| 55 |
+
```bash
|
| 56 |
+
python download_inputs.py --source qwen3/swiftsvd_r050 --output data/flashsvd
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
This pinned registry includes all 27 Sources. [Remote publication checks](publication_validation.json) verify the new weights and unchanged prior files.
|
basis/releases/source_ratios_20260917/data_bundle.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"status": "published",
|
| 3 |
+
"repo_id": "Duke-CEI-SVD/FlashSVD",
|
| 4 |
+
"revision": "08d28e1337c4fec6a106c959c4ca8a6e2a0d6acb",
|
| 5 |
+
"manifest_path": "basis/manifest.json",
|
| 6 |
+
"manifest_sha256": "81b74f1fab6c7aaf040e174a1a8f5046f0f8dafee035ec2cf01b76502e4fe0c7",
|
| 7 |
+
"publication": "pull_request",
|
| 8 |
+
"pr_url": "https://huggingface.co/Duke-CEI-SVD/FlashSVD/discussions/2",
|
| 9 |
+
"data_bytes": 4728774592,
|
| 10 |
+
"source_bytes": 264095245023,
|
| 11 |
+
"external_weight_bytes": 53054325445,
|
| 12 |
+
"source_count": 27,
|
| 13 |
+
"full_checkpoints_in_flashsvd": 23,
|
| 14 |
+
"sources_reusing_lowrankarena": 4
|
| 15 |
+
}
|
basis/releases/source_ratios_20260917/download_inputs.py
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Download selected frozen BASIS inputs and verify their SHA-256 checksums."""
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import argparse
|
| 6 |
+
import hashlib
|
| 7 |
+
import json
|
| 8 |
+
import os
|
| 9 |
+
import shutil
|
| 10 |
+
from concurrent.futures import ThreadPoolExecutor
|
| 11 |
+
from pathlib import Path
|
| 12 |
+
|
| 13 |
+
BUNDLE = Path(__file__).with_name('data_bundle.json')
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def sha256(path):
|
| 17 |
+
digest = hashlib.sha256()
|
| 18 |
+
with Path(path).open('rb') as stream:
|
| 19 |
+
for block in iter(lambda: stream.read(8 * 1024 * 1024), b''):
|
| 20 |
+
digest.update(block)
|
| 21 |
+
return digest.hexdigest()
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def select_files(manifest, groups, source_ids):
|
| 25 |
+
available_groups = {r['group'] for r in manifest['files']} - {'sources'}
|
| 26 |
+
unknown = set(groups) - available_groups
|
| 27 |
+
sources = {s['id']: s for s in manifest['sources']}
|
| 28 |
+
if unknown or set(source_ids) - sources.keys():
|
| 29 |
+
raise ValueError(f'Unknown groups or Sources: {sorted(unknown | (set(source_ids) - sources.keys()))}')
|
| 30 |
+
selected = []
|
| 31 |
+
prefixes = tuple(f'basis/sources/{s}/' for s in source_ids)
|
| 32 |
+
for record in manifest['files']:
|
| 33 |
+
path = Path(record['path'])
|
| 34 |
+
if path.is_absolute() or '..' in path.parts or path.parts[0] != 'basis':
|
| 35 |
+
raise ValueError(f'Invalid package path: {path}')
|
| 36 |
+
if record['group'] in set(groups) | {'provenance'} or (prefixes and record['path'].startswith(prefixes)):
|
| 37 |
+
selected.append(record)
|
| 38 |
+
return selected
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def verify_files(records, root):
|
| 42 |
+
for record in records:
|
| 43 |
+
path = root / record['path']
|
| 44 |
+
if path.stat().st_size != record['bytes'] or sha256(path) != record['sha256']:
|
| 45 |
+
raise ValueError(f'Checksum mismatch: {path}')
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def download_external(records, root):
|
| 49 |
+
"""Reuse pinned LowRankArena files and assemble the declared local layout."""
|
| 50 |
+
from huggingface_hub import hf_hub_download
|
| 51 |
+
|
| 52 |
+
def fetch(record):
|
| 53 |
+
remote = record['download']
|
| 54 |
+
target = root / record['path']
|
| 55 |
+
if target.is_file() and target.stat().st_size == record['bytes'] and sha256(target) == record['sha256']:
|
| 56 |
+
return
|
| 57 |
+
cached = Path(hf_hub_download(remote['repo_id'], remote['path'],
|
| 58 |
+
revision=remote['revision'], cache_dir=root / '.cache' / 'external')).resolve()
|
| 59 |
+
if sha256(cached) != record['sha256']:
|
| 60 |
+
raise ValueError(f'External checksum mismatch: {remote["path"]}')
|
| 61 |
+
target.parent.mkdir(parents=True, exist_ok=True)
|
| 62 |
+
if target.exists() or target.is_symlink():
|
| 63 |
+
target.unlink()
|
| 64 |
+
try:
|
| 65 |
+
os.link(cached, target)
|
| 66 |
+
except OSError:
|
| 67 |
+
shutil.copyfile(cached, target)
|
| 68 |
+
|
| 69 |
+
with ThreadPoolExecutor(max_workers=4) as pool:
|
| 70 |
+
list(pool.map(fetch, records))
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def write_path_map(manifest, root, revision):
|
| 74 |
+
# This maps the full inventory; only requested groups have been downloaded.
|
| 75 |
+
paths = {r['original_path']: str(root / r['path']) for r in manifest['files']}
|
| 76 |
+
paths.update({s['original_path']: str(root / s['path']) for s in manifest['sources']})
|
| 77 |
+
target = root / 'basis' / 'path_map.json'
|
| 78 |
+
target.write_text(json.dumps({
|
| 79 |
+
'repo_id': manifest['repo_id'], 'revision': revision,
|
| 80 |
+
'note': 'Full inventory mapping; check that an input was downloaded before use.',
|
| 81 |
+
'paths': paths, 'dense_parents': manifest['dense_parents'],
|
| 82 |
+
}, indent=2) + '\n')
|
| 83 |
+
return target
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
def main():
|
| 87 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 88 |
+
parser.add_argument('--group', action='append', default=[], help='Repeat for c4, c4_probe_shard, q64, q128, q64_gradients, q128_gradients, tokenizers, or provenance')
|
| 89 |
+
parser.add_argument('--source', action='append', default=[], help='Exact Source ID, e.g. llama31/swiftsvd_r080; repeat as needed')
|
| 90 |
+
parser.add_argument('--output', type=Path, default=Path('data/flashsvd'))
|
| 91 |
+
parser.add_argument('--list', action='store_true', help='List available input groups and Sources')
|
| 92 |
+
parser.add_argument('--dry-run', action='store_true', help='Show selected sizes; download only the small manifest')
|
| 93 |
+
args = parser.parse_args()
|
| 94 |
+
bundle = json.loads(BUNDLE.read_text())
|
| 95 |
+
if bundle.get('status') != 'published' or not bundle.get('revision'):
|
| 96 |
+
parser.error('The package is prepared but has not yet been published. See paper/DOWNLOADS.md.')
|
| 97 |
+
from huggingface_hub import hf_hub_download, snapshot_download
|
| 98 |
+
root = args.output.expanduser().resolve()
|
| 99 |
+
manifest_path = hf_hub_download(bundle['repo_id'], bundle['manifest_path'],
|
| 100 |
+
revision=bundle['revision'], local_dir=root)
|
| 101 |
+
if sha256(manifest_path) != bundle['manifest_sha256']:
|
| 102 |
+
raise ValueError('Package manifest checksum mismatch')
|
| 103 |
+
manifest = json.loads(Path(manifest_path).read_text())
|
| 104 |
+
if args.list:
|
| 105 |
+
for group in sorted({r['group'] for r in manifest['files']} - {'sources'}):
|
| 106 |
+
records = [r for r in manifest['files'] if r['group'] == group]
|
| 107 |
+
print(f'{group}: {len(records)} files, {sum(r["bytes"] for r in records) / 2**30:.3f} GiB')
|
| 108 |
+
for source in manifest['sources']:
|
| 109 |
+
print(f'Source {source["id"]}: Tasks {", ".join(source["tasks"])}')
|
| 110 |
+
return
|
| 111 |
+
if not args.group and not args.source:
|
| 112 |
+
parser.error('Select --group / --source, or use --list.')
|
| 113 |
+
selected = select_files(manifest, args.group, args.source)
|
| 114 |
+
print(f'Selected {len(selected)} files, {sum(r["bytes"] for r in selected) / 2**30:.3f} GiB')
|
| 115 |
+
if args.dry_run:
|
| 116 |
+
return
|
| 117 |
+
local = [r for r in selected if 'download' not in r]
|
| 118 |
+
external = [r for r in selected if 'download' in r]
|
| 119 |
+
if local:
|
| 120 |
+
snapshot_download(bundle['repo_id'], revision=bundle['revision'], local_dir=root,
|
| 121 |
+
allow_patterns=[r['path'] for r in local], max_workers=4)
|
| 122 |
+
if external:
|
| 123 |
+
print(f'Reusing {len(external)} weight files from LowRankArena.')
|
| 124 |
+
download_external(external, root)
|
| 125 |
+
verify_files(selected, root)
|
| 126 |
+
print('Verified every selected file. Path map:', write_path_map(manifest, root, bundle['revision']))
|
| 127 |
+
print('Create fresh task manifests using these paths; preserve the original frozen manifests.')
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
if __name__ == '__main__':
|
| 131 |
+
main()
|
basis/releases/source_ratios_20260917/publication_validation.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"status": "passed",
|
| 3 |
+
"verified_revision": "08d28e1337c4fec6a106c959c4ca8a6e2a0d6acb",
|
| 4 |
+
"uploaded_objects_verified": 35,
|
| 5 |
+
"new_weight_files_verified": 7,
|
| 6 |
+
"new_source_count": 7,
|
| 7 |
+
"source_count": 27,
|
| 8 |
+
"weight_verification": "All seven remote LFS byte counts and SHA256 identities match freshly hashed local artifacts",
|
| 9 |
+
"metadata_verification": "Git blob IDs or LFS identities match for every uploaded metadata object",
|
| 10 |
+
"original_files_preserved": 586,
|
| 11 |
+
"original_source_records_preserved": 20,
|
| 12 |
+
"anonymous_manifest_and_seven_source_records_downloaded": true,
|
| 13 |
+
"manifest_sha256": "81b74f1fab6c7aaf040e174a1a8f5046f0f8dafee035ec2cf01b76502e4fe0c7"
|
| 14 |
+
}
|