Add pinned speculative metadata runtime wheels
Browse files- .gitattributes +2 -0
- README.md +17 -0
- package-vllm-speculative-runtime.py +485 -0
- test_package_vllm_speculative_runtime.py +318 -0
- vllm-0.24.0+mayhem.specmeta1-cp38-abi3-manylinux_2_28_aarch64.whl +3 -0
- vllm-0.24.0+mayhem.specmeta1-cp38-abi3-manylinux_2_28_aarch64.whl.provenance.json +72 -0
- vllm-0.24.0+mayhem.specmeta1-cp38-abi3-manylinux_2_28_x86_64.whl +3 -0
- vllm-0.24.0+mayhem.specmeta1-cp38-abi3-manylinux_2_28_x86_64.whl.provenance.json +72 -0
- vllm-specmeta-v1.patch +149 -0
.gitattributes
CHANGED
|
@@ -58,3 +58,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 58 |
# Video files - compressed
|
| 59 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 60 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 58 |
# Video files - compressed
|
| 59 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 60 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
| 61 |
+
vllm-0.24.0+mayhem.specmeta1-cp38-abi3-manylinux_2_28_aarch64.whl filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
vllm-0.24.0+mayhem.specmeta1-cp38-abi3-manylinux_2_28_x86_64.whl filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
---
|
| 4 |
+
# OpenMayhem Runtime Wheels
|
| 5 |
+
|
| 6 |
+
vLLM 0.24.0 downstream runtime with the speculative FlashInfer host-metadata
|
| 7 |
+
lifetime fix. The original upstream native binaries, dependencies, licenses,
|
| 8 |
+
and platform metadata are preserved. This is not an official vLLM release.
|
| 9 |
+
|
| 10 |
+
Each wheel has a SHA-256 provenance record. The source patch, regression test,
|
| 11 |
+
and offline reproducible packager are included. Source base:
|
| 12 |
+
https://github.com/vllm-project/vllm/commit/ee0da84ab9e04ac7610e28580af62c365e898389
|
| 13 |
+
|
| 14 |
+
The change extends the existing ModelRunnerV2 host-buffer lifetime guard to
|
| 15 |
+
speculative decoding. Non-speculative V1 decoding retains its existing behavior.
|
| 16 |
+
It does not introduce global GPU synchronization or change native kernels.
|
| 17 |
+
Consumers must use an immutable repository revision and verify the wheel hash.
|
package-vllm-speculative-runtime.py
ADDED
|
@@ -0,0 +1,485 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Offline, pinned vLLM wheel rewrite; never import/build/install wheel code.
|
| 3 |
+
|
| 4 |
+
ZIP_STORED, sorted members, fixed timestamps and canonical permissions make
|
| 5 |
+
outputs reproducible without depending on a particular zlib version. Native
|
| 6 |
+
members are streamed, not buffered. The adjacent JSON is deterministic too.
|
| 7 |
+
|
| 8 |
+
--source-checkout needs only vllm/v1/attention/backends/flashinfer.py plus either:
|
| 9 |
+
* .git with HEAD at FIX_COMMIT, its pinned parent, the backend's tree objects,
|
| 10 |
+
and a clean backend index entry (other worktree files may be absent); or
|
| 11 |
+
* vllm-specmeta-source.json containing exactly base_commit, fix_commit and
|
| 12 |
+
backend_sha256, with the pinned values below. No Git state is needed for
|
| 13 |
+
this export form. The manifest is an identity declaration, not a signature;
|
| 14 |
+
the backend bytes are always independently checked against the built-in SHA.
|
| 15 |
+
No tests, _version.py, setup.py, dependencies or build artifacts are needed in
|
| 16 |
+
the source tree. _version.py is read only from the pinned upstream wheel.
|
| 17 |
+
"""
|
| 18 |
+
|
| 19 |
+
import argparse
|
| 20 |
+
import ast
|
| 21 |
+
import base64
|
| 22 |
+
import csv
|
| 23 |
+
from email import policy
|
| 24 |
+
from email.parser import BytesParser
|
| 25 |
+
import hashlib
|
| 26 |
+
import io
|
| 27 |
+
import json
|
| 28 |
+
import os
|
| 29 |
+
from pathlib import Path
|
| 30 |
+
import stat
|
| 31 |
+
import subprocess
|
| 32 |
+
import tempfile
|
| 33 |
+
import zipfile
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
BASE_COMMIT = "ee0da84ab9e04ac7610e28580af62c365e898389"
|
| 37 |
+
FIX_COMMIT = "9a9cbb67ac23d78cf7384650b561ce7b122f770b"
|
| 38 |
+
OLD_BACKEND_SHA = "ce9071eade3d1a9c7dc9dd9f187212599e1c20058ffda901d6950b9dcde19913"
|
| 39 |
+
NEW_BACKEND_SHA = "01678024fc88e5f031b866fd6affbb0d82917c271938d8c5878fa0e68c023ab5"
|
| 40 |
+
UPSTREAM_HASHES = {
|
| 41 |
+
"vllm-0.24.0-cp38-abi3-manylinux_2_28_aarch64.whl":
|
| 42 |
+
"700db71c3cf14697d42583521f38b12fac38db1e7a8ad062e8e4d63a5dadebd5",
|
| 43 |
+
"vllm-0.24.0-cp38-abi3-manylinux_2_28_x86_64.whl":
|
| 44 |
+
"2d2831aeba311292250df0132dbc4d8e9f42c654536eaec48e6fe58acb1822cf",
|
| 45 |
+
}
|
| 46 |
+
UPSTREAM_WHEEL_TAGS = {
|
| 47 |
+
"vllm-0.24.0-cp38-abi3-manylinux_2_28_aarch64.whl":
|
| 48 |
+
["cp38-abi3-linux_aarch64"],
|
| 49 |
+
"vllm-0.24.0-cp38-abi3-manylinux_2_28_x86_64.whl":
|
| 50 |
+
["cp38-abi3-linux_x86_64"],
|
| 51 |
+
}
|
| 52 |
+
VERSION = "0.24.0+mayhem.specmeta1"
|
| 53 |
+
BACKEND = "vllm/v1/attention/backends/flashinfer.py"
|
| 54 |
+
VERSION_FILE = "vllm/_version.py"
|
| 55 |
+
DIST = "vllm-0.24.0.dist-info"
|
| 56 |
+
NEW_DIST = "vllm-" + VERSION + ".dist-info"
|
| 57 |
+
RECORD = DIST + "/RECORD"
|
| 58 |
+
CHUNK = 1024 * 1024
|
| 59 |
+
MAX_ARCHIVE = 16 * 1024**3
|
| 60 |
+
MAX_MEMBER = 8 * 1024**3
|
| 61 |
+
MAX_TOTAL = 32 * 1024**3
|
| 62 |
+
MAX_SMALL = 16 * 1024**2
|
| 63 |
+
MAX_CENTRAL = 32 * 1024**2
|
| 64 |
+
MAX_ENTRIES = 50000
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
class InvalidWheel(ValueError):
|
| 68 |
+
pass
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def require(condition, message):
|
| 72 |
+
if not condition:
|
| 73 |
+
raise InvalidWheel(message)
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
def sha256(data):
|
| 77 |
+
return hashlib.sha256(data).hexdigest()
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
def digest_stream(stream, sink=None, limit=MAX_ARCHIVE):
|
| 81 |
+
digest, size = hashlib.sha256(), 0
|
| 82 |
+
while True:
|
| 83 |
+
chunk = stream.read(CHUNK)
|
| 84 |
+
if not chunk:
|
| 85 |
+
break
|
| 86 |
+
size += len(chunk)
|
| 87 |
+
require(size <= limit, "stream exceeds size bound")
|
| 88 |
+
digest.update(chunk)
|
| 89 |
+
if sink is not None:
|
| 90 |
+
sink.write(chunk)
|
| 91 |
+
return digest.hexdigest(), size
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
def safe_path(name):
|
| 95 |
+
require(isinstance(name, str) and 0 < len(name) <= 4096,
|
| 96 |
+
"invalid member path length")
|
| 97 |
+
require(not any(ord(c) < 32 or ord(c) == 127 or c in "\\:" for c in name),
|
| 98 |
+
"unsafe member path: " + repr(name))
|
| 99 |
+
parts = name.rstrip("/").split("/")
|
| 100 |
+
require(all(p and p not in (".", "..") and not p.endswith((".", " "))
|
| 101 |
+
for p in parts), "unsafe member path: " + repr(name))
|
| 102 |
+
require(not name.endswith("//"), "unsafe directory path")
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def git(checkout, *args):
|
| 106 |
+
# These are read-only plumbing commands, never diff/filter/build commands.
|
| 107 |
+
env = dict(os.environ, GIT_NO_REPLACE_OBJECTS="1", GIT_OPTIONAL_LOCKS="0")
|
| 108 |
+
for key in list(env):
|
| 109 |
+
if key.startswith("GIT_") and key not in (
|
| 110 |
+
"GIT_NO_REPLACE_OBJECTS", "GIT_OPTIONAL_LOCKS"):
|
| 111 |
+
del env[key]
|
| 112 |
+
result = subprocess.run(
|
| 113 |
+
["git", "-c", "core.fsmonitor=false", "-c", "core.hooksPath=/dev/null",
|
| 114 |
+
"-C", str(checkout), *args], env=env, check=True,
|
| 115 |
+
stdout=subprocess.PIPE, stderr=subprocess.PIPE, timeout=60)
|
| 116 |
+
require(len(result.stdout) <= MAX_CENTRAL, "source listing too large")
|
| 117 |
+
return result.stdout
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def fixed_source(checkout):
|
| 121 |
+
checkout = Path(checkout).resolve(strict=True)
|
| 122 |
+
path = checkout / BACKEND
|
| 123 |
+
require(all(not parent.is_symlink() for parent in
|
| 124 |
+
(path, *path.parents) if parent != checkout), "source symlink rejected")
|
| 125 |
+
require(stat.S_ISREG(path.stat().st_mode), "backend must be a regular file")
|
| 126 |
+
with path.open("rb") as stream:
|
| 127 |
+
backend = stream.read(MAX_SMALL + 1)
|
| 128 |
+
require(len(backend) <= MAX_SMALL and sha256(backend) == NEW_BACKEND_SHA,
|
| 129 |
+
"fixed backend SHA256 mismatch")
|
| 130 |
+
if os.path.lexists(checkout / ".git"):
|
| 131 |
+
require(git(checkout, "rev-parse", "HEAD").strip().decode() == FIX_COMMIT,
|
| 132 |
+
"source HEAD is not the pinned fix commit")
|
| 133 |
+
require(git(checkout, "rev-parse", "HEAD^").strip().decode() == BASE_COMMIT,
|
| 134 |
+
"source parent is not the pinned base commit")
|
| 135 |
+
blob = hashlib.sha1(b"blob " + str(len(backend)).encode() + b"\0" + backend).hexdigest().encode()
|
| 136 |
+
tree = git(checkout, "ls-tree", "--full-tree", "-z", "HEAD", "--", BACKEND)
|
| 137 |
+
# Git owns the tracked mode; transported source bytes need not be executable.
|
| 138 |
+
require(tree in {mode + b" blob " + blob + b"\t" + BACKEND.encode() + b"\0"
|
| 139 |
+
for mode in (b"100644", b"100755")},
|
| 140 |
+
"backend does not match pinned source tree")
|
| 141 |
+
mode = tree.split(b" ", 1)[0]
|
| 142 |
+
require(git(checkout, "ls-files", "--stage", "-z", "--", BACKEND) ==
|
| 143 |
+
mode + b" " + blob + b" 0\t" + BACKEND.encode() + b"\0",
|
| 144 |
+
"source backend index is not clean")
|
| 145 |
+
else:
|
| 146 |
+
manifest = checkout / "vllm-specmeta-source.json"
|
| 147 |
+
require(not manifest.is_symlink() and stat.S_ISREG(manifest.stat().st_mode),
|
| 148 |
+
"source manifest must be regular")
|
| 149 |
+
with manifest.open("rb") as stream:
|
| 150 |
+
data = stream.read(MAX_SMALL + 1)
|
| 151 |
+
require(len(data) <= MAX_SMALL, "source manifest too large")
|
| 152 |
+
require(json.loads(data) == {"base_commit": BASE_COMMIT,
|
| 153 |
+
"fix_commit": FIX_COMMIT,
|
| 154 |
+
"backend_sha256": NEW_BACKEND_SHA},
|
| 155 |
+
"exported source identity mismatch")
|
| 156 |
+
return backend
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
def check_zip_bounds(stream):
|
| 160 |
+
require(os.fstat(stream.fileno()).st_size <= MAX_ARCHIVE, "archive too large")
|
| 161 |
+
# zipfile's bounded EOCD/ZIP64 parser avoids loading a huge central directory.
|
| 162 |
+
end = zipfile._EndRecData(stream)
|
| 163 |
+
require(end is not None, "missing ZIP end record")
|
| 164 |
+
require(end[zipfile._ECD_SIZE] <= MAX_CENTRAL, "central directory too large")
|
| 165 |
+
require(end[zipfile._ECD_ENTRIES_TOTAL] <= MAX_ENTRIES, "too many ZIP entries")
|
| 166 |
+
require(end[zipfile._ECD_DISK_NUMBER] == 0 and
|
| 167 |
+
end[zipfile._ECD_DISK_START] == 0 and
|
| 168 |
+
end[zipfile._ECD_ENTRIES_THIS_DISK] == end[zipfile._ECD_ENTRIES_TOTAL],
|
| 169 |
+
"multidisk ZIP unsupported")
|
| 170 |
+
stream.seek(0)
|
| 171 |
+
|
| 172 |
+
|
| 173 |
+
def inventory(wheel):
|
| 174 |
+
infos, aliases, total = {}, set(), 0
|
| 175 |
+
require(len(wheel.infolist()) <= MAX_ENTRIES, "too many ZIP entries")
|
| 176 |
+
for info in wheel.infolist():
|
| 177 |
+
name = info.filename
|
| 178 |
+
require(info.orig_filename == name, "truncated ZIP path")
|
| 179 |
+
safe_path(name)
|
| 180 |
+
alias = name.rstrip("/").casefold()
|
| 181 |
+
require(alias not in aliases, "duplicate ZIP path: " + name)
|
| 182 |
+
aliases.add(alias)
|
| 183 |
+
mode = stat.S_IFMT(info.external_attr >> 16)
|
| 184 |
+
require(mode in (0, stat.S_IFDIR if info.is_dir() else stat.S_IFREG),
|
| 185 |
+
"symlink or special ZIP member: " + name)
|
| 186 |
+
require(not info.flag_bits & 1 and info.compress_type in
|
| 187 |
+
(zipfile.ZIP_STORED, zipfile.ZIP_DEFLATED),
|
| 188 |
+
"encrypted or unsupported ZIP member")
|
| 189 |
+
require(0 <= info.file_size <= MAX_MEMBER and
|
| 190 |
+
0 <= info.compress_size <= MAX_ARCHIVE, "ZIP member too large")
|
| 191 |
+
require(not info.is_dir() or info.file_size == 0, "nonempty ZIP directory")
|
| 192 |
+
total += info.file_size
|
| 193 |
+
require(total <= MAX_TOTAL, "expanded ZIP too large")
|
| 194 |
+
for part in name.rstrip("/").split("/"):
|
| 195 |
+
require(not part.endswith(".dist-info") or part == DIST,
|
| 196 |
+
"unknown dist-info directory")
|
| 197 |
+
require(name not in (DIST + "/RECORD.jws", DIST + "/RECORD.p7s"),
|
| 198 |
+
"signed RECORD cannot be rewritten")
|
| 199 |
+
infos[name] = info
|
| 200 |
+
files = {n.rstrip("/").casefold() for n, i in infos.items() if not i.is_dir()}
|
| 201 |
+
for name in infos:
|
| 202 |
+
parts = name.rstrip("/").casefold().split("/")
|
| 203 |
+
require(all("/".join(parts[:i]) not in files for i in range(1, len(parts))),
|
| 204 |
+
"ZIP file/directory collision")
|
| 205 |
+
require({BACKEND, VERSION_FILE, RECORD, DIST + "/METADATA", DIST + "/WHEEL"}
|
| 206 |
+
<= infos.keys(), "required wheel member missing")
|
| 207 |
+
return infos
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
def small(wheel, name):
|
| 211 |
+
require(wheel.getinfo(name).file_size <= MAX_SMALL, "metadata member too large")
|
| 212 |
+
with wheel.open(name) as stream:
|
| 213 |
+
data = stream.read(MAX_SMALL + 1)
|
| 214 |
+
require(len(data) <= MAX_SMALL, "metadata exceeds size bound")
|
| 215 |
+
return data
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
def read_record(data, infos):
|
| 219 |
+
rows = {}
|
| 220 |
+
for row in csv.reader(io.StringIO(data.decode("utf-8"), newline=""), strict=True):
|
| 221 |
+
require(len(row) == 3, "invalid RECORD row")
|
| 222 |
+
name, digest, size = row
|
| 223 |
+
safe_path(name)
|
| 224 |
+
require(name not in rows and name in infos and not infos[name].is_dir(),
|
| 225 |
+
"duplicate or unknown RECORD path")
|
| 226 |
+
if name == RECORD:
|
| 227 |
+
require(digest == size == "", "RECORD must not hash itself")
|
| 228 |
+
else:
|
| 229 |
+
require(digest.startswith("sha256=") and len(digest) == 50,
|
| 230 |
+
"RECORD requires SHA256")
|
| 231 |
+
encoded = digest[7:]
|
| 232 |
+
raw = base64.b64decode(encoded + "=", altchars=b"-_", validate=True)
|
| 233 |
+
require(base64.urlsafe_b64encode(raw).decode().rstrip("=") == encoded,
|
| 234 |
+
"noncanonical RECORD hash")
|
| 235 |
+
require(size == str(infos[name].file_size), "RECORD size mismatch")
|
| 236 |
+
rows[name] = (digest, size)
|
| 237 |
+
require(rows.keys() == {n for n, i in infos.items() if not i.is_dir()},
|
| 238 |
+
"RECORD does not cover every file")
|
| 239 |
+
return rows
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
def record_hash(hex_digest):
|
| 243 |
+
return "sha256=" + base64.urlsafe_b64encode(bytes.fromhex(hex_digest)).decode().rstrip("=")
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
def verify_record(name, digest, size, rows):
|
| 247 |
+
if name != RECORD:
|
| 248 |
+
require(rows[name] == (record_hash(digest), str(size)),
|
| 249 |
+
"RECORD hash/size mismatch: " + name)
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
def rewrite_version(data):
|
| 253 |
+
tree = ast.parse(data)
|
| 254 |
+
fields = {
|
| 255 |
+
("__version__", "version"): ("0.24.0", VERSION),
|
| 256 |
+
("__version_tuple__", "version_tuple"):
|
| 257 |
+
((0, 24, 0), (0, 24, 0, "mayhem.specmeta1")),
|
| 258 |
+
("__commit_id__", "commit_id"): ("gee0da84ab", "g" + FIX_COMMIT[:9]),
|
| 259 |
+
}
|
| 260 |
+
names = {name for pair in fields for name in pair}
|
| 261 |
+
lines = data.splitlines(keepends=True)
|
| 262 |
+
offsets = [0]
|
| 263 |
+
for line in lines:
|
| 264 |
+
offsets.append(offsets[-1] + len(line))
|
| 265 |
+
edits, seen = [], set()
|
| 266 |
+
for node in tree.body:
|
| 267 |
+
if isinstance(node, ast.Assign):
|
| 268 |
+
require(all(isinstance(t, ast.Name) for t in node.targets),
|
| 269 |
+
"unknown version assignment")
|
| 270 |
+
keys = tuple(t.id for t in node.targets)
|
| 271 |
+
if keys == ("__all__",):
|
| 272 |
+
require(set(ast.literal_eval(node.value)) == names,
|
| 273 |
+
"unknown version exports")
|
| 274 |
+
continue
|
| 275 |
+
require(keys in fields and keys not in seen, "unknown version fields")
|
| 276 |
+
old, new = fields[keys]
|
| 277 |
+
require(ast.literal_eval(node.value) == old, "unknown original version")
|
| 278 |
+
seen.add(keys)
|
| 279 |
+
value = node.value
|
| 280 |
+
start = offsets[value.lineno - 1] + value.col_offset
|
| 281 |
+
end = offsets[value.end_lineno - 1] + value.end_col_offset
|
| 282 |
+
edits.append((start, end, repr(new).encode("ascii")))
|
| 283 |
+
elif isinstance(node, ast.AnnAssign):
|
| 284 |
+
require(isinstance(node.target, ast.Name) and node.target.id in names
|
| 285 |
+
and node.value is None, "unknown version annotation")
|
| 286 |
+
elif isinstance(node, ast.ImportFrom):
|
| 287 |
+
require(node.level == 0 and node.module in ("__future__", "typing")
|
| 288 |
+
and all(n.asname is None and n.name in
|
| 289 |
+
("annotations", "Tuple", "Union") for n in node.names),
|
| 290 |
+
"unknown version import")
|
| 291 |
+
else:
|
| 292 |
+
require(isinstance(node, ast.Expr) and isinstance(node.value, ast.Constant)
|
| 293 |
+
and isinstance(node.value.value, str), "unknown version schema")
|
| 294 |
+
require(seen == fields.keys(), "missing version fields")
|
| 295 |
+
for start, end, replacement in sorted(edits, reverse=True):
|
| 296 |
+
data = data[:start] + replacement + data[end:]
|
| 297 |
+
return data
|
| 298 |
+
|
| 299 |
+
|
| 300 |
+
def headers(data):
|
| 301 |
+
message = BytesParser(policy=policy.compat32).parsebytes(data)
|
| 302 |
+
require(not message.defects, "malformed wheel metadata")
|
| 303 |
+
return message
|
| 304 |
+
|
| 305 |
+
|
| 306 |
+
def rewrite_metadata(data):
|
| 307 |
+
message = headers(data)
|
| 308 |
+
require(message.get_all("Name") == ["vllm"] and
|
| 309 |
+
message.get_all("Version") == ["0.24.0"], "unknown original METADATA")
|
| 310 |
+
# Parse structurally, but splice only this header to preserve dependencies,
|
| 311 |
+
# license fields and the description byte-for-byte (email reserializes them).
|
| 312 |
+
lines = data.splitlines(keepends=True)
|
| 313 |
+
for i, line in enumerate(lines):
|
| 314 |
+
if line in (b"\n", b"\r\n"):
|
| 315 |
+
break
|
| 316 |
+
if line.lower().startswith(b"version:"):
|
| 317 |
+
ending = b"\r\n" if line.endswith(b"\r\n") else b"\n"
|
| 318 |
+
require(line.rstrip(b"\r\n").split(b":", 1)[1].strip() == b"0.24.0"
|
| 319 |
+
and (i + 1 == len(lines) or not lines[i + 1].startswith((b" ", b"\t"))),
|
| 320 |
+
"unknown Version header encoding")
|
| 321 |
+
lines[i] = line.split(b":", 1)[0] + b": " + VERSION.encode() + ending
|
| 322 |
+
return b"".join(lines)
|
| 323 |
+
raise InvalidWheel("missing Version header")
|
| 324 |
+
|
| 325 |
+
|
| 326 |
+
def renamed(name):
|
| 327 |
+
return NEW_DIST + name[len(DIST):] if name == DIST + "/" or name.startswith(DIST + "/") else name
|
| 328 |
+
|
| 329 |
+
|
| 330 |
+
def write_wheel(source, target, infos, rows, replacements):
|
| 331 |
+
records, changes = [], []
|
| 332 |
+
with zipfile.ZipFile(target, "w", compression=zipfile.ZIP_STORED,
|
| 333 |
+
allowZip64=True) as output:
|
| 334 |
+
for name in sorted(infos, key=renamed):
|
| 335 |
+
if name == RECORD:
|
| 336 |
+
continue
|
| 337 |
+
original = infos[name]
|
| 338 |
+
new_name = renamed(name)
|
| 339 |
+
info = zipfile.ZipInfo(new_name, date_time=(1980, 1, 1, 0, 0, 0))
|
| 340 |
+
info.create_system = 3
|
| 341 |
+
mode = 0o755 if original.is_dir() or original.external_attr >> 16 & 0o111 else 0o644
|
| 342 |
+
info.external_attr = ((stat.S_IFDIR if original.is_dir() else stat.S_IFREG) | mode) << 16
|
| 343 |
+
if original.is_dir():
|
| 344 |
+
info.external_attr |= 0x10
|
| 345 |
+
info.file_size = len(replacements[name]) if name in replacements else original.file_size
|
| 346 |
+
with output.open(info, "w", force_zip64=info.file_size >= 2**31) as sink:
|
| 347 |
+
if name in replacements:
|
| 348 |
+
data = replacements[name]
|
| 349 |
+
sink.write(data)
|
| 350 |
+
digest, size = sha256(data), len(data)
|
| 351 |
+
old_digest = sha256(small(source, name))
|
| 352 |
+
else:
|
| 353 |
+
with source.open(original) as stream:
|
| 354 |
+
digest, size = digest_stream(stream, sink, original.file_size)
|
| 355 |
+
old_digest = digest
|
| 356 |
+
if not original.is_dir():
|
| 357 |
+
verify_record(name, digest, size, rows)
|
| 358 |
+
if not original.is_dir():
|
| 359 |
+
records.append((new_name, record_hash(digest), str(size)))
|
| 360 |
+
if name != new_name or name in replacements:
|
| 361 |
+
changes.append({"original": name, "output": new_name,
|
| 362 |
+
"original_sha256": old_digest, "sha256": digest})
|
| 363 |
+
record_text = io.StringIO(newline="")
|
| 364 |
+
writer = csv.writer(record_text, lineterminator="\n")
|
| 365 |
+
writer.writerows(sorted(records + [(renamed(RECORD), "", "")]))
|
| 366 |
+
record_data = record_text.getvalue().encode("utf-8")
|
| 367 |
+
info = zipfile.ZipInfo(renamed(RECORD), (1980, 1, 1, 0, 0, 0))
|
| 368 |
+
info.create_system = 3
|
| 369 |
+
info.external_attr = (stat.S_IFREG | 0o644) << 16
|
| 370 |
+
output.writestr(info, record_data)
|
| 371 |
+
changes.append({"original": RECORD, "output": renamed(RECORD),
|
| 372 |
+
"original_sha256": sha256(small(source, RECORD)),
|
| 373 |
+
"sha256": sha256(record_data)})
|
| 374 |
+
return sorted(changes, key=lambda row: row["output"])
|
| 375 |
+
|
| 376 |
+
|
| 377 |
+
def _package(wheel_path, output_dir, backend, expected_input_sha):
|
| 378 |
+
"""Internal fixture seam; the public entry point always selects pinned hashes."""
|
| 379 |
+
wheel_path, output_dir = Path(wheel_path), Path(output_dir)
|
| 380 |
+
require(wheel_path.name in UPSTREAM_HASHES, "unapproved upstream wheel filename")
|
| 381 |
+
require(sha256(backend) == NEW_BACKEND_SHA, "fixed backend SHA256 mismatch")
|
| 382 |
+
output_name = wheel_path.name.replace("vllm-0.24.0-", "vllm-" + VERSION + "-", 1)
|
| 383 |
+
destinations = [output_dir / output_name, output_dir / (output_name + ".provenance.json")]
|
| 384 |
+
owned, success = {}, False
|
| 385 |
+
|
| 386 |
+
def remember(path):
|
| 387 |
+
info = path.lstat()
|
| 388 |
+
owned[path] = (info.st_dev, info.st_ino)
|
| 389 |
+
|
| 390 |
+
try:
|
| 391 |
+
with wheel_path.open("rb") as stream:
|
| 392 |
+
require(stat.S_ISREG(os.fstat(stream.fileno()).st_mode), "wheel must be regular")
|
| 393 |
+
check_zip_bounds(stream)
|
| 394 |
+
input_sha, input_size = digest_stream(stream)
|
| 395 |
+
require(input_sha == expected_input_sha, "upstream wheel SHA256 mismatch")
|
| 396 |
+
stream.seek(0)
|
| 397 |
+
with zipfile.ZipFile(stream) as source:
|
| 398 |
+
infos = inventory(source)
|
| 399 |
+
rows = read_record(small(source, RECORD), infos)
|
| 400 |
+
originals = {n: small(source, n) for n in
|
| 401 |
+
(BACKEND, VERSION_FILE, DIST + "/METADATA", DIST + "/WHEEL")}
|
| 402 |
+
for name, data in originals.items():
|
| 403 |
+
verify_record(name, sha256(data), len(data), rows)
|
| 404 |
+
require(sha256(originals[BACKEND]) == OLD_BACKEND_SHA,
|
| 405 |
+
"unknown original backend SHA256")
|
| 406 |
+
wheel_headers = headers(originals[DIST + "/WHEEL"])
|
| 407 |
+
# Pinned upstream metadata may differ from the published filename.
|
| 408 |
+
require(wheel_headers.get_all("Tag") == UPSTREAM_WHEEL_TAGS[wheel_path.name] and
|
| 409 |
+
wheel_headers.get_all("Wheel-Version") == ["1.0"] and
|
| 410 |
+
wheel_headers.get_all("Root-Is-Purelib") == ["false"],
|
| 411 |
+
"unknown original WHEEL metadata")
|
| 412 |
+
replacements = {BACKEND: backend,
|
| 413 |
+
VERSION_FILE: rewrite_version(originals[VERSION_FILE]),
|
| 414 |
+
DIST + "/METADATA": rewrite_metadata(originals[DIST + "/METADATA"])}
|
| 415 |
+
output_dir.mkdir(parents=True, exist_ok=True)
|
| 416 |
+
require(not any(os.path.lexists(p) for p in destinations), "output already exists")
|
| 417 |
+
with tempfile.NamedTemporaryFile(prefix=".vllm-", suffix=".tmp",
|
| 418 |
+
dir=output_dir, delete=False) as target:
|
| 419 |
+
temporary = Path(target.name)
|
| 420 |
+
remember(temporary)
|
| 421 |
+
changes = write_wheel(source, target, infos, rows, replacements)
|
| 422 |
+
target.flush()
|
| 423 |
+
os.fsync(target.fileno())
|
| 424 |
+
# Detect an input changed during streaming, including ZIP headers.
|
| 425 |
+
stream.seek(0)
|
| 426 |
+
require(digest_stream(stream) == (input_sha, input_size),
|
| 427 |
+
"upstream wheel changed during packaging")
|
| 428 |
+
with temporary.open("rb") as stream:
|
| 429 |
+
output_sha, output_size = digest_stream(stream, limit=MAX_TOTAL + MAX_CENTRAL)
|
| 430 |
+
provenance = {
|
| 431 |
+
"schema_version": 1, "upstream_version": "0.24.0", "version": VERSION,
|
| 432 |
+
"base_commit": BASE_COMMIT, "fix_commit": FIX_COMMIT,
|
| 433 |
+
"backend": {"path": BACKEND, "original_sha256": OLD_BACKEND_SHA,
|
| 434 |
+
"sha256": NEW_BACKEND_SHA},
|
| 435 |
+
"upstream_wheel": {"filename": wheel_path.name, "sha256": input_sha, "size": input_size},
|
| 436 |
+
"output_wheel": {"filename": output_name, "sha256": output_sha, "size": output_size},
|
| 437 |
+
"changed_members": changes,
|
| 438 |
+
}
|
| 439 |
+
with tempfile.NamedTemporaryFile(prefix=".vllm-", suffix=".tmp",
|
| 440 |
+
dir=output_dir, delete=False) as target:
|
| 441 |
+
sidecar = Path(target.name)
|
| 442 |
+
remember(sidecar)
|
| 443 |
+
target.write((json.dumps(provenance, sort_keys=True, indent=2) + "\n").encode())
|
| 444 |
+
target.flush()
|
| 445 |
+
os.fsync(target.fileno())
|
| 446 |
+
for temporary_path, destination in zip((temporary, sidecar), destinations):
|
| 447 |
+
os.link(temporary_path, destination) # Atomic publication, never overwrite.
|
| 448 |
+
owned[destination] = owned[temporary_path]
|
| 449 |
+
success = True
|
| 450 |
+
return tuple(destinations)
|
| 451 |
+
finally:
|
| 452 |
+
for path, identity in owned.items():
|
| 453 |
+
if success and path in destinations:
|
| 454 |
+
continue
|
| 455 |
+
try:
|
| 456 |
+
info = path.lstat()
|
| 457 |
+
if (info.st_dev, info.st_ino) == identity:
|
| 458 |
+
path.unlink()
|
| 459 |
+
except FileNotFoundError:
|
| 460 |
+
pass
|
| 461 |
+
|
| 462 |
+
|
| 463 |
+
def package(upstream_wheel, source_checkout, output_dir):
|
| 464 |
+
name = Path(upstream_wheel).name
|
| 465 |
+
require(name in UPSTREAM_HASHES, "unapproved upstream wheel filename")
|
| 466 |
+
return _package(upstream_wheel, output_dir, fixed_source(source_checkout),
|
| 467 |
+
UPSTREAM_HASHES[name])
|
| 468 |
+
|
| 469 |
+
|
| 470 |
+
def main():
|
| 471 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 472 |
+
parser.add_argument("--upstream-wheel", required=True, type=Path)
|
| 473 |
+
parser.add_argument("--source-checkout", required=True, type=Path)
|
| 474 |
+
parser.add_argument("--output-dir", required=True, type=Path)
|
| 475 |
+
args = parser.parse_args()
|
| 476 |
+
try:
|
| 477 |
+
for path in package(args.upstream_wheel, args.source_checkout, args.output_dir):
|
| 478 |
+
print(path)
|
| 479 |
+
except (ValueError, OSError, SyntaxError, csv.Error, zipfile.BadZipFile,
|
| 480 |
+
RuntimeError, subprocess.SubprocessError) as error:
|
| 481 |
+
parser.exit(1, "packaging failed: " + str(error) + "\n")
|
| 482 |
+
|
| 483 |
+
|
| 484 |
+
if __name__ == "__main__":
|
| 485 |
+
main()
|
test_package_vllm_speculative_runtime.py
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Run offline: python3 -B scripts/test_package_vllm_speculative_runtime.py."""
|
| 3 |
+
|
| 4 |
+
import ast
|
| 5 |
+
import csv
|
| 6 |
+
import importlib.util
|
| 7 |
+
import io
|
| 8 |
+
import json
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
import stat
|
| 11 |
+
import tempfile
|
| 12 |
+
import unittest
|
| 13 |
+
from unittest import mock
|
| 14 |
+
import warnings
|
| 15 |
+
import zipfile
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
SPEC = importlib.util.spec_from_file_location(
|
| 19 |
+
"packager", Path(__file__).with_name("package-vllm-speculative-runtime.py"))
|
| 20 |
+
p = importlib.util.module_from_spec(SPEC)
|
| 21 |
+
SPEC.loader.exec_module(p)
|
| 22 |
+
|
| 23 |
+
OLD = b"# synthetic original backend\n"
|
| 24 |
+
NEW = b"# synthetic fixed backend\n"
|
| 25 |
+
VERSION_SOURCE = b'''# file generated by vcs-versioning\nfrom __future__ import annotations
|
| 26 |
+
__all__ = ["__version__", "__version_tuple__", "version", "version_tuple", "__commit_id__", "commit_id"]
|
| 27 |
+
__version__: str
|
| 28 |
+
version: str
|
| 29 |
+
__version_tuple__: tuple[int | str, ...]
|
| 30 |
+
version_tuple: tuple[int | str, ...]
|
| 31 |
+
__commit_id__: str | None
|
| 32 |
+
commit_id: str | None
|
| 33 |
+
__version__ = version = '0.24.0'
|
| 34 |
+
__version_tuple__ = version_tuple = (0, 24, 0)
|
| 35 |
+
__commit_id__ = commit_id = 'gee0da84ab'
|
| 36 |
+
'''
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
class PackagerTests(unittest.TestCase):
|
| 40 |
+
def setUp(self):
|
| 41 |
+
self.temp = tempfile.TemporaryDirectory()
|
| 42 |
+
self.addCleanup(self.temp.cleanup)
|
| 43 |
+
self.root = Path(self.temp.name)
|
| 44 |
+
self.wheel = self.root / next(iter(p.UPSTREAM_HASHES))
|
| 45 |
+
self.output = self.root / "output"
|
| 46 |
+
self.patches = mock.patch.multiple(
|
| 47 |
+
p, OLD_BACKEND_SHA=p.sha256(OLD), NEW_BACKEND_SHA=p.sha256(NEW))
|
| 48 |
+
self.patches.start()
|
| 49 |
+
self.addCleanup(self.patches.stop)
|
| 50 |
+
|
| 51 |
+
def fixture(self, changes=None, extra=(), record_edit=None):
|
| 52 |
+
tag = p.UPSTREAM_WHEEL_TAGS[self.wheel.name][0]
|
| 53 |
+
members = {
|
| 54 |
+
p.BACKEND: OLD,
|
| 55 |
+
p.VERSION_FILE: VERSION_SOURCE,
|
| 56 |
+
p.DIST + "/METADATA": (
|
| 57 |
+
b"Metadata-Version: 2.4\r\nName: vllm\r\nVersion: 0.24.0\r\n"
|
| 58 |
+
b"Requires-Dist: torch==2.11.0\r\nRequires-Dist: example;\r\n"
|
| 59 |
+
b" python_version >= '3.8'\r\nLicense-Expression: Apache-2.0\r\n"
|
| 60 |
+
b"\r\nDescription\r\nVersion: not a header\r\n"),
|
| 61 |
+
p.DIST + "/WHEEL": ("Wheel-Version: 1.0\nGenerator: fixture\n"
|
| 62 |
+
"Root-Is-Purelib: false\nTag: " + tag + "\n").encode(),
|
| 63 |
+
p.DIST + "/licenses/LICENSE": b"untouched license\n",
|
| 64 |
+
"vllm/_C.abi3.so": bytes(range(256)) * 10000,
|
| 65 |
+
"vllm/unchanged.py": b"raise RuntimeError('must never execute')\n",
|
| 66 |
+
p.DIST + "/": b"",
|
| 67 |
+
}
|
| 68 |
+
members.update(changes or {})
|
| 69 |
+
entries = list(members.items()) + list(extra)
|
| 70 |
+
rows = [(n, p.record_hash(p.sha256(d)), str(len(d)))
|
| 71 |
+
for n, d in entries if not n.endswith("/")]
|
| 72 |
+
rows.append((p.RECORD, "", ""))
|
| 73 |
+
if record_edit:
|
| 74 |
+
record_edit(rows)
|
| 75 |
+
record = io.StringIO(newline="")
|
| 76 |
+
csv.writer(record, lineterminator="\n").writerows(rows)
|
| 77 |
+
with warnings.catch_warnings():
|
| 78 |
+
warnings.simplefilter("ignore", UserWarning)
|
| 79 |
+
with zipfile.ZipFile(self.wheel, "w", zipfile.ZIP_DEFLATED) as wheel:
|
| 80 |
+
for name, data in entries:
|
| 81 |
+
wheel.writestr(name, data)
|
| 82 |
+
wheel.writestr(p.RECORD, record.getvalue().encode())
|
| 83 |
+
return members
|
| 84 |
+
|
| 85 |
+
def run_package(self, output=None):
|
| 86 |
+
return p._package(self.wheel, output or self.output, NEW,
|
| 87 |
+
p.sha256(self.wheel.read_bytes()))
|
| 88 |
+
|
| 89 |
+
def assert_rejected(self, pattern=None):
|
| 90 |
+
with self.assertRaisesRegex((p.InvalidWheel, zipfile.BadZipFile, ValueError), pattern or "."):
|
| 91 |
+
self.run_package()
|
| 92 |
+
if self.output.exists():
|
| 93 |
+
self.assertEqual(list(self.output.iterdir()), [])
|
| 94 |
+
|
| 95 |
+
def test_deterministic_rewrite_and_complete_record(self):
|
| 96 |
+
for name in p.UPSTREAM_HASHES:
|
| 97 |
+
with self.subTest(name=name):
|
| 98 |
+
self.wheel = self.root / name
|
| 99 |
+
members = self.fixture()
|
| 100 |
+
first, provenance_path = self.run_package(self.root / (name + "-a"))
|
| 101 |
+
second, second_provenance = self.run_package(self.root / (name + "-b"))
|
| 102 |
+
self.assertEqual(first.read_bytes(), second.read_bytes())
|
| 103 |
+
self.assertEqual(provenance_path.read_bytes(), second_provenance.read_bytes())
|
| 104 |
+
provenance = json.loads(provenance_path.read_bytes())
|
| 105 |
+
self.assertEqual(provenance["output_wheel"]["sha256"], p.sha256(first.read_bytes()))
|
| 106 |
+
self.assertEqual(provenance["base_commit"], p.BASE_COMMIT)
|
| 107 |
+
self.assertEqual(provenance["fix_commit"], p.FIX_COMMIT)
|
| 108 |
+
with zipfile.ZipFile(first) as result:
|
| 109 |
+
expected_names = {p.renamed(n) for n in members} | {p.renamed(p.RECORD)}
|
| 110 |
+
self.assertEqual(set(result.namelist()), expected_names)
|
| 111 |
+
for member, data in members.items():
|
| 112 |
+
if member not in (p.BACKEND, p.VERSION_FILE, p.DIST + "/METADATA"):
|
| 113 |
+
self.assertEqual(result.read(p.renamed(member)), data)
|
| 114 |
+
self.assertEqual(result.read(p.BACKEND), NEW)
|
| 115 |
+
version = ast.parse(result.read(p.VERSION_FILE))
|
| 116 |
+
values = {node.targets[0].id: ast.literal_eval(node.value)
|
| 117 |
+
for node in version.body if isinstance(node, ast.Assign)}
|
| 118 |
+
self.assertEqual(values["__version__"], p.VERSION)
|
| 119 |
+
self.assertEqual(values["__version_tuple__"], (0, 24, 0, "mayhem.specmeta1"))
|
| 120 |
+
self.assertEqual(values["__commit_id__"], "g" + p.FIX_COMMIT[:9])
|
| 121 |
+
self.assertEqual(result.read(p.NEW_DIST + "/METADATA"),
|
| 122 |
+
members[p.DIST + "/METADATA"].replace(
|
| 123 |
+
b"Version: 0.24.0\r\n", b"Version: " + p.VERSION.encode() + b"\r\n"))
|
| 124 |
+
record = list(csv.reader(io.StringIO(result.read(p.renamed(p.RECORD)).decode())))
|
| 125 |
+
self.assertEqual({r[0] for r in record},
|
| 126 |
+
{n for n in expected_names if not n.endswith("/")})
|
| 127 |
+
for member, digest, size in record:
|
| 128 |
+
data = result.read(member)
|
| 129 |
+
if member == p.renamed(p.RECORD):
|
| 130 |
+
self.assertEqual((digest, size), ("", ""))
|
| 131 |
+
else:
|
| 132 |
+
self.assertEqual((digest, size), (p.record_hash(p.sha256(data)), str(len(data))))
|
| 133 |
+
self.assertTrue(all(i.date_time == (1980, 1, 1, 0, 0, 0)
|
| 134 |
+
and i.compress_type == zipfile.ZIP_STORED
|
| 135 |
+
for i in result.infolist()))
|
| 136 |
+
changed = {row["original"] for row in provenance["changed_members"]}
|
| 137 |
+
self.assertEqual(changed, {p.BACKEND, p.VERSION_FILE, p.RECORD} |
|
| 138 |
+
{n for n in members if n.startswith(p.DIST + "/")})
|
| 139 |
+
|
| 140 |
+
def test_production_hash_gate_has_no_fixture_override(self):
|
| 141 |
+
self.fixture()
|
| 142 |
+
with mock.patch.object(p, "fixed_source", return_value=NEW):
|
| 143 |
+
with self.assertRaisesRegex(p.InvalidWheel, "upstream wheel SHA256"):
|
| 144 |
+
p.package(self.wheel, self.root, self.output)
|
| 145 |
+
self.assertFalse(self.output.exists())
|
| 146 |
+
self.assertEqual(len(p.UPSTREAM_HASHES), 2)
|
| 147 |
+
|
| 148 |
+
def test_pinned_internal_linux_tags_are_preserved(self):
|
| 149 |
+
for arch, other in (("aarch64", "x86_64"), ("x86_64", "aarch64")):
|
| 150 |
+
with self.subTest(architecture=arch):
|
| 151 |
+
self.wheel = self.root / ("vllm-0.24.0-cp38-abi3-manylinux_2_28_" + arch + ".whl")
|
| 152 |
+
self.output = self.root / arch
|
| 153 |
+
tag = ("cp38-abi3-linux_" + arch).encode()
|
| 154 |
+
metadata = (b"Wheel-Version: 1.0\nGenerator: setuptools (80.10.2)\n"
|
| 155 |
+
b"Root-Is-Purelib: false\nTag: " + tag + b"\n")
|
| 156 |
+
self.fixture({p.DIST + "/WHEEL": metadata})
|
| 157 |
+
output, _ = self.run_package()
|
| 158 |
+
with zipfile.ZipFile(output) as wheel:
|
| 159 |
+
self.assertEqual(wheel.read(p.NEW_DIST + "/WHEEL"), metadata)
|
| 160 |
+
self.output = self.root / (arch + "-rejected")
|
| 161 |
+
for wrong in ("cp38-abi3-manylinux_2_28_" + arch, "cp38-abi3-linux_" + other):
|
| 162 |
+
self.fixture({p.DIST + "/WHEEL": metadata.replace(tag, wrong.encode())})
|
| 163 |
+
self.assert_rejected("unknown original WHEEL metadata")
|
| 164 |
+
|
| 165 |
+
def test_unknown_filename(self):
|
| 166 |
+
self.fixture()
|
| 167 |
+
self.wheel = self.wheel.rename(self.root / "vllm-0.24.0-py3-none-any.whl")
|
| 168 |
+
self.assert_rejected("filename")
|
| 169 |
+
|
| 170 |
+
def test_malicious_and_duplicate_paths(self):
|
| 171 |
+
for name in ("../escape", "/absolute", "a/../../b", "a\\b", "C:/bad", "a//b",
|
| 172 |
+
"a/./b", "a/space /b", "a\x00bad", "a\nb", p.BACKEND,
|
| 173 |
+
p.BACKEND.upper(), "vllm/_C.abi3.so/child", "other.dist-info/METADATA"):
|
| 174 |
+
with self.subTest(name=name):
|
| 175 |
+
self.fixture(extra=[(name, b"bad")])
|
| 176 |
+
self.assert_rejected()
|
| 177 |
+
|
| 178 |
+
def test_symlink_and_special_file(self):
|
| 179 |
+
for mode in (stat.S_IFLNK, stat.S_IFIFO, stat.S_IFCHR):
|
| 180 |
+
self.fixture()
|
| 181 |
+
with zipfile.ZipFile(self.wheel, "a") as wheel:
|
| 182 |
+
info = zipfile.ZipInfo("link")
|
| 183 |
+
info.create_system = 3
|
| 184 |
+
info.external_attr = (mode | 0o777) << 16
|
| 185 |
+
wheel.writestr(info, b"../outside")
|
| 186 |
+
self.assert_rejected("symlink or special")
|
| 187 |
+
|
| 188 |
+
def test_record_hash_size_coverage_and_duplicates(self):
|
| 189 |
+
edits = [
|
| 190 |
+
lambda rows: rows.__setitem__(0, (rows[0][0], p.record_hash("00" * 32), rows[0][2])),
|
| 191 |
+
lambda rows: rows.__setitem__(0, (rows[0][0], rows[0][1], "999")),
|
| 192 |
+
lambda rows: rows.pop(0),
|
| 193 |
+
lambda rows: rows.append(rows[0]),
|
| 194 |
+
lambda rows: rows.append(("ghost", "", "")),
|
| 195 |
+
lambda rows: rows.__setitem__(-1, (p.RECORD, "sha256=bad", "0")),
|
| 196 |
+
lambda rows: rows.__setitem__(0, (rows[0][0], "", rows[0][2])),
|
| 197 |
+
]
|
| 198 |
+
for edit in edits:
|
| 199 |
+
self.fixture(record_edit=edit)
|
| 200 |
+
self.assert_rejected()
|
| 201 |
+
|
| 202 |
+
def test_streamed_binary_hash_failure_cleans_owned_temps(self):
|
| 203 |
+
def corrupt(rows):
|
| 204 |
+
for i, row in enumerate(rows):
|
| 205 |
+
if row[0].endswith(".so"):
|
| 206 |
+
rows[i] = (row[0], p.record_hash("00" * 32), row[2])
|
| 207 |
+
self.fixture(record_edit=corrupt)
|
| 208 |
+
self.assert_rejected("RECORD hash/size mismatch")
|
| 209 |
+
|
| 210 |
+
def test_unknown_backend_version_and_metadata(self):
|
| 211 |
+
for changes in (
|
| 212 |
+
{p.BACKEND: b"unrecognized"},
|
| 213 |
+
{p.VERSION_FILE: VERSION_SOURCE.replace(b"gee0da84ab", b"gunknown0")},
|
| 214 |
+
{p.VERSION_FILE: VERSION_SOURCE.replace(b"(0, 24, 0)", b"(0, 23, 0)")},
|
| 215 |
+
{p.VERSION_FILE: VERSION_SOURCE + b"raise RuntimeError('never run')\n"},
|
| 216 |
+
{p.VERSION_FILE: VERSION_SOURCE + b"version = '0.24.0'\n"},
|
| 217 |
+
{p.DIST + "/METADATA": b"Name: vllm\nVersion: 0.25.0\n\n"},
|
| 218 |
+
{p.DIST + "/METADATA": b"Name: vllm\nVersion: 0.24.0\nVersion: 0.24.0\n\n"},
|
| 219 |
+
{p.DIST + "/WHEEL": b"Wheel-Version: 1.0\nTag: py3-none-any\n"},
|
| 220 |
+
{p.DIST + "/RECORD.jws": b"signature"},
|
| 221 |
+
):
|
| 222 |
+
self.fixture(changes)
|
| 223 |
+
self.assert_rejected()
|
| 224 |
+
|
| 225 |
+
def test_size_bounds(self):
|
| 226 |
+
self.fixture()
|
| 227 |
+
for field in ("MAX_ARCHIVE", "MAX_CENTRAL", "MAX_ENTRIES", "MAX_MEMBER", "MAX_TOTAL", "MAX_SMALL"):
|
| 228 |
+
with self.subTest(field=field), mock.patch.object(p, field, 1):
|
| 229 |
+
self.assert_rejected()
|
| 230 |
+
|
| 231 |
+
def test_no_overwrite_and_cleanup_publication_race(self):
|
| 232 |
+
self.fixture()
|
| 233 |
+
wheel, sidecar = self.run_package()
|
| 234 |
+
saved = (wheel.read_bytes(), sidecar.read_bytes())
|
| 235 |
+
with self.assertRaisesRegex(p.InvalidWheel, "output already exists"):
|
| 236 |
+
self.run_package()
|
| 237 |
+
self.assertEqual((wheel.read_bytes(), sidecar.read_bytes()), saved)
|
| 238 |
+
wheel.unlink()
|
| 239 |
+
sidecar.unlink()
|
| 240 |
+
real_link = p.os.link
|
| 241 |
+
|
| 242 |
+
def race(source, destination):
|
| 243 |
+
if str(destination).endswith(".json"):
|
| 244 |
+
Path(destination).write_bytes(b"other owner")
|
| 245 |
+
real_link(source, destination)
|
| 246 |
+
|
| 247 |
+
with mock.patch.object(p.os, "link", side_effect=race):
|
| 248 |
+
with self.assertRaises(FileExistsError):
|
| 249 |
+
self.run_package()
|
| 250 |
+
self.assertFalse(wheel.exists())
|
| 251 |
+
self.assertEqual(sidecar.read_bytes(), b"other owner")
|
| 252 |
+
self.assertEqual(list(self.output.iterdir()), [sidecar])
|
| 253 |
+
|
| 254 |
+
def test_large_members_are_streamed(self):
|
| 255 |
+
self.fixture()
|
| 256 |
+
original_read = zipfile.ZipExtFile.read
|
| 257 |
+
|
| 258 |
+
def bounded_read(stream, size=-1):
|
| 259 |
+
if stream.name.endswith(".so"):
|
| 260 |
+
self.assertGreater(size, 0)
|
| 261 |
+
self.assertLessEqual(size, p.CHUNK)
|
| 262 |
+
return original_read(stream, size)
|
| 263 |
+
|
| 264 |
+
with mock.patch.object(zipfile.ZipExtFile, "read", bounded_read):
|
| 265 |
+
self.run_package()
|
| 266 |
+
|
| 267 |
+
def test_minimal_export_source_and_pinned_identity(self):
|
| 268 |
+
source = self.root / "source"
|
| 269 |
+
backend = source / p.BACKEND
|
| 270 |
+
backend.parent.mkdir(parents=True)
|
| 271 |
+
backend.write_bytes(NEW)
|
| 272 |
+
manifest = source / "vllm-specmeta-source.json"
|
| 273 |
+
identity = {"base_commit": p.BASE_COMMIT, "fix_commit": p.FIX_COMMIT,
|
| 274 |
+
"backend_sha256": p.NEW_BACKEND_SHA}
|
| 275 |
+
manifest.write_text(json.dumps(identity))
|
| 276 |
+
with mock.patch.object(p, "git", side_effect=AssertionError("no git for export")):
|
| 277 |
+
self.assertEqual(p.fixed_source(source), NEW)
|
| 278 |
+
for key in identity:
|
| 279 |
+
manifest.write_text(json.dumps({**identity, key: "wrong"}))
|
| 280 |
+
with self.assertRaisesRegex(p.InvalidWheel, "identity mismatch"):
|
| 281 |
+
p.fixed_source(source)
|
| 282 |
+
manifest.write_text(json.dumps(identity))
|
| 283 |
+
backend.write_bytes(OLD)
|
| 284 |
+
with self.assertRaisesRegex(p.InvalidWheel, "backend SHA256"):
|
| 285 |
+
p.fixed_source(source)
|
| 286 |
+
|
| 287 |
+
def test_sparse_git_source_identity_and_index(self):
|
| 288 |
+
source = self.root / "source"
|
| 289 |
+
backend = source / p.BACKEND
|
| 290 |
+
backend.parent.mkdir(parents=True)
|
| 291 |
+
backend.write_bytes(NEW)
|
| 292 |
+
(source / ".git").mkdir()
|
| 293 |
+
blob = p.hashlib.sha1(b"blob " + str(len(NEW)).encode() + b"\0" + NEW).hexdigest().encode()
|
| 294 |
+
replies = [p.FIX_COMMIT.encode(), p.BASE_COMMIT.encode(),
|
| 295 |
+
b"100644 blob " + blob + b"\t" + p.BACKEND.encode() + b"\0",
|
| 296 |
+
b"100644 " + blob + b" 0\t" + p.BACKEND.encode() + b"\0"]
|
| 297 |
+
for mode in (b"100644", b"100755"):
|
| 298 |
+
for local_mode in (0o644, 0o755):
|
| 299 |
+
backend.chmod(local_mode)
|
| 300 |
+
matching = [row.replace(b"100644", mode) for row in replies]
|
| 301 |
+
with self.subTest(git_mode=mode, local_mode=local_mode):
|
| 302 |
+
with mock.patch.object(p, "git", side_effect=matching):
|
| 303 |
+
self.assertEqual(p.fixed_source(source), NEW)
|
| 304 |
+
mismatched_index = replies.copy()
|
| 305 |
+
mismatched_index[-1] = mismatched_index[-1].replace(b"100644", b"100755")
|
| 306 |
+
with mock.patch.object(p, "git", side_effect=mismatched_index):
|
| 307 |
+
with self.assertRaisesRegex(p.InvalidWheel, "index is not clean"):
|
| 308 |
+
p.fixed_source(source)
|
| 309 |
+
for i in range(len(replies)):
|
| 310 |
+
changed = replies.copy()
|
| 311 |
+
changed[i] = b"wrong"
|
| 312 |
+
with mock.patch.object(p, "git", side_effect=changed):
|
| 313 |
+
with self.assertRaises(p.InvalidWheel):
|
| 314 |
+
p.fixed_source(source)
|
| 315 |
+
|
| 316 |
+
|
| 317 |
+
if __name__ == "__main__":
|
| 318 |
+
unittest.main()
|
vllm-0.24.0+mayhem.specmeta1-cp38-abi3-manylinux_2_28_aarch64.whl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:edd083a50cc8469ec5ebf347dbe73236d8cd988b63ed63ca49f4e7a7b7480e39
|
| 3 |
+
size 614981674
|
vllm-0.24.0+mayhem.specmeta1-cp38-abi3-manylinux_2_28_aarch64.whl.provenance.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": {
|
| 3 |
+
"original_sha256": "ce9071eade3d1a9c7dc9dd9f187212599e1c20058ffda901d6950b9dcde19913",
|
| 4 |
+
"path": "vllm/v1/attention/backends/flashinfer.py",
|
| 5 |
+
"sha256": "01678024fc88e5f031b866fd6affbb0d82917c271938d8c5878fa0e68c023ab5"
|
| 6 |
+
},
|
| 7 |
+
"base_commit": "ee0da84ab9e04ac7610e28580af62c365e898389",
|
| 8 |
+
"changed_members": [
|
| 9 |
+
{
|
| 10 |
+
"original": "vllm-0.24.0.dist-info/METADATA",
|
| 11 |
+
"original_sha256": "142e542d132be54f21f696c35ef841b90f92427d3bf1dbdc9a08d16e343daacd",
|
| 12 |
+
"output": "vllm-0.24.0+mayhem.specmeta1.dist-info/METADATA",
|
| 13 |
+
"sha256": "927c5856499e96b08e92164e802a1059af52a35d2326a621a83e6123600f91ec"
|
| 14 |
+
},
|
| 15 |
+
{
|
| 16 |
+
"original": "vllm-0.24.0.dist-info/RECORD",
|
| 17 |
+
"original_sha256": "cd774ecdf7dab4820deb22c2001da67eb3928af88a78e6952ca4dc7b01b39faf",
|
| 18 |
+
"output": "vllm-0.24.0+mayhem.specmeta1.dist-info/RECORD",
|
| 19 |
+
"sha256": "615ab38a86f63077d5abf9c7b604c8f30949635556d5cba9a106e1cff11d80bc"
|
| 20 |
+
},
|
| 21 |
+
{
|
| 22 |
+
"original": "vllm-0.24.0.dist-info/WHEEL",
|
| 23 |
+
"original_sha256": "3ccf5124a5e39af4379a4a0bf5c8922613862738afe138af2497b555c331d397",
|
| 24 |
+
"output": "vllm-0.24.0+mayhem.specmeta1.dist-info/WHEEL",
|
| 25 |
+
"sha256": "3ccf5124a5e39af4379a4a0bf5c8922613862738afe138af2497b555c331d397"
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"original": "vllm-0.24.0.dist-info/entry_points.txt",
|
| 29 |
+
"original_sha256": "37761e1ffd913d6e1859b7450911af4e6275a92ccbb319657c28e951fe5ee140",
|
| 30 |
+
"output": "vllm-0.24.0+mayhem.specmeta1.dist-info/entry_points.txt",
|
| 31 |
+
"sha256": "37761e1ffd913d6e1859b7450911af4e6275a92ccbb319657c28e951fe5ee140"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"original": "vllm-0.24.0.dist-info/licenses/LICENSE",
|
| 35 |
+
"original_sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4",
|
| 36 |
+
"output": "vllm-0.24.0+mayhem.specmeta1.dist-info/licenses/LICENSE",
|
| 37 |
+
"sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4"
|
| 38 |
+
},
|
| 39 |
+
{
|
| 40 |
+
"original": "vllm-0.24.0.dist-info/top_level.txt",
|
| 41 |
+
"original_sha256": "7c081bf0fb78cd0a0a4d40376672842207238742fdeff7701236034cbe4c104a",
|
| 42 |
+
"output": "vllm-0.24.0+mayhem.specmeta1.dist-info/top_level.txt",
|
| 43 |
+
"sha256": "7c081bf0fb78cd0a0a4d40376672842207238742fdeff7701236034cbe4c104a"
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"original": "vllm/_version.py",
|
| 47 |
+
"original_sha256": "763ed234b0648da39d230104ca1afb879dd874d64a4fb6363a43a73649592804",
|
| 48 |
+
"output": "vllm/_version.py",
|
| 49 |
+
"sha256": "be5e443590a7da3d2f8b1c50f0c4d29a357fd0d8f95dc682abf21b3948b445ca"
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
"original": "vllm/v1/attention/backends/flashinfer.py",
|
| 53 |
+
"original_sha256": "ce9071eade3d1a9c7dc9dd9f187212599e1c20058ffda901d6950b9dcde19913",
|
| 54 |
+
"output": "vllm/v1/attention/backends/flashinfer.py",
|
| 55 |
+
"sha256": "01678024fc88e5f031b866fd6affbb0d82917c271938d8c5878fa0e68c023ab5"
|
| 56 |
+
}
|
| 57 |
+
],
|
| 58 |
+
"fix_commit": "9a9cbb67ac23d78cf7384650b561ce7b122f770b",
|
| 59 |
+
"output_wheel": {
|
| 60 |
+
"filename": "vllm-0.24.0+mayhem.specmeta1-cp38-abi3-manylinux_2_28_aarch64.whl",
|
| 61 |
+
"sha256": "edd083a50cc8469ec5ebf347dbe73236d8cd988b63ed63ca49f4e7a7b7480e39",
|
| 62 |
+
"size": 614981674
|
| 63 |
+
},
|
| 64 |
+
"schema_version": 1,
|
| 65 |
+
"upstream_version": "0.24.0",
|
| 66 |
+
"upstream_wheel": {
|
| 67 |
+
"filename": "vllm-0.24.0-cp38-abi3-manylinux_2_28_aarch64.whl",
|
| 68 |
+
"sha256": "700db71c3cf14697d42583521f38b12fac38db1e7a8ad062e8e4d63a5dadebd5",
|
| 69 |
+
"size": 271361241
|
| 70 |
+
},
|
| 71 |
+
"version": "0.24.0+mayhem.specmeta1"
|
| 72 |
+
}
|
vllm-0.24.0+mayhem.specmeta1-cp38-abi3-manylinux_2_28_x86_64.whl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:15b03d4d57e971627349dfc72275f2806457334d934cc1e29dfbd4d616d5a058
|
| 3 |
+
size 638028744
|
vllm-0.24.0+mayhem.specmeta1-cp38-abi3-manylinux_2_28_x86_64.whl.provenance.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"backend": {
|
| 3 |
+
"original_sha256": "ce9071eade3d1a9c7dc9dd9f187212599e1c20058ffda901d6950b9dcde19913",
|
| 4 |
+
"path": "vllm/v1/attention/backends/flashinfer.py",
|
| 5 |
+
"sha256": "01678024fc88e5f031b866fd6affbb0d82917c271938d8c5878fa0e68c023ab5"
|
| 6 |
+
},
|
| 7 |
+
"base_commit": "ee0da84ab9e04ac7610e28580af62c365e898389",
|
| 8 |
+
"changed_members": [
|
| 9 |
+
{
|
| 10 |
+
"original": "vllm-0.24.0.dist-info/METADATA",
|
| 11 |
+
"original_sha256": "142e542d132be54f21f696c35ef841b90f92427d3bf1dbdc9a08d16e343daacd",
|
| 12 |
+
"output": "vllm-0.24.0+mayhem.specmeta1.dist-info/METADATA",
|
| 13 |
+
"sha256": "927c5856499e96b08e92164e802a1059af52a35d2326a621a83e6123600f91ec"
|
| 14 |
+
},
|
| 15 |
+
{
|
| 16 |
+
"original": "vllm-0.24.0.dist-info/RECORD",
|
| 17 |
+
"original_sha256": "faedfff053a871980816cea1bc6b20aea1108b8fb2e951047c196a6548e9e6c5",
|
| 18 |
+
"output": "vllm-0.24.0+mayhem.specmeta1.dist-info/RECORD",
|
| 19 |
+
"sha256": "24b119b527f4bf89dcf16199aef88f90222e6718a64adae6bf80940b33a204fd"
|
| 20 |
+
},
|
| 21 |
+
{
|
| 22 |
+
"original": "vllm-0.24.0.dist-info/WHEEL",
|
| 23 |
+
"original_sha256": "3195b844c385a39b126f4c647a4bee9c534d9bc9d95a3025edc887ed33933941",
|
| 24 |
+
"output": "vllm-0.24.0+mayhem.specmeta1.dist-info/WHEEL",
|
| 25 |
+
"sha256": "3195b844c385a39b126f4c647a4bee9c534d9bc9d95a3025edc887ed33933941"
|
| 26 |
+
},
|
| 27 |
+
{
|
| 28 |
+
"original": "vllm-0.24.0.dist-info/entry_points.txt",
|
| 29 |
+
"original_sha256": "37761e1ffd913d6e1859b7450911af4e6275a92ccbb319657c28e951fe5ee140",
|
| 30 |
+
"output": "vllm-0.24.0+mayhem.specmeta1.dist-info/entry_points.txt",
|
| 31 |
+
"sha256": "37761e1ffd913d6e1859b7450911af4e6275a92ccbb319657c28e951fe5ee140"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"original": "vllm-0.24.0.dist-info/licenses/LICENSE",
|
| 35 |
+
"original_sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4",
|
| 36 |
+
"output": "vllm-0.24.0+mayhem.specmeta1.dist-info/licenses/LICENSE",
|
| 37 |
+
"sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4"
|
| 38 |
+
},
|
| 39 |
+
{
|
| 40 |
+
"original": "vllm-0.24.0.dist-info/top_level.txt",
|
| 41 |
+
"original_sha256": "7c081bf0fb78cd0a0a4d40376672842207238742fdeff7701236034cbe4c104a",
|
| 42 |
+
"output": "vllm-0.24.0+mayhem.specmeta1.dist-info/top_level.txt",
|
| 43 |
+
"sha256": "7c081bf0fb78cd0a0a4d40376672842207238742fdeff7701236034cbe4c104a"
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"original": "vllm/_version.py",
|
| 47 |
+
"original_sha256": "763ed234b0648da39d230104ca1afb879dd874d64a4fb6363a43a73649592804",
|
| 48 |
+
"output": "vllm/_version.py",
|
| 49 |
+
"sha256": "be5e443590a7da3d2f8b1c50f0c4d29a357fd0d8f95dc682abf21b3948b445ca"
|
| 50 |
+
},
|
| 51 |
+
{
|
| 52 |
+
"original": "vllm/v1/attention/backends/flashinfer.py",
|
| 53 |
+
"original_sha256": "ce9071eade3d1a9c7dc9dd9f187212599e1c20058ffda901d6950b9dcde19913",
|
| 54 |
+
"output": "vllm/v1/attention/backends/flashinfer.py",
|
| 55 |
+
"sha256": "01678024fc88e5f031b866fd6affbb0d82917c271938d8c5878fa0e68c023ab5"
|
| 56 |
+
}
|
| 57 |
+
],
|
| 58 |
+
"fix_commit": "9a9cbb67ac23d78cf7384650b561ce7b122f770b",
|
| 59 |
+
"output_wheel": {
|
| 60 |
+
"filename": "vllm-0.24.0+mayhem.specmeta1-cp38-abi3-manylinux_2_28_x86_64.whl",
|
| 61 |
+
"sha256": "15b03d4d57e971627349dfc72275f2806457334d934cc1e29dfbd4d616d5a058",
|
| 62 |
+
"size": 638028744
|
| 63 |
+
},
|
| 64 |
+
"schema_version": 1,
|
| 65 |
+
"upstream_version": "0.24.0",
|
| 66 |
+
"upstream_wheel": {
|
| 67 |
+
"filename": "vllm-0.24.0-cp38-abi3-manylinux_2_28_x86_64.whl",
|
| 68 |
+
"sha256": "2d2831aeba311292250df0132dbc4d8e9f42c654536eaec48e6fe58acb1822cf",
|
| 69 |
+
"size": 279209310
|
| 70 |
+
},
|
| 71 |
+
"version": "0.24.0+mayhem.specmeta1"
|
| 72 |
+
}
|
vllm-specmeta-v1.patch
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
diff --git a/tests/v1/attention/test_flashinfer_metadata_builder.py b/tests/v1/attention/test_flashinfer_metadata_builder.py
|
| 2 |
+
new file mode 100644
|
| 3 |
+
index 0000000..5e85c81
|
| 4 |
+
--- /dev/null
|
| 5 |
+
+++ b/tests/v1/attention/test_flashinfer_metadata_builder.py
|
| 6 |
+
@@ -0,0 +1,120 @@
|
| 7 |
+
+# SPDX-License-Identifier: Apache-2.0
|
| 8 |
+
+# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
| 9 |
+
+"""Regression tests for FlashInfer's persistent host metadata buffers."""
|
| 10 |
+
+
|
| 11 |
+
+import unittest
|
| 12 |
+
+from itertools import product
|
| 13 |
+
+from unittest.mock import MagicMock, patch
|
| 14 |
+
+
|
| 15 |
+
+import torch
|
| 16 |
+
+
|
| 17 |
+
+from vllm.config import (
|
| 18 |
+
+ AttentionConfig,
|
| 19 |
+
+ CUDAGraphMode,
|
| 20 |
+
+ ModelConfig,
|
| 21 |
+
+ SpeculativeConfig,
|
| 22 |
+
+ VllmConfig,
|
| 23 |
+
+ set_current_vllm_config,
|
| 24 |
+
+)
|
| 25 |
+
+from vllm.platforms import current_platform
|
| 26 |
+
+from vllm.v1.attention.backends.utils import PerLayerParameters
|
| 27 |
+
+from vllm.v1.kv_cache_interface import FullAttentionSpec
|
| 28 |
+
+
|
| 29 |
+
+
|
| 30 |
+
+def check_persistent_host_buffer_pinning(
|
| 31 |
+
+ cuda_device: torch.device,
|
| 32 |
+
+ use_v2_model_runner: bool,
|
| 33 |
+
+ has_speculation: bool,
|
| 34 |
+
+ pin_memory: bool,
|
| 35 |
+
+):
|
| 36 |
+
+ from vllm.v1.attention.backends import flashinfer
|
| 37 |
+
+
|
| 38 |
+
+ # Mock configuration only: no model config resolution or weight downloads.
|
| 39 |
+
+ config = MagicMock(spec=VllmConfig)
|
| 40 |
+
+ config.model_config = MagicMock(spec=ModelConfig)
|
| 41 |
+
+ config.model_config.dtype = torch.float16
|
| 42 |
+
+ config.model_config.max_model_len = 32
|
| 43 |
+
+ config.model_config.get_num_attention_heads.return_value = 4
|
| 44 |
+
+ config.cache_config = MagicMock()
|
| 45 |
+
+ config.scheduler_config = MagicMock(max_num_seqs=2)
|
| 46 |
+
+ config.compilation_config = MagicMock(cudagraph_mode=CUDAGraphMode.NONE)
|
| 47 |
+
+ config.parallel_config = MagicMock(
|
| 48 |
+
+ decode_context_parallel_size=1,
|
| 49 |
+
+ dcp_kv_cache_interleave_size=1,
|
| 50 |
+
+ )
|
| 51 |
+
+ config.attention_config = AttentionConfig(use_trtllm_attention=False)
|
| 52 |
+
+ config.use_v2_model_runner = use_v2_model_runner
|
| 53 |
+
+ config.speculative_config = (
|
| 54 |
+
+ MagicMock(
|
| 55 |
+
+ spec=SpeculativeConfig,
|
| 56 |
+
+ num_speculative_tokens=1,
|
| 57 |
+
+ parallel_drafting=False,
|
| 58 |
+
+ )
|
| 59 |
+
+ if has_speculation
|
| 60 |
+
+ else None
|
| 61 |
+
+ )
|
| 62 |
+
+ kv_cache_spec = FullAttentionSpec(
|
| 63 |
+
+ block_size=16,
|
| 64 |
+
+ num_kv_heads=2,
|
| 65 |
+
+ head_size=64,
|
| 66 |
+
+ dtype=torch.float16,
|
| 67 |
+
+ )
|
| 68 |
+
+ per_layer_parameters = {
|
| 69 |
+
+ "layer.0": PerLayerParameters(
|
| 70 |
+
+ window_left=-1, logits_soft_cap=0.0, sm_scale=64**-0.5
|
| 71 |
+
+ )
|
| 72 |
+
+ }
|
| 73 |
+
+
|
| 74 |
+
+ # Exercise the real constructor and allocators; only layer registration
|
| 75 |
+
+ # and the platform pinning flag are patched. GPU buffers total 36 bytes.
|
| 76 |
+
+ with (
|
| 77 |
+
+ set_current_vllm_config(config),
|
| 78 |
+
+ patch.object(flashinfer, "PIN_MEMORY", pin_memory),
|
| 79 |
+
+ patch.object(
|
| 80 |
+
+ flashinfer, "get_per_layer_parameters", return_value=per_layer_parameters
|
| 81 |
+
+ ),
|
| 82 |
+
+ ):
|
| 83 |
+
+ builder = flashinfer.FlashInferMetadataBuilder(
|
| 84 |
+
+ kv_cache_spec, ["layer.0"], config, cuda_device
|
| 85 |
+
+ )
|
| 86 |
+
+
|
| 87 |
+
+ # V2 and speculative proposals can reuse host metadata while an earlier
|
| 88 |
+
+ # asynchronous H2D copy is in flight. Legacy non-spec decoding stays pinned.
|
| 89 |
+
+ expected_pinned = pin_memory and not use_v2_model_runner and not has_speculation
|
| 90 |
+
+ assert builder.pin_memory is expected_pinned
|
| 91 |
+
+ for name in ("paged_kv_indptr", "paged_kv_indices", "paged_kv_last_page_len"):
|
| 92 |
+
+ buffer = getattr(builder, name)
|
| 93 |
+
+ assert buffer.gpu.device == cuda_device, name
|
| 94 |
+
+ assert buffer.cpu.device.type == "cpu", name
|
| 95 |
+
+ assert buffer.cpu.is_pinned() is expected_pinned, name
|
| 96 |
+
+ assert builder.paged_kv_indptr_cpu_buffer.device.type == "cpu"
|
| 97 |
+
+ assert builder.paged_kv_indptr_cpu_buffer.is_pinned() is expected_pinned
|
| 98 |
+
+
|
| 99 |
+
+
|
| 100 |
+
+class TestFlashInferMetadataBuilder(unittest.TestCase):
|
| 101 |
+
+ @classmethod
|
| 102 |
+
+ def setUpClass(cls):
|
| 103 |
+
+ if not current_platform.is_cuda() or not torch.cuda.is_available():
|
| 104 |
+
+ raise unittest.SkipTest("Requires CUDA for real pinned host allocations")
|
| 105 |
+
+ try:
|
| 106 |
+
+ import flashinfer # noqa: F401
|
| 107 |
+
+ except ImportError as exc:
|
| 108 |
+
+ raise unittest.SkipTest("Requires FlashInfer") from exc
|
| 109 |
+
+
|
| 110 |
+
+ def test_persistent_host_buffer_pinning(self):
|
| 111 |
+
+ device = torch.device("cuda:0")
|
| 112 |
+
+ for use_v2_model_runner, has_speculation, pin_memory in product(
|
| 113 |
+
+ (False, True), repeat=3
|
| 114 |
+
+ ):
|
| 115 |
+
+ with self.subTest(
|
| 116 |
+
+ use_v2_model_runner=use_v2_model_runner,
|
| 117 |
+
+ has_speculation=has_speculation,
|
| 118 |
+
+ pin_memory=pin_memory,
|
| 119 |
+
+ ):
|
| 120 |
+
+ check_persistent_host_buffer_pinning(
|
| 121 |
+
+ device, use_v2_model_runner, has_speculation, pin_memory
|
| 122 |
+
+ )
|
| 123 |
+
+
|
| 124 |
+
+
|
| 125 |
+
+if __name__ == "__main__":
|
| 126 |
+
+ unittest.main()
|
| 127 |
+
diff --git a/vllm/v1/attention/backends/flashinfer.py b/vllm/v1/attention/backends/flashinfer.py
|
| 128 |
+
index 8031900..f11a1bd 100755
|
| 129 |
+
--- a/vllm/v1/attention/backends/flashinfer.py
|
| 130 |
+
+++ b/vllm/v1/attention/backends/flashinfer.py
|
| 131 |
+
@@ -718,10 +718,14 @@ class FlashInferMetadataBuilder(AttentionMetadataBuilder[FlashInferMetadata]):
|
| 132 |
+
"earlier GPUs."
|
| 133 |
+
)
|
| 134 |
+
# Preparing persistent buffers
|
| 135 |
+
- # Since we do not have explicit synchronization in ModelRunnerV2, we do not pin
|
| 136 |
+
- # reused CPU buffers to avoid a race condition between step N async copies to
|
| 137 |
+
- # GPU and step N+1 buffer updates.
|
| 138 |
+
- self.pin_memory = not vllm_config.use_v2_model_runner and PIN_MEMORY
|
| 139 |
+
+ # ModelRunnerV2 and speculative proposals can reuse host metadata before
|
| 140 |
+
+ # an earlier asynchronous H2D copy completes. Pageable staging prevents
|
| 141 |
+
+ # the next proposal's metadata from overwriting that copy's source.
|
| 142 |
+
+ self.pin_memory = (
|
| 143 |
+
+ PIN_MEMORY
|
| 144 |
+
+ and not vllm_config.use_v2_model_runner
|
| 145 |
+
+ and speculative_config is None
|
| 146 |
+
+ )
|
| 147 |
+
self.paged_kv_indptr = self._make_buffer(max_num_reqs + 1)
|
| 148 |
+
self.paged_kv_indptr_cpu_buffer = torch.zeros_like(
|
| 149 |
+
self.paged_kv_indptr.cpu, pin_memory=self.pin_memory
|