MCPcopy Create free account
hub / github.com/cactus-compute/needle / parse_bits_map

Function parse_bits_map

needle/model/quantize.py:301–318  ·  view source on GitHub ↗
(spec)

Source from the content-addressed store, hash-verified

299
300
301def parse_bits_map(spec):
302 m, default = {}, None
303 for part in str(spec or "").split(","):
304 if not part.strip():
305 continue
306 k, v = part.split("=", 1)
307 b = TERNARY_BITS if float(v) == TERNARY_BITS else int(v)
308 if k.strip() == "default":
309 default = b
310 else:
311 m[canonical_tensor_name(k.strip())] = b
312 if default is None:
313 raise ValueError(f"bits map {spec!r} needs a default=<b> entry")
314 bad = {b for b in list(m.values()) + [default]
315 if b not in CQ_BITS and b != TERNARY_BITS}
316 if bad:
317 raise ValueError(f"bits map {spec!r} has unsupported widths {sorted(bad)}")
318 return m, default
319
320
321def cq_mixed_params(params, bits_map, default_bits, group_size=CQ_GROUP_SIZE):

Callers 3

build_exportFunction · 0.85
write_exportFunction · 0.85
deploy_quantizeFunction · 0.85

Calls 1

canonical_tensor_nameFunction · 0.85

Tested by

no test coverage detected