hyperdex-trainer / web /templates /detail.html
GGUFGuy's picture
Duplicate from GGUFGuy/hyperdex-trainer
2a49d9a
Raw History Blame Contribute Delete
15.2 kB
{% extends "base.html" %}
{% set nav = 'models' %}
{% block title %}{{ job.name }} — NanoDex{% endblock %}
{% block body %}
<a href="{{ '/models' if owner else '/explore' }}" class="btn ghost sm"
style="margin-bottom:16px">← {{ 'My models' if owner else 'Explore' }}</a>
<div class="sect-h" style="align-items:flex-start;margin-bottom:20px">
<div>
<div style="display:flex;align-items:center;gap:11px;flex-wrap:wrap">
<h1 style="font-size:27px">{{ job.name }}</h1>
<span id="statusChip"></span>
</div>
<p class="sub" style="margin-top:5px">
{{ job.tier_label }} · {{ "{:,}".format(job.n_params) }} parameters ·
by <a href="/u/{{ job.username }}" style="color:var(--accent)">@{{ job.username }}</a>
</p>
</div>
{% if owner %}
<div style="display:flex;gap:8px">
<button class="btn danger sm" id="cancelBtn" style="display:none">Cancel run</button>
</div>
{% endif %}
</div>
<div id="banner"></div>
<div class="card" style="margin-bottom:16px">
<div style="display:flex;justify-content:space-between;align-items:baseline;margin-bottom:10px">
<span class="eyebrow">Progress</span>
<span class="mono" id="pctLabel" style="color:var(--accent);font-weight:640">—</span>
</div>
<div class="bar"><i id="progBar" style="width:0%"></i></div>
<div class="grid g4" style="margin-top:18px;gap:14px">
<div><span class="eyebrow">Tokens seen</span>
<div class="mono" style="font-size:20px;font-weight:650" id="m-tokens">—</div>
<small class="muted" id="m-target">&nbsp;</small></div>
<div><span class="eyebrow">Step</span>
<div class="mono" style="font-size:20px;font-weight:650" id="m-step">—</div>
<small class="muted" id="m-steps">&nbsp;</small></div>
<div><span class="eyebrow">Loss</span>
<div class="mono" style="font-size:20px;font-weight:650" id="m-loss">—</div>
<small class="muted" id="m-ppl">&nbsp;</small></div>
<div><span class="eyebrow">Throughput</span>
<div class="mono" style="font-size:20px;font-weight:650" id="m-tps">—</div>
<small class="muted" id="m-eta">&nbsp;</small></div>
</div>
</div>
<div class="card" style="margin-bottom:16px">
<div class="sect-h" style="margin-bottom:8px">
<h2 style="font-size:16px">Loss curve</h2>
<span class="sub">cross-entropy vs tokens seen</span>
</div>
<svg class="chart" id="chart" preserveAspectRatio="xMidYMid meet"></svg>
</div>
<div class="grid g2" style="margin-bottom:16px">
<div class="card">
<h2 style="font-size:16px;margin-bottom:12px">Architecture</h2>
<div class="kv"><span>Class</span><b class="mono">LlamaForCausalLM</b></div>
<div class="kv"><span>Layers</span><b>{{ job.arch.layers }}</b></div>
<div class="kv"><span>Hidden size</span><b>{{ job.arch.hidden }}</b></div>
<div class="kv"><span>Attention heads</span><b>{{ job.arch.heads }} ({{ job.arch.kv_heads }} KV, head dim {{ job.arch.head_dim }})</b></div>
<div class="kv"><span>FFN size</span><b>{{ job.arch.ffn }}</b></div>
<div class="kv"><span>Context</span><b>{{ job.arch.ctx }} tokens</b></div>
<div class="kv"><span>Vocabulary</span><b>{{ "{:,}".format(job.arch.vocab) }}</b></div>
<div class="kv"><span>Parameters</span><b>{{ "{:,}".format(job.n_params) }}</b></div>
</div>
<div class="card">
<h2 style="font-size:16px;margin-bottom:12px">Run</h2>
<div class="kv"><span>Dataset</span><b>fineweb-edu</b></div>
<div class="kv"><span>Token budget</span><b id="d-target">—</b></div>
<div class="kv"><span>Optimizer</span><b>AdamW β=0.9/0.95 wd=0.1</b></div>
<div class="kv"><span>Schedule</span><b>2% warmup → cosine</b></div>
<div class="kv"><span>Learning rate</span><b id="d-lr">—</b></div>
<div class="kv"><span>Best loss</span><b id="d-best">—</b></div>
<div class="kv"><span>Worker</span><b id="d-gpu">—</b></div>
<div class="kv"><span>Queued</span><b id="d-created">—</b></div>
</div>
</div>
{% if owner %}
<div class="card" id="publishCard" style="display:none;margin-bottom:16px">
<h2 style="font-size:16px">Publish to your Hugging Face account</h2>
<p class="sub" style="margin:6px 0 14px">Uploads weights, config, tokenizer, the
full training recipe and a generated model card to
<span class="mono">{{ user.username }}/&lt;name&gt;</span>.</p>
<div style="display:flex;gap:10px;flex-wrap:wrap">
<input type="text" id="repoName" placeholder="{{ job.name }}" style="flex:1;min-width:220px">
<button class="btn primary" id="publishBtn">Publish</button>
</div>
</div>
{% endif %}
<div class="card" id="pgCard" style="display:none">
<div class="sect-h" style="margin-bottom:6px">
<h2 style="font-size:16px">Playground</h2>
<span id="ckptChip"></span>
</div>
<p class="sub" style="margin:0 0 14px" id="pgBlurb">Generate text with this
model. At this scale expect English-shaped output with no facts in it —
that's the honest result.</p>
<label class="fl">Prompt</label>
<textarea id="pgPrompt" rows="2">The mitochondria is</textarea>
<div class="grid g4" style="margin-top:14px">
<div><label class="fl">New tokens <span class="mono" id="v-max">80</span></label>
<input type="range" id="pgMax" min="8" max="256" step="8" value="80"></div>
<div><label class="fl">Temperature <span class="mono" id="v-temp">0.85</span></label>
<input type="range" id="pgTemp" min="0.1" max="2" step="0.05" value="0.85"></div>
<div><label class="fl">Top-k <span class="mono" id="v-topk">40</span></label>
<input type="range" id="pgTopk" min="0" max="200" step="5" value="40"></div>
<div><label class="fl">Top-p <span class="mono" id="v-topp">0.95</span></label>
<input type="range" id="pgTopp" min="0.1" max="1" step="0.05" value="0.95"></div>
</div>
<div style="display:flex;gap:10px;align-items:center;margin-top:16px;flex-wrap:wrap">
{% if user %}<button class="btn primary" id="pgGo">Generate</button>
{% else %}<a class="btn primary" target="_top"
href="/login?next=/models/{{ job.id }}">Sign in to generate</a>{% endif %}
{% if user %}
<label class="sub" style="display:flex;align-items:center;gap:7px;font-size:13px">
<input type="checkbox" id="pgAuto" style="width:auto;accent-color:var(--accent)">
re-run on every new checkpoint
</label>
{% endif %}
<span class="mono muted" id="pgStats" style="font-size:12px"></span>
</div>
<div id="pgOut" class="pgout" style="margin-top:14px;display:none"></div>
</div>
<div class="card" style="margin-top:16px">
<h2 style="font-size:16px;margin-bottom:12px">Logs</h2>
<div class="logs" id="logs">waiting…</div>
</div>
{% endblock %}
{% block scripts %}
<script>
const JOB_ID = {{ job.id | tojson }};
const OWNER = {{ owner | tojson }};
const SIGNED_IN = {{ (user is not none) | tojson }};
const INFER_DEVICE = {{ infer_device | tojson }};
let stopPoll = null;
let lastCkpt = null;
function banner(j){
const el = document.getElementById('banner');
if(j.status === 'queued'){
el.innerHTML = `<div class="card" style="margin-bottom:16px;border-color:#3b2f63">
<b>Position #${j.queue_position || '?'} in the queue.</b>
<span class="sub"> A worker will pick it up automatically — you can close this tab.</span>
</div>`;
} else if(j.status === 'failed'){
el.innerHTML = `<div class="card" style="margin-bottom:16px;border-color:#4c1d24">
<b style="color:var(--red)">This run failed.</b>
<div class="mono sub" style="margin-top:6px">${NX.esc(j.error||'')}</div></div>`;
} else if(j.status === 'done' && j.pushed_repo){
el.innerHTML = `<div class="card" style="margin-bottom:16px;border-color:var(--accent-2)">
<b>Published →</b> <a class="mono" style="color:var(--accent)"
href="https://huggingface.co/${NX.esc(j.pushed_repo)}" target="_blank"
rel="noopener">${NX.esc(j.pushed_repo)}</a></div>`;
} else if(j.status === 'cancelled'){
el.innerHTML = `<div class="card" style="margin-bottom:16px">
<b>Cancelled.</b> <span class="sub">Stopped before finishing.</span></div>`;
} else { el.innerHTML = ''; }
}
async function refresh(){
const j = await NX.get('/api/jobs/' + JOB_ID);
const pct = (j.progress * 100);
document.getElementById('statusChip').innerHTML = NX.chip(j.status);
document.getElementById('pctLabel').textContent = pct.toFixed(1) + '%';
document.getElementById('progBar').style.width = pct.toFixed(2) + '%';
document.getElementById('m-tokens').textContent = NX.fmtTokens(j.tokens_seen);
document.getElementById('m-target').textContent = 'of ' + NX.fmtTokens(j.target_tokens);
document.getElementById('m-step').textContent = Number(j.step).toLocaleString();
document.getElementById('m-steps').textContent = 'of ' + Number(j.total_steps).toLocaleString();
document.getElementById('m-loss').textContent = j.loss ? j.loss.toFixed(4) : '—';
document.getElementById('m-ppl').textContent = j.loss
? 'ppl ' + Math.exp(Math.min(j.loss,20)).toFixed(1) : 'not started';
document.getElementById('m-tps').textContent = j.tok_per_s
? Math.round(j.tok_per_s/1e3) + 'k/s' : '—';
document.getElementById('m-eta').textContent = (j.status==='running' && j.eta_s)
? NX.fmtTime(j.eta_s) + ' left' : (j.status==='done' ? 'completed' : '');
document.getElementById('d-target').textContent = NX.fmtTokens(j.target_tokens) + ' tokens';
document.getElementById('d-lr').textContent = j.lr ? j.lr.toExponential(2) : '—';
document.getElementById('d-best').textContent = j.best_loss ? j.best_loss.toFixed(4) : '—';
document.getElementById('d-gpu').textContent =
j.gpu_index === null || j.gpu_index === undefined ? 'not assigned' : ('worker ' + j.gpu_index);
document.getElementById('d-created').textContent = NX.ago(j.created_at);
banner(j);
if(OWNER){
const cb = document.getElementById('cancelBtn');
if(cb) cb.style.display =
(j.status==='queued' || j.status==='running') ? 'inline-flex' : 'none';
const pc = document.getElementById('publishCard');
if(pc) pc.style.display = (j.status==='done' && !j.pushed_repo) ? 'block' : 'none';
}
{
// The playground is available to anyone signed in, from the moment the
// first live checkpoint lands — so you can hear someone else's model
// mid-training, not only your own at the end.
const pg = document.getElementById('pgCard');
if(pg) pg.style.display = j.has_checkpoint ? 'block' : 'none';
const chip = document.getElementById('ckptChip');
const blurb = document.getElementById('pgBlurb');
if(chip){
if(j.status === 'done'){
chip.innerHTML = `<span class="chip done"><i></i>final weights</span>`;
if(blurb) blurb.textContent = OWNER
? "Generate text with the model you trained. At this scale expect "
+ "English-shaped output with no facts in it — that's the honest result."
: "Generate text with this finished model. At this scale expect "
+ "English-shaped output with no facts in it — that's the honest result.";
} else if(j.live_step !== null && j.live_step !== undefined){
chip.innerHTML = `<span class="chip running"><i></i>live checkpoint ·
step ${Number(j.live_step).toLocaleString()}</span>`;
if(blurb) blurb.textContent =
`Weights as of step ${Number(j.live_step).toLocaleString()} of `
+ `${Number(j.total_steps).toLocaleString()}, loaded on ${INFER_DEVICE}. `
+ "It gets less incoherent as the run goes on — generate again later "
+ "and compare.";
} else {
chip.innerHTML = '';
}
}
// auto re-run when a fresher snapshot appears
const auto = SIGNED_IN ? document.getElementById('pgAuto') : null;
if(auto && auto.checked && j.live_step !== lastCkpt && j.live_step != null){
lastCkpt = j.live_step;
generate(true);
} else if(j.live_step != null && lastCkpt === null){
lastCkpt = j.live_step;
}
}
const {metrics} = await NX.get(`/api/jobs/${JOB_ID}/metrics`);
NX.lossChart(document.getElementById('chart'), metrics);
const {logs} = await NX.get(`/api/jobs/${JOB_ID}/logs`);
const box = document.getElementById('logs');
const atBottom = box.scrollHeight - box.scrollTop - box.clientHeight < 40;
box.innerHTML = logs.length ? logs.map(l =>
`<span class="t">${new Date(l.t*1000).toLocaleTimeString()}</span>${NX.esc(l.line)}`
).join('\n') : 'no logs yet';
if(atBottom) box.scrollTop = box.scrollHeight;
if(['done','failed','cancelled'].includes(j.status) && stopPoll){ stopPoll(); stopPoll = null; }
}
stopPoll = NX.poll(refresh, 3000);
const cb = document.getElementById('cancelBtn');
if(cb) cb.addEventListener('click', async () => {
if(!confirm('Stop this run? Progress is lost.')) return;
cb.disabled = true;
try{ await NX.post(`/api/jobs/${JOB_ID}/cancel`); NX.toast('Cancellation requested.','ok'); }
catch(e){ NX.toast(NX.esc(e.message),'err'); cb.disabled = false; }
});
const pb = document.getElementById('publishBtn');
if(pb) pb.addEventListener('click', async () => {
pb.disabled = true; pb.textContent = 'Uploading…';
try{
const r = await NX.post(`/api/jobs/${JOB_ID}/publish`,
{repo: document.getElementById('repoName').value});
NX.toast(`Published → <a href="${r.url}" target="_blank"
style="color:var(--accent)">${NX.esc(r.repo)}</a>`, 'ok');
if(!stopPoll) refresh();
}catch(e){ NX.toast(NX.esc(e.message),'err'); }
finally{ pb.disabled = false; pb.textContent = 'Publish'; }
});
['Max','Temp','Topk','Topp'].forEach(k => {
const el = document.getElementById('pg'+k);
if(!el) return;
const out = document.getElementById('v-'+k.toLowerCase());
el.addEventListener('input', () => out.textContent = el.value);
});
const pgGo = document.getElementById('pgGo');
async function generate(quiet){
if(!pgGo || pgGo.disabled) return;
pgGo.disabled = true;
const label = pgGo.textContent;
pgGo.textContent = 'Generating…';
const out = document.getElementById('pgOut');
try{
const r = await NX.post(`/api/jobs/${JOB_ID}/generate`, {
prompt: document.getElementById('pgPrompt').value,
max_new_tokens: Number(document.getElementById('pgMax').value),
temperature: Number(document.getElementById('pgTemp').value),
top_k: Number(document.getElementById('pgTopk').value),
top_p: Number(document.getElementById('pgTopp').value),
});
out.style.display = 'block';
// The prompt is dimmed so it reads as the seed, not as model output.
out.innerHTML = `<span class="pgp">${NX.esc(r.prompt)}</span>`
+ `<span class="pgc">${NX.esc(r.continuation)}</span>`;
document.getElementById('pgStats').textContent =
`${r.new_tokens} tokens · ${r.ms} ms · ${r.device} · `
+ (r.checkpoint === 'final' ? 'final weights'
: `step ${Number(r.step).toLocaleString()}`);
}catch(e){ if(!quiet) NX.toast(NX.esc(e.message),'err'); }
finally{ pgGo.disabled = false; pgGo.textContent = label; }
}
if(pgGo) pgGo.addEventListener('click', () => generate(false));
</script>
{% endblock %}