mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-06 16:29:04 +00:00
DFlash2 confidence: only a slot at least IQ3_S's is priced at its own size; IQ3_XXS keeps today's steps (#5700)
A pack whose slot is smaller than SLOT_MIB (IQ3_XXS 1.665 MiB, the 2-bit sets) would raise the slot estimate and take a lower --draft-conf step; that direction is not measured on those sets, so they keep SLOT_MIB until it is (coordinator 11-16). UD-Q4_K_XL (2.99 MiB) and IQ3_S (1.952 MiB) keep their own size. tests/terminal/test_drafting_slot_size.py: IQ3_XXS gives the same slots and --draft-conf as before on every card of 8 to 96 GB at 128K and 262K (int8, --kv-resident 32768); it fails on the previous commit (10 GB at 128K: 1158 slots, was 989).
This commit is contained in:
1 parent
c594b8e0de
commit
25c9dc5142
2 files changed
+37
-14
No files matched your search
@@ -1002,7 +1002,9 @@ def pack_slot_mib(args: list[Any]) -> float:
|
||||
"""MiB of one engine slot for the pack ``--pack`` names. A native-experts pack (Unsloth, i-quant, NVFP4) gives its expert bytes in the first line of
|
||||
native_experts.txt, over n_expert per layer and one line per layer: UD-Q4_K_XL is 77,017,907,200 bytes over 512 x 48, 2.99 MiB a slot, as its engine
|
||||
logs it ("expert cache 2710 slots, 7.90 GiB" on a 16 GB card). The ISTA-DASLab i-quant packs have the file too: IQ3_S 1.952 MiB (SLOT_MIB, the set the
|
||||
steps were measured on), IQ3_XXS 1.665 MiB. A pack without the file (the canonical Q2_0 pack), or no --pack, is priced at SLOT_MIB."""
|
||||
steps were measured on), IQ3_XXS 1.665 MiB. A pack without the file (the canonical Q2_0 pack), or no --pack, is priced at SLOT_MIB.
|
||||
Only a slot of at least SLOT_MIB is priced at its own size: a smaller one (IQ3_XXS, the 2-bit sets) would raise the estimate and lower the step, and that
|
||||
direction is not measured on those sets yet (coordinator 11-16), so they keep SLOT_MIB, today's pricing."""
|
||||
pack = _flag_value(args, "--pack")
|
||||
try:
|
||||
lines = (Path(pack) / "native_experts.txt").read_text(encoding="utf-8", errors="replace").splitlines() if pack else []
|
||||
@@ -1012,7 +1014,7 @@ def pack_slot_mib(args: list[Any]) -> float:
|
||||
layers = sum(1 for line in lines[1:] if line.strip() and not line.startswith("#"))
|
||||
if head is None or not layers or not int(head.group(1)):
|
||||
return SLOT_MIB
|
||||
return int(head.group(2)) / (int(head.group(1)) * layers) / 2 ** 20
|
||||
return max(SLOT_MIB, int(head.group(2)) / (int(head.group(1)) * layers) / 2 ** 20)
|
||||
|
||||
|
||||
def slots_of(args: list[Any], vram_mib: float | None = None) -> int | None:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""The automatic --draft-conf counts a card's expert slots at the pack's own slot size: a native-experts pack states its expert bytes in
|
||||
native_experts.txt (the ISTA-DASLab i-quant packs too); a pack without it keeps IQ3_S's SLOT_MIB."""
|
||||
"""The automatic --draft-conf counts a card's expert slots at the pack's own slot size where it is at least IQ3_S's: a native-experts pack states its expert
|
||||
bytes in native_experts.txt (the ISTA-DASLab i-quant packs too); a smaller slot (IQ3_XXS) or a pack without the file keeps IQ3_S's SLOT_MIB."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -23,6 +23,20 @@ def ud_q4_k_xl_pack(root: Path) -> Path:
|
||||
return pack
|
||||
|
||||
|
||||
IQ3_S_TOTAL, IQ3_XXS_TOTAL = 50292326400, 42912972800 # the first lines of the ISTA-DASLab packs' native_experts.txt (n_expert 512)
|
||||
|
||||
|
||||
def ista_pack(root: Path, total: int) -> Path:
|
||||
"""A pack folder whose native_experts.txt has an ISTA-DASLab header (v3, 48 layers)."""
|
||||
pack = root / "ista"
|
||||
pack.mkdir()
|
||||
rows = "".join(f"{layer} 18 20 0 1 0 0 0\n" for layer in range(48))
|
||||
(pack / "native_experts.txt").write_text(
|
||||
f"# strata native experts v3: layer gu_type d_type offset blob_bytes gate_off up_off down_off [shard] (n_expert 512, total {total}; "
|
||||
"absolute offsets in x.gguf, or in the named shard beside it)\n" + rows, encoding="utf-8")
|
||||
return pack
|
||||
|
||||
|
||||
class PackSlotSize(unittest.TestCase):
|
||||
def test_a_native_experts_pack_gives_its_own_slot_size(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
@@ -30,18 +44,25 @@ class PackSlotSize(unittest.TestCase):
|
||||
self.assertAlmostEqual(drafting.pack_slot_mib(["--pack", str(pack)]), 77017907200 / (512 * 48) / 2 ** 20, places=6) # 2.99 MiB
|
||||
|
||||
def test_the_ista_i_quant_packs_have_the_file_too(self):
|
||||
# the headers tools/iq_pack.py writes for the ISTA-DASLab sets (n_expert 512, 48 layers): IQ3_S prices as SLOT_MIB did, IQ3_XXS smaller
|
||||
for total, want in ((50292326400, 1.9516), (42912972800, 1.6652)):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
pack = Path(tmp) / "p"
|
||||
pack.mkdir()
|
||||
rows = "".join(f"{layer} 18 20 0 1 0 0 0\n" for layer in range(48))
|
||||
(pack / "native_experts.txt").write_text(
|
||||
f"# strata native experts v3: layer gu_type d_type offset blob_bytes gate_off up_off down_off [shard] (n_expert 512, total {total}; "
|
||||
"absolute offsets in x.gguf, or in the named shard beside it)\n" + rows, encoding="utf-8")
|
||||
self.assertAlmostEqual(drafting.pack_slot_mib(["--pack", str(pack)]), want, places=4)
|
||||
# the headers tools/iq_pack.py writes for the ISTA-DASLab sets (n_expert 512, 48 layers): IQ3_S at its own 1.952 MiB; IQ3_XXS (1.665 MiB, smaller
|
||||
# than SLOT_MIB) keeps SLOT_MIB until a measurement backs the lower steps its own size would give
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
self.assertAlmostEqual(drafting.pack_slot_mib(["--pack", str(ista_pack(Path(tmp), IQ3_S_TOTAL))]), 1.9516, places=4)
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
self.assertEqual(drafting.pack_slot_mib(["--pack", str(ista_pack(Path(tmp), IQ3_XXS_TOTAL))]), drafting.SLOT_MIB)
|
||||
self.assertAlmostEqual(drafting.SLOT_MIB, 1.95, places=2)
|
||||
|
||||
def test_iq3_xxs_keeps_todays_steps(self):
|
||||
# every card 8 .. 96 GB at 128K and 262K (int8, --kv-resident 32768): the same slots and the same --draft-conf as with no pack named
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
pack = str(ista_pack(Path(tmp), IQ3_XXS_TOTAL))
|
||||
for ctx in ("131072", "262144"):
|
||||
base = ["--max-context", ctx, "--kv", "int8", "--kv-resident", "32768", "--prefill", "auto"]
|
||||
for gb in (8, 10, 12, 16, 20, 24, 32, 48, 72, 96):
|
||||
old, new = drafting.expected_slots(gb * 1024, base), drafting.expected_slots(gb * 1024, base + ["--pack", pack])
|
||||
self.assertEqual(new, old, (ctx, gb))
|
||||
self.assertEqual(drafting.conf_for_slots(new), drafting.conf_for_slots(old), (ctx, gb))
|
||||
|
||||
def test_a_pack_without_the_file_keeps_the_iq3_s_size(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
self.assertEqual(drafting.pack_slot_mib(["--pack", tmp]), drafting.SLOT_MIB, "a pack folder with no native_experts.txt")
|
||||
|
||||
Reference in new issue
Block a user