well-event-transfer-audit / tcn-stream-validation.js
sankalpsthakur's picture
Add complete validation TCN replay, current-only hypothesis and retained failures
f01648d verified
Raw History Blame Contribute Delete
5.81 kB
'use strict';
const $ = id => document.getElementById(id);
const labels = {
original_all_grid_batch256: 'Original offline batches',
eligible_naive_batch1: 'One available reading',
eligible_current_only_eight_copy: 'Eight copies of one available reading'
};
const integer = n => n.toLocaleString('en-US');
const ms = n => `${(n / 1e6).toFixed(3)} ms`;
let saved;
function cell(row, value) { const td = document.createElement('td'); td.textContent = value; row.append(td); return td; }
function render() {
const selected = saved.result.profiles.find(r => r.candidate === $('checkpoint').value && r.profile === $('profile').value);
if (!selected) throw new Error('Frozen profile not present');
const batch = selected.profile === 'original_all_grid_batch256';
$('selection-note').textContent = `${selected.candidate.endsWith('seed7') ? 'Seed 7' : 'Seed 29'} · ${labels[selected.profile]} · ${selected.state === 'PASSED' ? 'Every eligible score matches exactly' : 'Original numerical tolerance FAILED'}.`;
$('failed').textContent = integer(selected.failed_values);
$('failed').classList.toggle('fail', selected.failed_values > 0);
$('failed-detail').textContent = `of ${integer(selected.finite_scores)} eligible scores · maximum difference ${selected.max_abs_difference.toExponential(6)}`;
$('alarm-changes').textContent = integer(selected.alarm_changes_all_grid);
$('alarm-detail').textContent = selected.recorded_threshold === null ? 'Original alarm is disabled' : 'Unchanged threshold and hysteresis';
$('median').textContent = ms(selected.call_median_ns);
$('timing-detail').textContent = `${integer(selected.calls)} ${batch ? 'whole-batch' : 'current-input'} calls · P95 ${ms(selected.call_p95_ns)}`;
$('maximum').textContent = ms(selected.call_max_ns);
$('first-detail').textContent = `First call ${ms(selected.first_call_elapsed_ns)} · retained`;
$('timing-boundary').textContent = batch ? 'Offline cost is per whole batch of up to 256 grid rows. It is not one-reading latency. Original native strides and terminal batch of 164 are preserved.' : 'Current-input call cost includes checking, copying, model and sigmoid. Acquisition and rolling raw-feature work are excluded; these cloud timings are not target-device deadlines.';
const m = selected.common_metric, c = m.counts;
$('alarm-boundary').textContent = selected.recorded_threshold === null ? 'A disabled threshold produces no alarms. Zero alarm changes therefore do not establish a useful detector.' : `Already-selected validation alarm: ${c.covered_episodes}/${c.episodes} episodes covered; ${c.new_known_onset_discoveries_300s} new known-onset discoveries within 300 s; ${c.false_normal_alarm_episodes} false normal alarm over ${m.eligible_normal_days.toFixed(6)} eligible normal days. No fresh detection improvement is claimed.`;
$('profile-rows').replaceChildren();
for (const item of saved.result.profiles) {
const tr = document.createElement('tr'); tr.dataset.candidate = item.candidate; tr.dataset.profile = item.profile;
tr.classList.toggle('selected', item === selected); tr.classList.toggle('fail', item.failed_values > 0);
for (const text of [item.candidate.endsWith('seed7') ? 'Seed 7' : 'Seed 29', labels[item.profile], integer(item.failed_values), integer(item.alarm_changes_all_grid), ms(item.call_median_ns), ms(item.call_p95_ns), ms(item.call_max_ns)]) cell(tr, text);
$('profile-rows').append(tr);
}
$('group-caption').textContent = `${labels[selected.profile]} · eight public filename groups, not authenticated independent physical wells.`;
$('group-rows').replaceChildren();
for (const item of selected.group_comparisons) {
const tr = document.createElement('tr'); tr.dataset.group = item.group;
cell(tr, item.group); cell(tr, integer(item.scored_rows));
const td = cell(tr, integer(item.failed_values)); const bar = document.createElement('div'); bar.className = 'bar';
const fill = document.createElement('div'); fill.className = 'fill'; fill.style.width = `${100 * item.failed_values / item.scored_rows}%`; bar.append(fill); td.append(bar);
cell(tr, item.max_abs_difference === null ? 'Unavailable' : item.max_abs_difference.toExponential(6)); cell(tr, integer(item.alarm_changes));
$('group-rows').append(tr);
}
}
fetch('tcn-stream-validation.json').then(r => { if (!r.ok) throw new Error(`Saved result response ${r.status}`); return r.json(); }).then(data => {
if (data.result.state !== 'COMPLETE_VALIDATION_NUMERICAL_REVIEW_NOT_RESERVED_OR_FIELD_ADMISSION' || data.result.profiles.length !== 6) throw new Error('Complete six-profile result required');
saved = data;
for (const [id, file] of [['report-link', 'REPORT.md'], ['archive-link', 'ORIGINAL-STREAM-OUTPUT.zip'], ['rebuild-link', 'REBUILD.md']]) $('' + id).href = `https://huggingface.co/sankalpsthakur/well-production-event-causal/${id === 'archive-link' ? 'resolve' : 'blob'}/${data.artifact_revision}/tcn-stream-replay/${file}`;
$('output-digest').textContent = data.output_sha256; $('artifact-revision').textContent = data.artifact_revision;
$('resources').textContent = `Linux x86_64 / ${data.result.cpu_capability}, two CPU threads, Torch 2.10.0+cpu, MKLDNN enabled. Provider ${data.provider_elapsed_seconds.toFixed(3)} s, setup ${data.setup_seconds.toFixed(3)} s, feature reconstruction ${(data.result.feature_reconstruction_elapsed_ns / 1e9).toFixed(3)} s; process-lifetime peak RSS ${integer(data.result.peak_rss)} KiB.`;
$('checkpoint').addEventListener('change', render); $('profile').addEventListener('change', render);
render(); $('audit').hidden = false; $('load-state').hidden = true;
}).catch(error => { $('audit').hidden = true; $('load-state').textContent = `Saved results unavailable: ${error.message}. Use the repository report.`; });