Skip to content

Kyojin: open-source engine that runs 100 GB-class open models (GLM-5.3, Qwen3.8, DeepSeek V4.1) on one desktop machine. AMD Strix Halo, NVIDIA RTX and Apple Mac. OpenAI API, built on ExLlamaV3.

GLM server: judge a picture batch before it is written, and bound the disk cache by tenure

MangetsuCa9106f309450
diff --git a/tools/glm/SERVE.md b/tools/glm/SERVE.md
index 44ff7ed..acbd66e 100644
--- a/tools/glm/SERVE.md
+++ b/tools/glm/SERVE.md
@@ -34,6 +34,7 @@ call, a streamed call, a tool call, and two 400-token benchmark calls.
| `--image-cache-items` | `0` | optional cap on how many pictures are held at once; `0` = only the byte budget |
| `--image-cache-dir` | none | a second-level picture cache on disk, **off by default**. The rows of the pictures the memory budget evicts are written there (and only those: a session that fits in `--image-cache-mb` writes nothing) and read back when the client sends the picture again. With the picture's identity kept for the life of the process, a restored picture reproduces the prompt token for token, so the paged prefix still matches. Holds rows derived from the images the clients send, never an image file or a path |
| `--image-cache-dir-max-gb` | `4` | cap on that directory (0 = no cap). It is enforced per *conversation*, not per file: pictures no remembered conversation claims go first (oldest file first); then a conversation the server remembers but this request is not serving is released **whole**, oldest conversation first, so with `--sessions N` as many conversations as fit keep a complete cache instead of N half-caches; the conversation the request itself is serving is the last to be touched and only in part if its own files alone exceed the cap (end of its prompt first). Trimming also happens at start-up |
+| `--image-cache-dir-lock-s` | `300` | seconds a conversation keeps the room its files took before another conversation may take it (0 = no tenure). The clock starts when the files are written and is **not** refreshed by later requests, so the conversation that grabbed the cache cannot keep it for ever. Tenure never costs a write: a batch that would have to push a recent conversation out is judged *before* anything is written and simply skipped (a conversation cached only in part has no reuse anyway), so the bytes stay on the client's side of the wire — which is what matters for wear |
| `--image-cache-format` | `fp32` | how the cached rows are stored: `fp32` as the vision merger emits them, `fp16` (half the bytes, **measured bit-exact on this pack**) or `q8` (8 bit with one fp16 scale per row, a quarter, 0.86 % error) |
| `--sessions` | `1` | requests decoded together through the one model (multi-user). `1` = one request at a time, others wait |
| `--row-budget` | `5` when `--sessions` > 1 | caps the verify rows per round by lowering the draft depth when several sessions are busy; `0` = off |
@@ -241,6 +242,7 @@ queue and the worker. Events, in the order a request that goes through produces
| `sse_headers` / `sse_first_content` | streaming: headers sent / first frame with text | `first_s` since arrival — the gap the client experiences as silence |
| `job_done` | job finished | `prompt_tokens`, `cache_n`, `cache_pct`, `new_tokens`, `prefill_s`, `decode_s`, `elapsed_s` |
| `img_cache` | image request, after `job_done` | `imgs`, `hits`, `misses`, `first_missing`, `entries`, `mb`, `budget_mb`, `item_cap`, `evicted` |
+| `img_disk` | the same request, when `--image-cache-dir` is set | `files`, `mb`, `cap_mb`, `locked`, `loaded`, `stored`, `dropped`, `skipped`, `written_bytes`, `written_mb`, `skipped_mb`, `errors` |
| `sse_done` / `req_done` | stream closed / response returned | `out_tokens`, `status`, `elapsed_s` |
| `client_left` | client hung up first | `path`, `stage` |
| `job_skipped` / `job_error` / `stream_error` / `req_error` | cancelled before start / failure | `error` (type plus a truncated message) |
diff --git a/tools/glm/image_cache_disk.py b/tools/glm/image_cache_disk.py
index b4fe46a..7523d6d 100644
--- a/tools/glm/image_cache_disk.py
+++ b/tools/glm/image_cache_disk.py
@@ -25,6 +25,7 @@ from __future__ import annotations
import os
import pathlib
+import time
import torch
from exllamav3.tokenizer.mm_embedding import MMEmbedding, QuantizedMMRows
@@ -45,6 +46,16 @@ def _rows_payload(emb: Any) -> dict | None:
return None
+def rows_nbytes(emb: Any) -> int:
+ """Bytes the rows of one picture take, without building the payload."""
+ rows = getattr(emb, "embeddings", None)
+ if isinstance(rows, QuantizedMMRows):
+ return int(rows.nbytes)
+ if rows is not None and hasattr(rows, "element_size"):
+ return int(rows.numel()) * int(rows.element_size())
+ return 0
+
+
def as_live(live) -> list | None:
"""`live` as a list of conversations (each a set of content keys), newest first; None means "not told"."""
if live is None:
@@ -65,10 +76,16 @@ class ImageEmbeddingDisk:
for why, and for the order it uses.
"""
- def __init__(self, directory: str, max_bytes: int = 0, start_token: int = 0, end_token: int = 0):
+ def __init__(self, directory: str, max_bytes: int = 0, start_token: int = 0, end_token: int = 0,
+ lock_s: float = 0.0):
self.path = pathlib.Path(directory).expanduser()
self.max_bytes = max(0, int(max_bytes))
self.start_token, self.end_token = int(start_token), int(end_token)
+ # A conversation keeps the room its cache took for this long (0 = no tenure). The clock starts when the
+ # file is written and is *not* refreshed by later requests: refreshing it would let whichever
+ # conversation grabbed the cache first keep it for ever. Tenure is what stops a cyclic workload
+ # (four conversations taking turns) from evicting each one just before it is served again.
+ self.lock_s = max(0.0, float(lock_s))
self.enabled = False
self.error: str | None = None
self._identity: dict[str, dict] = {}
@@ -76,7 +93,11 @@ class ImageEmbeddingDisk:
self._live: list | None = None # conversations the memory cache last said it refers to
self._bytes = 0
self._files = 0
- self.stats = {"loaded": 0, "stored": 0, "dropped": 0, "errors": 0}
+ self._locked: dict[str, float] = {} # content key -> time its tenure ends
+ # written_mb / skipped_mb are the numbers to watch when what matters is how much the server writes:
+ # a batch that would not fit is not written at all, so bytes are never written just to be deleted.
+ self.stats = {"loaded": 0, "stored": 0, "dropped": 0, "skipped": 0,
+ "written_bytes": 0, "skipped_bytes": 0, "errors": 0}
try:
self.path.mkdir(parents=True, exist_ok=True)
self.enabled = True
@@ -98,11 +119,26 @@ class ImageEmbeddingDisk:
if not self.enabled:
return f"picture cache on disk off ({self.error})"
cap = f"{self.max_bytes / 2 ** 30:.1f} GiB cap" if self.max_bytes else "no cap"
- return f"picture cache on disk {self.path} ({self._files} files, {self._bytes / 2 ** 20:.1f} MiB, {cap})"
+ tenure = f", {self.lock_s / 60:.0f} min tenure" if self.lock_s else ""
+ return f"picture cache on disk {self.path} ({self._files} files, {self._bytes / 2 ** 20:.1f} MiB, {cap}{tenure})"
def report(self) -> dict:
return {"files": self._files, "mb": round(self._bytes / 2 ** 20, 1),
- "cap_mb": round(self.max_bytes / 2 ** 20, 1), **self.stats}
+ "written_mb": round(self.stats["written_bytes"] / 2 ** 20, 3),
+ "skipped_mb": round(self.stats["skipped_bytes"] / 2 ** 20, 3),
+ "cap_mb": round(self.max_bytes / 2 ** 20, 1),
+ "locked": sum(1 for key, until in self._locked.items()
+ if until > time.time() and key in self._present()),
+ **self.stats}
+
+ def _present(self) -> set:
+ try:
+ return {entry.name.split(".")[0] for entry in self.path.glob("*.pt")}
+ except OSError:
+ return set()
+
+ def _locked_now(self, key: str) -> bool:
+ return self.lock_s > 0 and self._locked.get(key, 0.0) > time.time()
# -- identity --------------------------------------------------------------------------------------------
@@ -172,31 +208,57 @@ class ImageEmbeddingDisk:
`live` is `ImageEmbeddingCache.live_orders` (remembered conversations, newest first) and `protect` is the
conversation this request is serving, so that concurrent requests cannot release each other's cache.
+
+ The batch is judged **before** anything is written: room is made first (whole conversations, per
+ `collect`), and if the batch still does not fit it is not written at all. A conversation that is cached
+ only in part has no reuse anyway — it would hold room a complete one needs — so there is no point writing
+ it, and no point writing bytes that would have to be deleted again a moment later.
"""
if not self.enabled or not evicted:
return
if live is not None:
self._live = as_live(live) # the conversations the cache still refers to (see collect)
+ pending = []
for key, emb, position in evicted:
self.position(key, position)
+ if getattr(emb, "deepstack_embeddings", None) is not None:
+ continue # not stored: only the merger rows are (GLM has none)
+ if self._file(key, mode).exists():
+ continue # same picture evicted again: already on disk
+ pending.append((key, emb))
+ if not pending:
+ self.collect(live, protect)
+ return
+ # 4 KiB covers what the container adds around the rows (measured ~3 KiB for a 12 MiB payload)
+ estimate = sum(rows_nbytes(emb) + 4096 for _, emb in pending)
+ if self.max_bytes:
+ # Make room *before* deciding: give up what is free to give up (unclaimed files first, then whole
+ # conversations whose tenure is over) so that the batch can be written, not written and deleted.
+ self.collect(live, protect, reserve=estimate)
+ if self._bytes + estimate > self.max_bytes:
+ self.stats["skipped"] += len(pending) # does not fit: nothing is written for this batch
+ self.stats["skipped_bytes"] += estimate
+ self.collect(live, protect)
+ return
+ for key, emb in pending:
payload = _rows_payload(emb)
if payload is None:
continue
- if getattr(emb, "deepstack_embeddings", None) is not None:
- continue # not stored: only the merger rows are (GLM has none)
payload |= {"grid_thw": getattr(emb, "grid_thw", None),
"mrope_merge_size": getattr(emb, "mrope_merge_size", None),
"metadata": dict(getattr(emb, "metadata", None) or {})}
path = self._file(key, mode)
- if path.exists():
- continue # same picture evicted again: already on disk
tmp = path.with_suffix(".tmp")
try:
torch.save(payload, tmp)
os.replace(tmp, path)
- self._bytes += path.stat().st_size
+ size = path.stat().st_size
+ self._bytes += size
self._files += 1
self.stats["stored"] += 1
+ self.stats["written_bytes"] += size
+ if self.lock_s:
+ self._locked[key] = time.time() + self.lock_s
except Exception: # disk full, permissions, ...: keep serving
self.stats["errors"] += 1
try:
@@ -206,6 +268,7 @@ class ImageEmbeddingDisk:
self.collect(live, protect)
def _unlink(self, path: pathlib.Path) -> None:
+ self._locked.pop(path.name.split(".")[0], None)
try:
size = path.stat().st_size
path.unlink()
@@ -214,7 +277,7 @@ class ImageEmbeddingDisk:
except OSError:
pass
- def collect(self, live: list | set | None = None, protect: set | None = None) -> int:
+ def collect(self, live: list | set | None = None, protect: set | None = None, reserve: int = 0) -> int:
"""Enforce the cap. The unit of eviction is a *conversation*, not a file.
A conversation's pictures are only worth keeping together: the engine resumes at a checkpoint only when a
@@ -235,7 +298,7 @@ class ImageEmbeddingDisk:
just because some other request happened to be served more recently. Without `protect` the newest
remembered conversation plays that part.
"""
- if not self.enabled or not self.max_bytes or self._bytes <= self.max_bytes:
+ if not self.enabled or not self.max_bytes or self._bytes + reserve <= self.max_bytes:
return 0
live = self._live if live is None else as_live(live)
protected = set(protect) if protect is not None else (set(live[0]) if live else set())
@@ -258,10 +321,13 @@ class ImageEmbeddingDisk:
if live is None: # nobody said which conversations are live: position only
for entry in sorted(files, key=lambda e: (0, age(e)) if self._position.get(e.name.split(".")[0]) is None
else (1, -self._position[e.name.split(".")[0]])):
- if self._bytes <= self.max_bytes:
+ if self._bytes + reserve <= self.max_bytes:
break
+ if self._locked_now(entry.name.split(".")[0]):
+ continue
self._unlink(entry)
dropped += 1
+ dropped += self._break_tenure(files, reserve)
self.stats["dropped"] += dropped
return dropped
@@ -281,22 +347,39 @@ class ImageEmbeddingDisk:
groups.setdefault(group_of(entry.name.split(".")[0]), []).append(entry)
for group in sorted(groups, reverse=True): # least wanted first
- if self._bytes <= self.max_bytes:
+ if self._bytes + reserve <= self.max_bytes:
break
entries = groups[group]
if group == unclaimed: # nobody claims these: the oldest goes first
- ordered = sorted(entries, key=age)
- whole = False
+ ordered, whole = sorted(entries, key=age), False
elif group == 0: # the one being served: only as a last resort, tail first
- ordered = sorted(entries, key=within)
- whole = False
+ ordered, whole = sorted(entries, key=within), False
else: # a remembered conversation: it goes as a unit
- ordered = sorted(entries, key=age)
- whole = True
+ ordered, whole = sorted(entries, key=age), True
+ if whole and any(self._locked_now(e.name.split(".")[0]) for e in entries):
+ continue # still within its tenure: leave it alone for now
for entry in ordered:
- if not whole and self._bytes <= self.max_bytes:
+ if not whole and self._bytes + reserve <= self.max_bytes:
break
+ if not whole and self._locked_now(entry.name.split(".")[0]):
+ continue
self._unlink(entry)
dropped += 1
+ # Tenure is only broken when the directory is already over the cap (a cap lowered under it, say): it is
+ # not broken to make room for a new batch, which is exactly what it exists to prevent. That batch is
+ # simply not written and waits for the tenure to run out.
+ dropped += self._break_tenure(files, reserve if self._bytes > self.max_bytes else 0)
self.stats["dropped"] += dropped
return dropped
+
+ def _break_tenure(self, files: list, reserve: int = 0) -> int:
+ """Last resort: the cap has to hold, so the tenures closest to expiring go first."""
+ dropped = 0
+ for entry in sorted(files, key=lambda e: self._locked.get(e.name.split(".")[0], 0.0)):
+ if self._bytes + reserve <= self.max_bytes:
+ break
+ if not entry.exists():
+ continue
+ self._unlink(entry)
+ dropped += 1
+ return dropped
diff --git a/tools/glm/serve.py b/tools/glm/serve.py
index 668e418..87fa663 100644
--- a/tools/glm/serve.py
+++ b/tools/glm/serve.py
@@ -123,6 +123,11 @@ IMAGE_CACHE_FORMATS = ("fp32", "fp16", "q8")
# evict, so it is deliberately independent of --image-cache-mb: 4 GiB is 87 manga pages as fp32, 175 as fp16 and
# 349 as q8, which covers the sessions this server is run for. 0 = no cap.
IMAGE_CACHE_DIR_MAX_GB = 4.0
+# How long a conversation keeps the room its picture cache took on disk (--image-cache-dir-lock-s). The clock
+# starts when the files are written and is not refreshed by later requests, so a conversation that grabbed the
+# cache cannot keep it for ever; within the window a cyclic workload cannot evict each conversation just before
+# it is served again.
+IMAGE_CACHE_DIR_LOCK_S = 300.0
def physical_ram_bytes() -> int:
@@ -475,7 +480,8 @@ class ResidentEngine:
vision: bool = True, sessions: int = 1,
image_cache_bytes: int | None = None, image_cache_items: int = 0,
image_cache_format: str = "fp32",
- image_cache_dir: str | None = None, image_cache_dir_max_gb: float = IMAGE_CACHE_DIR_MAX_GB):
+ image_cache_dir: str | None = None, image_cache_dir_max_gb: float = IMAGE_CACHE_DIR_MAX_GB,
+ image_cache_dir_lock_s: float = IMAGE_CACHE_DIR_LOCK_S):
import torch
from exllamav3 import Cache, Config, Generator, Job, Model, Tokenizer
from exllamav3.generator import generator as GM
@@ -534,7 +540,8 @@ class ResidentEngine:
self.emb_disk = ImageEmbeddingDisk(
image_cache_dir, int(max(0.0, float(image_cache_dir_max_gb)) * 2 ** 30),
start_token=int(getattr(self.config, "vision_start_token_id", 0) or 0),
- end_token=int(getattr(self.config, "vision_end_token_id", 0) or 0))
+ end_token=int(getattr(self.config, "vision_end_token_id", 0) or 0),
+ lock_s=max(0.0, float(image_cache_dir_lock_s)))
if vision:
self.vision = self._load_vision()
self.supports_vision = self.vision is not None
@@ -1768,6 +1775,12 @@ def main() -> None:
"a file read instead of a vision pass plus a re-prefill of everything after it. "
"Off by default (nothing is written). Holds rows derived from the images the "
"clients send, never an image file or a path")
+ parser.add_argument("--image-cache-dir-lock-s", type=float, default=IMAGE_CACHE_DIR_LOCK_S,
+ help=f"seconds a conversation keeps its files on disk before another conversation may "
+ f"take the room (default {IMAGE_CACHE_DIR_LOCK_S:g} = 5 min, 0 = no tenure). Tenure "
+ "is what keeps a set of conversations taking turns from evicting each one just "
+ "before it is served again; while it holds, a new picture that would have to push a "
+ "recent conversation out is simply not cached")
parser.add_argument("--image-cache-dir-max-gb", type=float, default=IMAGE_CACHE_DIR_MAX_GB,
help=f"cap on that directory, in GiB (default {IMAGE_CACHE_DIR_MAX_GB:g}; 0 = no cap). The "
"pictures the memory cache is most likely to need again are the earliest ones, so "
@@ -1833,7 +1846,8 @@ def main() -> None:
vision=not args.no_vision, sessions=args.sessions,
image_cache_bytes=image_cache_bytes, image_cache_items=args.image_cache_items,
image_cache_format=args.image_cache_format,
- image_cache_dir=args.image_cache_dir, image_cache_dir_max_gb=args.image_cache_dir_max_gb)
+ image_cache_dir=args.image_cache_dir, image_cache_dir_max_gb=args.image_cache_dir_max_gb,
+ image_cache_dir_lock_s=args.image_cache_dir_lock_s)
engine.row_budget = (5 if args.row_budget is None else args.row_budget) if args.sessions > 1 else 0
template = Path(args.chat_template or DEFAULT_TEMPLATE).expanduser().read_text(encoding="utf-8")
print(mem_line("loaded"), flush=True)
@@ -1894,6 +1908,7 @@ def main() -> None:
image_cache_format=getattr(engine, "image_cache_format", "fp32"),
image_cache_dir=str(engine.emb_disk.path) if getattr(engine, "emb_disk", None) else None,
image_cache_dir_cap_mb=round(engine.emb_disk.max_bytes / 2 ** 20) if getattr(engine, "emb_disk", None) else None,
+ image_cache_dir_lock_s=engine.emb_disk.lock_s if getattr(engine, "emb_disk", None) else None,
heartbeat_s=reqlog.heartbeat_s)
sock = startup_health.finish() # the early listener's open socket: no refused connection
if sock is not None:
diff --git a/tools/glm/test_serve_glm_additional.py b/tools/glm/test_serve_glm_additional.py
index eb32e03..5adafd6 100644
--- a/tools/glm/test_serve_glm_additional.py
+++ b/tools/glm/test_serve_glm_additional.py
@@ -87,7 +87,8 @@ def vision_engine():
return eng, calls
-def disk_engine(directory, budget_bytes: int = 768, mode: str = "fp32", cap_bytes: int = 0, on_disk: bool = True):
+def disk_engine(directory, budget_bytes: int = 768, mode: str = "fp32", cap_bytes: int = 0, on_disk: bool = True,
+ lock_s: float = 0.0):
"""An engine whose _embed() runs over a real memory cache *and* a real second-level cache on disk.
The fake pictures carry everything a restore needs (identity, token list, MRoPE metadata) so a test can ask
@@ -126,7 +127,7 @@ def disk_engine(directory, budget_bytes: int = 768, mode: str = "fp32", cap_byte
eng.emb_disk = None
if on_disk:
from image_cache_disk import ImageEmbeddingDisk
- eng.emb_disk = ImageEmbeddingDisk(directory, max_bytes=cap_bytes, start_token=7, end_token=8)
+ eng.emb_disk = ImageEmbeddingDisk(directory, max_bytes=cap_bytes, start_token=7, end_token=8, lock_s=lock_s)
return eng, calls
@@ -141,8 +142,16 @@ class ImageDiskCacheTests(unittest.TestCase):
def test_the_default_cap_is_four_gib(self):
self.assertEqual(serve.IMAGE_CACHE_DIR_MAX_GB, 4.0)
+ self.assertEqual(serve.IMAGE_CACHE_DIR_LOCK_S, 300.0) # 5 minutes of tenure for a conversation's files
self.assertNotIn("EXL3_IMAGE_CACHE_DIR", os.environ) # a flag, not an environment variable
+ def test_the_tenure_reaches_the_disk_cache(self):
+ with tempfile.TemporaryDirectory() as tmp:
+ eng, _ = disk_engine(tmp, budget_bytes=384, lock_s=42.0)
+ self.assertEqual(eng.emb_disk.lock_s, 42.0)
+ eng, _ = disk_engine(tmp, budget_bytes=384, lock_s=0.0)
+ self.assertEqual(eng.emb_disk.lock_s, 0.0)
+
def test_only_what_memory_gave_up_is_written(self):
with tempfile.TemporaryDirectory() as tmp:
eng, calls = disk_engine(tmp, budget_bytes=768) # room for two of the four pictures
@@ -180,6 +189,31 @@ class ImageDiskCacheTests(unittest.TestCase):
self.assertEqual(list(pathlib.Path(tmp).rglob("*.pt")), [])
self.assertEqual(len(calls), 6) # 4 cold, then the 2 that memory dropped
+ def test_a_batch_that_does_not_fit_writes_nothing_at_all(self):
+ # What matters for wear: a conversation that cannot be cached should cost *no* bytes at all, rather than
+ # being written and deleted again on the next request.
+ with tempfile.TemporaryDirectory() as tmp:
+ eng, calls = disk_engine(tmp, budget_bytes=768, cap_bytes=1) # room for nothing
+ serve.ResidentEngine._embed(eng, tiny_pictures(4))
+ report = eng.emb_disk.report()
+ self.assertEqual(report["files"], 0)
+ self.assertEqual(report["written_bytes"], 0)
+ self.assertEqual(report["dropped"], 0)
+ self.assertGreater(report["skipped"], 0)
+ self.assertEqual(list(pathlib.Path(tmp).glob("*.pt")), [])
+
+ def test_every_picture_is_written_once_when_it_fits(self):
+ with tempfile.TemporaryDirectory() as tmp:
+ eng, calls = disk_engine(tmp, budget_bytes=768, cap_bytes=1 << 20)
+ serve.ResidentEngine._embed(eng, tiny_pictures(4))
+ first = eng.emb_disk.report()
+ self.assertEqual((first["stored"], first["dropped"], first["skipped"]), (2, 0, 0))
+ serve.ResidentEngine._embed(eng, tiny_pictures(4)) # the same two are evicted again
+ again = eng.emb_disk.report()
+ self.assertEqual(again["stored"], 2) # already on disk: not rewritten
+ self.assertEqual(again["written_bytes"], first["written_bytes"])
+ self.assertEqual(again["dropped"], 0)
+
def test_an_unusable_directory_does_not_stop_a_request(self):
with tempfile.TemporaryDirectory() as tmp:
blocker = pathlib.Path(tmp) / "blocker"
@@ -190,17 +224,6 @@ class ImageDiskCacheTests(unittest.TestCase):
self.assertEqual(len(out), 2)
self.assertEqual(len(calls), 2)
- def test_the_collector_runs_from_the_request_path(self):
- with tempfile.TemporaryDirectory() as tmp:
- eng, _ = disk_engine(tmp, budget_bytes=384, cap_bytes=1) # cap for nothing at all
- serve.ResidentEngine._embed(eng, tiny_pictures(2))
- self.assertEqual(list(pathlib.Path(tmp).glob("*.pt")), [])
- self.assertGreaterEqual(eng.emb_disk.report()["dropped"], 1)
-
-
-class ImageCacheBudgetTests(unittest.TestCase):
- """--image-cache-mb / --image-cache-items, and the automatic budget behind them."""
-
def test_auto_budget_is_a_share_of_ram_clamped_to_this_box(self):
low, high = serve.IMAGE_CACHE_AUTO_MIN_MB, serve.IMAGE_CACHE_AUTO_MAX_MB
self.assertEqual(serve.auto_image_cache_bytes(8 << 30), low << 20) # 2 % of 8 GiB would be 164 MiB