/** * The page: one repo id in, one honest breakdown out. * * Every rule lives in precision_map.js, which the parity gate holds to * the Python implementation. Nothing here decides anything — it fetches, * calls, and renders, so a rule can never be quietly different in the UI * from the one that was tested. */ import { FORMATS, RULES_MEASURED_ON, inspect } from './precision_map.js'; import { progress } from './progress.js'; import { ensureNextStepStyles, nextSteps, repoFromUrl } from './tools.js'; const $ = (id) => document.getElementById(id); // A link from another tool carries the model over; arriving at an empty // form is what makes five tools feel like five tools instead of one. ensureNextStepStyles(); const carried = repoFromUrl(); if (carried) { $('repo').value = carried; } const out = $('out'); const esc = (s) => String(s).replace(/[&<>"]/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"' }[c])); const GIB = 1024 ** 3; const gib = (b) => (b / GIB >= 0.01 ? `${(b / GIB).toFixed(2)} GiB` : `${(b / (1024 ** 2)).toFixed(0)} MiB`); const pct = (part, whole) => `${((part / whole) * 100).toFixed(1)}%`; function renderFormats() { $('formats').innerHTML = Object.entries(FORMATS).map(([method, f]) => `
${esc(method)}${esc(f.producer.join('.').replace('config.', ''))}`
: 'records none'}${esc(r.producerVersion)}`
: 'no version recorded in the pack';
const meta = ``;
if (!r.knownFormat && r.method !== 'none') {
return meta + card('check', `No convention on file for ${esc(r.method)}`,
`This reader has never been verified against a
${esc(r.method)} pack, so the split below rests on dtypes
alone and the metadata line may be undercounted. Treat it as an
estimate, not a reading.
The pack declares ${esc(r.method)}, which quantizes
something — but no tensor here is in a packed dtype or under a packed
name. Either the convention moved since ${esc(RULES_MEASURED_ON)}, or
this pack stores its weights somewhere this cannot see.
No breakdown is shown, on purpose. A number here would look like a measurement and be a guess.
`); } if (r.method === 'none') { return meta + card('clear', 'Not quantized', `Every tensor is at full precision — ${esc(gib(b.full))} of it. No quantization method is declared and none is detectable from the dtypes.
` + tableFamilies(r, b.full)); } const headline = `${pct(b.full, t)} of this pack is still full precision`; return meta + card('check', headline, `Written by ${esc(r.tool)}, ${version}.
` + bar(b, t) + table(r) + `The output head is quantized. That is
a real choice with a real cost: measured on this repo's own weights,
quantizing lm_head flips the model's chosen token on
about a fifth of positions. It buys size; it is worth knowing you
bought it.
The output head was left at full precision — the usual choice, and the reason a "4-bit" pack is never 4-bit throughout.
`) + (r.unknownDtypes.length ? `Unknown dtypes counted at 2 bytes:
${r.unknownDtypes.map(esc).join(', ')}.
| ${esc(fam)} | ${gib(size)} | ${pct(size, fullTotal)} |
${esc(e.message || e)}
Gated and private repos cannot be read from the browser.
`); } finally { go.disabled = false; } } $('form').addEventListener('submit', (e) => { e.preventDefault(); const v = $('repo').value.trim(); if (v) run(v); }); document.querySelectorAll('[data-ex]').forEach((btn) => btn.addEventListener('click', () => { $('repo').value = btn.dataset.ex; run(btn.dataset.ex); })); $('measured').textContent = RULES_MEASURED_ON; renderFormats();