feat: factor DeepSeek boundary and role blocks

This commit is contained in:
wuyang
2026-07-29 21:42:07 +08:00
parent 8cebb8cb30
commit 1d0a331e06
21 changed files with 8060293 additions and 33 deletions
@@ -0,0 +1,289 @@
import { createHash } from "node:crypto";
import { readFileSync, statSync, writeFileSync } from "node:fs";
import { resolve } from "node:path";
const root = resolve(import.meta.dirname, "..");
const mainPath = resolve(
root,
"src/data/deepseek-v2-lite-routing-role-marker-block-factorial.json",
);
const reproPath = resolve(
root,
"src/data/deepseek-v2-lite-routing-role-marker-block-factorial-repro.json",
);
const roleHeadPath = resolve(
root,
"src/data/deepseek-v2-lite-routing-role-marker-head-control.json",
);
const outputPath = resolve(
root,
"src/data/deepseek-v2-lite-routing-role-marker-block-factorial-compact.json",
);
const sha256 = (path) => createHash("sha256")
.update(readFileSync(path))
.digest("hex");
const mainSha256 = sha256(mainPath);
const reproSha256 = sha256(reproPath);
const mainBytes = statSync(mainPath).size;
const reproBytes = statSync(reproPath).size;
const exact = mainSha256 === reproSha256 && mainBytes === reproBytes;
if (!exact) {
throw new Error("role-block formal run and rerun are not byte-exact");
}
const block = JSON.parse(readFileSync(mainPath, "utf8"));
const head = JSON.parse(readFileSync(roleHeadPath, "utf8"));
const blockEdges = [
"system_user_colon",
"system_assistant_colon",
"system_user_x",
"system_assistant_x",
"assistant_colon_at_s0",
"assistant_colon_at_s1",
"user_x_at_s0",
"user_x_at_s1",
"assistant_x_at_s0",
"assistant_x_at_s1",
"head_at_x_s0",
"head_at_x_s1",
"delimiter_at_assistant_s0",
"delimiter_at_assistant_s1",
];
const aggregateAlignment = (layer, domain, edge) => {
const rows = layer.prompts
.filter((prompt) => prompt.domain === domain)
.map((prompt) => prompt.alignments[edge]);
const aligned = rows.reduce(
(sum, row) => sum + row.aligned_tokens,
0,
);
const setExact = rows.reduce(
(sum, row) => sum + row.set_topk_exact,
0,
);
const orderedExact = rows.reduce(
(sum, row) => sum + row.ordered_topk_exact,
0,
);
const weightedJaccard = rows.reduce(
(sum, row) => sum + row.mean_jaccard * row.aligned_tokens,
0,
);
return {
aligned,
setExactRate: setExact / aligned,
orderedExactRate: orderedExact / aligned,
meanJaccard: weightedJaccard / aligned,
};
};
const sharedMappings = {
user_colon: "official",
assistant_colon: "target_assistant",
};
const sourceById = new Map(
head.corpus_contract.selected.map((source) => [source.id, source]),
);
const tokenContract = {
compared: 0,
messageHashExact: 0,
renderedHashExact: 0,
tokenIdHashExact: 0,
targetContractExact: 0,
};
for (const source of block.corpus_contract.selected) {
const previousSource = sourceById.get(source.id);
if (!previousSource) throw new Error(`role-head source missing: ${source.id}`);
for (const system of [0, 1]) {
for (const [level, previousLevel] of Object.entries(sharedMappings)) {
const current = source.conditions[`s${system}_${level}`];
const previous = (
previousSource.conditions[`s${system}_${previousLevel}`]
);
tokenContract.compared += 1;
tokenContract.messageHashExact += (
current.messages_sha256 === previous.messages_sha256
);
tokenContract.renderedHashExact += (
current.rendered_sha256 === previous.rendered_sha256
);
tokenContract.tokenIdHashExact += (
current.token_ids_sha256 === previous.token_ids_sha256
);
tokenContract.targetContractExact += (
current.tokens === previous.tokens
&& current.content_tokens === previous.content_tokens
&& current.aligned_content_tokens
=== previous.aligned_content_tokens
);
}
}
}
const crossBatch = block.layers.slice(1).flatMap((layer) => {
const previousLayer = head.layers.find(
(candidate) => candidate.layer === layer.layer,
);
const previousById = new Map(
previousLayer.prompts.map((prompt) => [prompt.id, prompt]),
);
return Object.entries(sharedMappings).map(([level, previousLevel]) => {
const counts = {
compared: 0,
fullRouteHashExact: 0,
targetRouteHashExact: 0,
fullLoadExact: 0,
targetLoadExact: 0,
};
for (const prompt of layer.prompts) {
const previousPrompt = previousById.get(prompt.id);
if (!previousPrompt) {
throw new Error(`role-head prompt missing: ${prompt.id}`);
}
for (const system of [0, 1]) {
const current = prompt.conditions[`s${system}_${level}`];
const previous = (
previousPrompt.conditions[`s${system}_${previousLevel}`]
);
counts.compared += 1;
counts.fullRouteHashExact += (
current.topk_sha256 === previous.topk_sha256
);
counts.targetRouteHashExact += (
current.content_topk_sha256 === previous.content_topk_sha256
);
counts.fullLoadExact += (
JSON.stringify(current.full_load)
=== JSON.stringify(previous.full_load)
);
counts.targetLoadExact += (
JSON.stringify(current.content_load)
=== JSON.stringify(previous.content_load)
);
}
}
return {
layer: layer.layer,
level,
previousLevel,
...counts,
};
});
});
const compact = {
schemaVersion: 1,
source: {
mainSha256,
reproSha256,
mainBytes,
reproBytes,
exact,
},
domains: block.corpus_contract.domains,
labels: block.corpus_contract.domain_labels,
inference: block.inference_contract,
contract: {
tokenIds: block.role_marker_block_contract.role_token_ids,
officialIds: (
block.role_marker_block_contract.official_target_block_ids
),
levels: block.role_marker_block_contract.level_factors,
validation: block.role_marker_block_contract.render_validation,
official: block.boundary.official_serialization_by_role_block,
tokenContractAgainstRoleHeadRun: tokenContract,
},
crossBatch,
layers: block.layers.slice(1).map((layer) => ({
layer: layer.layer,
alignment: Object.fromEntries(
block.corpus_contract.domains.map((domain) => [
domain,
Object.fromEntries(
blockEdges.map((edge) => [
edge,
aggregateAlignment(layer, domain, edge),
]),
),
]),
),
scopes: Object.fromEntries(
["target_content", "full_input"].map((scope) => [
scope,
{
modes: Object.fromEntries(
["prompt_balanced", "token_weighted"].map((mode) => {
const control = (
layer.statistics[scope].modes[mode].role_block_control
);
return [
mode,
Object.fromEntries(
block.corpus_contract.domains.map((domain) => [
domain,
{
distances: control[domain].system_edge_distances,
contrasts: (
control[domain].system_edge_distance_contrasts
),
cvEdges: control[domain].metric_system_edges.cv,
cvContrasts: (
control[domain].metric_system_edge_contrasts.cv
),
direct: control[domain].direct_substitutions,
factorial: {
factorCoding: (
control[domain].role_block_factorial.factor_coding
),
systemEdgeDistanceEffects: (
control[domain].role_block_factorial
.system_edge_distance_effects
),
metricSystemEdgeEffects: (
control[domain].role_block_factorial
.metric_system_edge_effects
),
distributionSystemEdgeMagnitudes: (
Object.fromEntries(
Object.entries(
control[domain].role_block_factorial
.distribution_system_edge_effects,
).map(([name, value]) => [
name,
value.half_l1_magnitude,
]),
)
),
directFactorEdges: (
control[domain].role_block_factorial
.direct_factor_edges
),
directEffectDependencies: (
control[domain].role_block_factorial
.direct_effect_dependencies
),
},
},
]),
),
];
}),
),
},
]),
),
})),
};
writeFileSync(
outputPath,
`${JSON.stringify(compact, null, 2)}\n`,
"utf8",
);
process.stdout.write(
`${outputPath}\n${mainSha256}\n${mainBytes} bytes source → `
+ `${statSync(outputPath).size} bytes compact\n`,
);
@@ -0,0 +1,245 @@
import { createHash } from "node:crypto";
import { readFileSync, statSync, writeFileSync } from "node:fs";
import { resolve } from "node:path";
const root = resolve(import.meta.dirname, "..");
const mainPath = resolve(
root,
"src/data/deepseek-v2-lite-routing-special-token-family-control.json",
);
const reproPath = resolve(
root,
"src/data/deepseek-v2-lite-routing-special-token-family-control-repro.json",
);
const boundaryPath = resolve(
root,
"src/data/deepseek-v2-lite-routing-history-boundary-token-control.json",
);
const outputPath = resolve(
root,
"src/data/deepseek-v2-lite-routing-special-token-family-control-compact.json",
);
const sha256 = (path) => createHash("sha256")
.update(readFileSync(path))
.digest("hex");
const mainSha256 = sha256(mainPath);
const reproSha256 = sha256(reproPath);
const mainBytes = statSync(mainPath).size;
const reproBytes = statSync(reproPath).size;
const exact = mainSha256 === reproSha256 && mainBytes === reproBytes;
if (!exact) {
throw new Error("special-token formal run and rerun are not byte-exact");
}
const family = JSON.parse(readFileSync(mainPath, "utf8"));
const boundary = JSON.parse(readFileSync(boundaryPath, "utf8"));
const familyEdges = [
"system_eos",
"system_bos",
"system_x",
"system_period",
"bos_at_s0",
"bos_at_s1",
"x_at_s0",
"x_at_s1",
"period_at_s0",
"period_at_s1",
];
const aggregateAlignment = (layer, domain, edge) => {
const rows = layer.prompts
.filter((prompt) => prompt.domain === domain)
.map((prompt) => prompt.alignments[edge]);
const aligned = rows.reduce(
(sum, row) => sum + row.aligned_tokens,
0,
);
const setExact = rows.reduce(
(sum, row) => sum + row.set_topk_exact,
0,
);
const orderedExact = rows.reduce(
(sum, row) => sum + row.ordered_topk_exact,
0,
);
const weightedJaccard = rows.reduce(
(sum, row) => sum + row.mean_jaccard * row.aligned_tokens,
0,
);
return {
aligned,
setExactRate: setExact / aligned,
orderedExactRate: orderedExact / aligned,
meanJaccard: weightedJaccard / aligned,
};
};
const sharedLevels = ["eos", "x", "period"];
const sourceById = new Map(
boundary.corpus_contract.selected.map((source) => [source.id, source]),
);
const tokenContract = {
compared: 0,
messageHashExact: 0,
renderedHashExact: 0,
tokenIdHashExact: 0,
targetContractExact: 0,
};
for (const source of family.corpus_contract.selected) {
const previousSource = sourceById.get(source.id);
if (!previousSource) throw new Error(`boundary source missing: ${source.id}`);
for (const system of [0, 1]) {
for (const level of sharedLevels) {
const current = source.conditions[`s${system}_${level}`];
const previous = previousSource.conditions[`s${system}_${level}`];
tokenContract.compared += 1;
tokenContract.messageHashExact += (
current.messages_sha256 === previous.messages_sha256
);
tokenContract.renderedHashExact += (
current.rendered_sha256 === previous.rendered_sha256
);
tokenContract.tokenIdHashExact += (
current.token_ids_sha256 === previous.token_ids_sha256
);
tokenContract.targetContractExact += (
current.tokens === previous.tokens
&& current.content_tokens === previous.content_tokens
&& current.aligned_content_tokens
=== previous.aligned_content_tokens
);
}
}
}
const crossBatch = family.layers.slice(1).flatMap((layer) => {
const previousLayer = boundary.layers.find(
(candidate) => candidate.layer === layer.layer,
);
const previousById = new Map(
previousLayer.prompts.map((prompt) => [prompt.id, prompt]),
);
return sharedLevels.map((level) => {
const counts = {
compared: 0,
fullRouteHashExact: 0,
targetRouteHashExact: 0,
fullLoadExact: 0,
targetLoadExact: 0,
};
for (const prompt of layer.prompts) {
const previousPrompt = previousById.get(prompt.id);
if (!previousPrompt) {
throw new Error(`boundary prompt missing: ${prompt.id}`);
}
for (const system of [0, 1]) {
const condition = `s${system}_${level}`;
const current = prompt.conditions[condition];
const previous = previousPrompt.conditions[condition];
counts.compared += 1;
counts.fullRouteHashExact += (
current.topk_sha256 === previous.topk_sha256
);
counts.targetRouteHashExact += (
current.content_topk_sha256 === previous.content_topk_sha256
);
counts.fullLoadExact += (
JSON.stringify(current.full_load)
=== JSON.stringify(previous.full_load)
);
counts.targetLoadExact += (
JSON.stringify(current.content_load)
=== JSON.stringify(previous.content_load)
);
}
}
return { layer: layer.layer, level, ...counts };
});
});
const compact = {
schemaVersion: 1,
source: {
mainSha256,
reproSha256,
mainBytes,
reproBytes,
exact,
},
domains: family.corpus_contract.domains,
labels: family.corpus_contract.domain_labels,
inference: family.inference_contract,
contract: {
tokenIds: family.special_token_family_contract.boundary_token_ids,
inventory: (
family.special_token_family_contract.tokenizer_special_inventory
),
validation: family.special_token_family_contract.render_validation,
official: family.boundary.official_serialization_by_boundary,
classBoundary: (
family.special_token_family_contract.class_comparison_boundary
),
tokenContractAgainstBoundaryRun: tokenContract,
},
crossBatch,
layers: family.layers.slice(1).map((layer) => ({
layer: layer.layer,
alignment: Object.fromEntries(
family.corpus_contract.domains.map((domain) => [
domain,
Object.fromEntries(
familyEdges.map((edge) => [
edge,
aggregateAlignment(layer, domain, edge),
]),
),
]),
),
scopes: Object.fromEntries(
["target_content", "full_input"].map((scope) => [
scope,
{
modes: Object.fromEntries(
["prompt_balanced", "token_weighted"].map((mode) => {
const control = (
layer.statistics[scope].modes[mode].boundary_control
);
return [
mode,
Object.fromEntries(
family.corpus_contract.domains.map((domain) => [
domain,
{
distances: control[domain].system_edge_distances,
contrasts: (
control[domain].system_edge_distance_contrasts
),
cvEdges: control[domain].metric_system_edges.cv,
cvContrasts: (
control[domain].metric_system_edge_contrasts.cv
),
direct: control[domain].direct_substitutions,
family: control[domain].descriptive_family_summary,
},
]),
),
];
}),
),
},
]),
),
})),
};
writeFileSync(
outputPath,
`${JSON.stringify(compact, null, 2)}\n`,
"utf8",
);
process.stdout.write(
`${outputPath}\n${mainSha256}\n${mainBytes} bytes source → `
+ `${statSync(outputPath).size} bytes compact\n`,
);
+191 -6
View File
@@ -608,8 +608,8 @@ const artifactRole = await evaluate(`(() => {
depthTitle: root.querySelector("[data-role-depth-title]").textContent.trim(),
exact: root.querySelector(".role-ledger .exact b").textContent.trim(),
causalCards: root.querySelectorAll(".role-causal-ledger > article").length,
batchCells: root.querySelectorAll(".role-batch-audit > div:last-child > span").length,
batchValues: [...root.querySelectorAll(".role-batch-audit > div:last-child > span i")].map((node) => node.textContent.trim()),
batchCells: root.querySelectorAll('[data-artifact-panel="role"] .role-batch-audit > div:last-child > span').length,
batchValues: [...root.querySelectorAll('[data-artifact-panel="role"] .role-batch-audit > div:last-child > span i')].map((node) => node.textContent.trim()),
note: root.querySelector("[data-role-note]").textContent.trim(),
targetHead: root.querySelector("[data-role-target-head]").textContent.trim(),
suffixHead: root.querySelector("[data-role-suffix-head]").textContent.trim(),
@@ -646,6 +646,135 @@ await evaluate(`(() => {
await pause(120);
await screenshot("/tmp/llm-atlas-deepseek-role-results-desktop.png");
const artifactSpecial = await evaluate(`(() => {
const root = document.querySelector("[data-dsv2-lab]");
root.querySelector('[data-artifact-tab="special"]').click();
const read = () => ({
panel: root.querySelector("[data-artifact-panel]:not([hidden])").dataset.artifactPanel,
tokenCards: root.querySelectorAll(".special-token-grid > article").length,
domainCards: root.querySelectorAll("[data-special-domain-grid] > article").length,
domains: [...root.querySelectorAll("[data-special-domain-grid] > article")].map((node) => ({
label: node.querySelector(":scope > span").textContent.trim(),
values: [...node.querySelectorAll(".special-tv-ladder > b")].map((cell) => ({
name: cell.querySelector("small").textContent.trim(),
value: cell.querySelector("strong").textContent.trim(),
})),
effect: node.querySelector(":scope > strong").textContent.trim(),
className: node.querySelector(":scope > strong").className,
ci: node.querySelector(":scope > p").textContent.trim(),
detail: node.querySelector(":scope > em").textContent.trim(),
stability: node.querySelector(":scope > small").textContent.trim(),
cv: node.querySelector(":scope > i").textContent.trim(),
})),
summary: [...root.querySelectorAll('[data-artifact-panel="special"] .special-summary article b')].map((node) => node.textContent.trim()),
depthRows: root.querySelectorAll("[data-special-depth-map] > div").length,
depthCells: root.querySelectorAll("[data-special-depth-map] > div > span").length,
depthTitle: root.querySelector("[data-special-depth-title]").textContent.trim(),
exact: root.querySelector(".special-ledger .exact b").textContent.trim(),
scopeCards: root.querySelectorAll('[data-artifact-panel="special"] .special-scope-ledger > article').length,
batchCells: root.querySelectorAll(".special-batch-audit > div:last-child > span").length,
batchValues: [...root.querySelectorAll(".special-batch-audit > div:last-child > span i")].map((node) => node.textContent.trim()),
note: root.querySelector("[data-special-note]").textContent.trim(),
activeLayer: root.querySelector("[data-special-layer].active").textContent.trim(),
activeScope: root.querySelector('[data-special-scope][aria-pressed="true"]').dataset.specialScope,
activeMode: root.querySelector('[data-special-mode][aria-pressed="true"]').dataset.specialMode,
activeContrast: root.querySelector('[data-special-contrast][aria-pressed="true"]').dataset.specialContrast,
});
const layer1Bos = read();
root.querySelector('[data-special-layer="4"]').click();
root.querySelector('[data-special-contrast="x_minus_eos"]').click();
const layer4X = read();
root.querySelector('[data-special-contrast="period_minus_eos"]').click();
const layer4Period = read();
root.querySelector('[data-special-contrast="family"]').click();
const layer4Family = read();
root.querySelector('[data-special-scope="full_input"]').click();
const layer4FullFamily = read();
root.querySelector('[data-special-mode="token_weighted"]').click();
const layer4FullToken = read();
root.querySelector('[data-special-layer="1"]').click();
root.querySelector('[data-special-scope="target_content"]').click();
root.querySelector('[data-special-mode="prompt_balanced"]').click();
root.querySelector('[data-special-contrast="bos_minus_eos"]').click();
return { layer1Bos, layer4X, layer4Period, layer4Family, layer4FullFamily, layer4FullToken, restored: read() };
})()`);
await evaluate(`(() => {
document.querySelector("[data-dsv2-lab]").scrollIntoView({ block: "start", behavior: "instant" });
window.scrollBy(0, -82);
})()`);
await pause(180);
await screenshot("/tmp/llm-atlas-deepseek-special-desktop.png");
await evaluate(`(() => {
document.querySelector(".special-domain-grid").scrollIntoView({ block: "center", behavior: "instant" });
})()`);
await pause(120);
await screenshot("/tmp/llm-atlas-deepseek-special-results-desktop.png");
const artifactRoleBlock = await evaluate(`(() => {
const root = document.querySelector("[data-dsv2-lab]");
root.querySelector('[data-artifact-tab="role-block"]').click();
const read = () => ({
panel: root.querySelector("[data-artifact-panel]:not([hidden])").dataset.artifactPanel,
matrixCards: root.querySelectorAll(".role-block-matrix > article").length,
domainCards: root.querySelectorAll("[data-role-block-domain-grid] > article").length,
domains: [...root.querySelectorAll("[data-role-block-domain-grid] > article")].map((node) => ({
label: node.querySelector(":scope > span").textContent.trim(),
values: [...node.querySelectorAll(".role-block-tv-ladder > b")].map((cell) => ({
name: cell.querySelector("small").textContent.trim(),
value: cell.querySelector("strong").textContent.trim(),
})),
effect: node.querySelector(":scope > strong").textContent.trim(),
className: node.querySelector(":scope > strong").className,
ci: node.querySelector(":scope > p").textContent.trim(),
direct: node.querySelector(":scope > em").textContent.trim(),
dependency: node.querySelector(":scope > u").textContent.trim(),
stability: node.querySelector(":scope > small").textContent.trim(),
cv: node.querySelector(":scope > i").textContent.trim(),
})),
summary: [...root.querySelectorAll('[data-artifact-panel="role-block"] .role-block-summary article b')].map((node) => node.textContent.trim()),
directCards: root.querySelectorAll(".role-block-direct > article").length,
depthRows: root.querySelectorAll("[data-role-block-depth-map] > div").length,
depthCells: root.querySelectorAll("[data-role-block-depth-map] > div > span").length,
depthTitle: root.querySelector("[data-role-block-depth-title]").textContent.trim(),
exact: root.querySelector(".role-block-ledger .exact b").textContent.trim(),
boundaryCards: root.querySelectorAll(".role-block-boundaries > article").length,
batchCells: root.querySelectorAll(".role-block-batch-audit > div:last-child > span").length,
batchValues: [...root.querySelectorAll(".role-block-batch-audit > div:last-child > span i")].map((node) => node.textContent.trim()),
note: root.querySelector("[data-role-block-note]").textContent.trim(),
activeLayer: root.querySelector("[data-role-block-layer].active").textContent.trim(),
activeScope: root.querySelector('[data-role-block-scope][aria-pressed="true"]').dataset.roleBlockScope,
activeMode: root.querySelector('[data-role-block-mode][aria-pressed="true"]').dataset.roleBlockMode,
activeEffect: root.querySelector('[data-role-block-effect][aria-pressed="true"]').dataset.roleBlockEffect,
});
const layer1Head = read();
root.querySelector('[data-role-block-layer="4"]').click();
root.querySelector('[data-role-block-effect="delimiter_main"]').click();
const layer4Delimiter = read();
root.querySelector('[data-role-block-layer="5"]').click();
root.querySelector('[data-role-block-effect="head_by_delimiter"]').click();
const layer5Interaction = read();
root.querySelector('[data-role-block-scope="full_input"]').click();
const layer5FullInteraction = read();
root.querySelector('[data-role-block-mode="token_weighted"]').click();
const layer5FullToken = read();
root.querySelector('[data-role-block-layer="1"]').click();
root.querySelector('[data-role-block-scope="target_content"]').click();
root.querySelector('[data-role-block-mode="prompt_balanced"]').click();
root.querySelector('[data-role-block-effect="head_main"]').click();
return { layer1Head, layer4Delimiter, layer5Interaction, layer5FullInteraction, layer5FullToken, restored: read() };
})()`);
await evaluate(`(() => {
document.querySelector("[data-dsv2-lab]").scrollIntoView({ block: "start", behavior: "instant" });
window.scrollBy(0, -82);
})()`);
await pause(180);
await screenshot("/tmp/llm-atlas-deepseek-role-block-desktop.png");
await evaluate(`(() => {
document.querySelector(".role-block-domain-grid").scrollIntoView({ block: "center", behavior: "instant" });
})()`);
await pause(120);
await screenshot("/tmp/llm-atlas-deepseek-role-block-results-desktop.png");
const artifactEvidence = await evaluate(`(() => {
const root = document.querySelector("[data-dsv2-lab]");
root.querySelector('[data-artifact-tab="evidence"]').click();
@@ -750,6 +879,20 @@ const mobile = await evaluate(`(() => {
roleLevelCards: artifact.querySelectorAll(".role-level-grid > article").length,
roleDomainCards: artifact.querySelectorAll("[data-role-domain-grid] > article").length,
roleDepthCells: artifact.querySelectorAll("[data-role-depth-map] > div > span").length,
specialLayers: artifact.querySelectorAll("[data-special-layer]").length,
specialScopes: artifact.querySelectorAll("[data-special-scope]").length,
specialModes: artifact.querySelectorAll("[data-special-mode]").length,
specialContrasts: artifact.querySelectorAll("[data-special-contrast]").length,
specialTokenCards: artifact.querySelectorAll(".special-token-grid > article").length,
specialDomainCards: artifact.querySelectorAll("[data-special-domain-grid] > article").length,
specialDepthCells: artifact.querySelectorAll("[data-special-depth-map] > div > span").length,
roleBlockLayers: artifact.querySelectorAll("[data-role-block-layer]").length,
roleBlockScopes: artifact.querySelectorAll("[data-role-block-scope]").length,
roleBlockModes: artifact.querySelectorAll("[data-role-block-mode]").length,
roleBlockEffects: artifact.querySelectorAll("[data-role-block-effect]").length,
roleBlockMatrixCards: artifact.querySelectorAll(".role-block-matrix > article").length,
roleBlockDomainCards: artifact.querySelectorAll("[data-role-block-domain-grid] > article").length,
roleBlockDepthCells: artifact.querySelectorAll("[data-role-block-depth-map] > div > span").length,
offenders: [...document.querySelectorAll("body *")]
.filter((node) => !node.closest(".paper-chain, .advantage-table, .precision-table, .mapping-table, [data-deepseek-lab], [data-dsv2-lab]"))
.filter((node) => node.getBoundingClientRect().right > document.documentElement.clientWidth + 1)
@@ -847,8 +990,36 @@ await evaluate(`(() => {
})()`);
await pause(120);
await screenshot("/tmp/llm-atlas-deepseek-role-results-mobile.png");
await evaluate(`(() => {
const artifact = document.querySelector("[data-dsv2-lab]");
artifact.querySelector('[data-artifact-tab="special"]').click();
artifact.scrollIntoView({ block: "start", behavior: "instant" });
window.scrollBy(0, -70);
})()`);
await pause(180);
await screenshot("/tmp/llm-atlas-deepseek-special-mobile.png");
await evaluate(`(() => {
document.querySelector(".special-domain-grid").scrollIntoView({ block: "start", behavior: "instant" });
window.scrollBy(0, -72);
})()`);
await pause(120);
await screenshot("/tmp/llm-atlas-deepseek-special-results-mobile.png");
await evaluate(`(() => {
const artifact = document.querySelector("[data-dsv2-lab]");
artifact.querySelector('[data-artifact-tab="role-block"]').click();
artifact.scrollIntoView({ block: "start", behavior: "instant" });
window.scrollBy(0, -70);
})()`);
await pause(180);
await screenshot("/tmp/llm-atlas-deepseek-role-block-mobile.png");
await evaluate(`(() => {
document.querySelector(".role-block-domain-grid").scrollIntoView({ block: "start", behavior: "instant" });
window.scrollBy(0, -72);
})()`);
await pause(120);
await screenshot("/tmp/llm-atlas-deepseek-role-block-results-mobile.png");
const report = { overview, capacity, cache, codesign, rl, artifactRoute, artifactLoad, artifactCache, artifactAbsorb, artifactCorpus, artifactTemplate, artifactHistory, artifactDistance, artifactBoundary, artifactRole, artifactEvidence, home, papers, mobile, exceptions };
const report = { overview, capacity, cache, codesign, rl, artifactRoute, artifactLoad, artifactCache, artifactAbsorb, artifactCorpus, artifactTemplate, artifactHistory, artifactDistance, artifactBoundary, artifactRole, artifactSpecial, artifactRoleBlock, artifactEvidence, home, papers, mobile, exceptions };
console.log(JSON.stringify(report, null, 2));
const numeric = (text) => Number.parseFloat(text.replaceAll(",", ""));
@@ -858,8 +1029,8 @@ if (overview.sections !== 26 || overview.tocLinks !== 26) failures.push("二十
if (overview.ledgers !== 24 || overview.waves !== 10) failures.push("二十四张问题账或十次转向结构异常");
if (overview.paperLinks !== 60 || overview.branches !== 5 || overview.followups !== 1) failures.push("论文链、旁支或公开后续标记异常");
if (overview.labTabs !== 4 || overview.labPanels !== 4) failures.push("四联实验结构异常");
if (overview.artifactTabs !== 11 || overview.artifactPanels !== 11 || overview.artifactLayers !== 27) failures.push("真实权重十一联实验结构异常");
if (overview.heroLabs !== "15 个可操作实验") failures.push("DeepSeek 实验总数账异常");
if (overview.artifactTabs !== 13 || overview.artifactPanels !== 13 || overview.artifactLayers !== 27) failures.push("真实权重十三联实验结构异常");
if (overview.heroLabs !== "17 个可操作实验") failures.push("DeepSeek 实验总数账异常");
if (overview.navLinks !== 20 || home.navLinks !== 20 || mobile.mobileLinks !== 20 || overview.activeNav !== "DeepSeek") failures.push("全站导航未同步 DeepSeek");
if (overview.documentOverflow > 1 || mobile.documentOverflow > 1) failures.push("桌面或移动端存在文档级横向溢出");
if (capacity.initial.panel !== "capacity" || capacity.initial.total !== "32.1× FFN" || capacity.initial.active !== "1.13× FFN") failures.push("V3 稀疏容量初始账异常");
@@ -929,12 +1100,26 @@ if (artifactRole.layer5Suffix.domains.some((domain) => domain.effect !== "SUFFIX
if (artifactRole.layer5FullSuffix.activeScope !== "full_input" || !artifactRole.layer5FullSuffix.note.includes("suffix 自身") || artifactRole.layer5FullSuffix.domains[0].values[0].value === artifactRole.layer5Suffix.domains[0].values[0].value) failures.push("角色词头完整输入 scope 异常");
if (artifactRole.layer5FullToken.activeMode !== "token_weighted" || artifactRole.restored.activeLayer !== "L1" || artifactRole.restored.activeScope !== "target_content" || artifactRole.restored.activeMode !== "prompt_balanced" || artifactRole.restored.activeContrast !== "target_assistant_minus_official" || artifactRole.restored.targetHead !== "Assistant" || artifactRole.restored.suffixHead !== "Assistant") failures.push("角色词头聚合口径或恢复状态异常");
if (artifactRole.layer1Assistant.batchValues.join("|") !== "256 / 256|180 / 256|149 / 256|102 / 256|72 / 256|73 / 256") failures.push("角色词头 BF16 batch-content 审计异常");
if (artifactSpecial.layer1Bos.panel !== "special" || artifactSpecial.layer1Bos.tokenCards !== 4 || artifactSpecial.layer1Bos.domainCards !== 4 || artifactSpecial.layer1Bos.depthRows !== 4 || artifactSpecial.layer1Bos.depthCells !== 24 || artifactSpecial.layer1Bos.exact !== "BYTE-EXACT" || artifactSpecial.layer1Bos.scopeCards !== 3 || artifactSpecial.layer1Bos.batchCells !== 6) failures.push("特殊词元家族控制结构或独立复跑闸门异常");
if (artifactSpecial.layer1Bos.domains[0].values.map((cell) => cell.value).join("/") !== "0.056/0.108/0.084/0.081" || artifactSpecial.layer1Bos.domains[0].effect !== "BOS − EOS · ΔTV +0.052" || !artifactSpecial.layer1Bos.domains[0].ci.includes("+0.040, +0.061")) failures.push("L1 英文特殊词元家族统计异常");
if (!artifactSpecial.layer1Bos.domains[0].detail.includes("S0 0.087 · S1 0.064") || !artifactSpecial.layer1Bos.domains[0].stability.includes("S0 37.4%") || artifactSpecial.layer1Bos.summary.join("|") !== ".037518|+.010500|24↑ / 24↑|+.011864") failures.push("特殊词元直接效应、对齐率或总账异常");
if (artifactSpecial.layer4X.activeContrast !== "x_minus_eos" || !artifactSpecial.layer4X.depthTitle.includes("普通内容 token") || artifactSpecial.layer4Period.activeContrast !== "period_minus_eos" || !artifactSpecial.layer4Period.depthTitle.includes("句点")) failures.push("特殊词元单 ID contrast 切换异常");
if (artifactSpecial.layer4Family.activeContrast !== "family" || !artifactSpecial.layer4Family.note.includes("四个 ID") || !artifactSpecial.layer4Family.domains.every((domain) => domain.stability.includes("2-vs-2"))) failures.push("特殊词元描述性 family 汇总异常");
if (artifactSpecial.layer4FullFamily.activeScope !== "full_input" || !artifactSpecial.layer4FullFamily.note.includes("完整输入") || artifactSpecial.layer4FullToken.activeMode !== "token_weighted") failures.push("特殊词元完整输入或聚合口径切换异常");
if (artifactSpecial.restored.activeLayer !== "L1" || artifactSpecial.restored.activeScope !== "target_content" || artifactSpecial.restored.activeMode !== "prompt_balanced" || artifactSpecial.restored.activeContrast !== "bos_minus_eos") failures.push("特殊词元控制恢复状态异常");
if (artifactSpecial.layer1Bos.batchValues.join("|") !== "768 / 768|610 / 768|477 / 768|368 / 768|269 / 768|244 / 768") failures.push("特殊词元 BF16 batch-content 审计异常");
if (artifactRoleBlock.layer1Head.panel !== "role-block" || artifactRoleBlock.layer1Head.matrixCards !== 4 || artifactRoleBlock.layer1Head.domainCards !== 4 || artifactRoleBlock.layer1Head.depthRows !== 4 || artifactRoleBlock.layer1Head.depthCells !== 24 || artifactRoleBlock.layer1Head.exact !== "BYTE-EXACT" || artifactRoleBlock.layer1Head.directCards !== 4 || artifactRoleBlock.layer1Head.boundaryCards !== 3 || artifactRoleBlock.layer1Head.batchCells !== 6) failures.push("完整角色块 2×2 结构或独立复跑闸门异常");
if (artifactRoleBlock.layer1Head.domains[0].values.map((cell) => cell.value).join("/") !== "0.056/0.059/0.056/0.058" || artifactRoleBlock.layer1Head.domains[0].effect !== "HEAD MAIN · ΔTV +0.002" || !artifactRoleBlock.layer1Head.domains[0].ci.includes("-0.002, +0.004")) failures.push("L1 英文完整角色块 head 统计异常");
if (!artifactRoleBlock.layer1Head.domains[0].direct.includes("head @ colon") || !artifactRoleBlock.layer1Head.domains[0].dependency.includes("head @ x") || artifactRoleBlock.layer1Head.summary.join("|") !== ".037304 → .036220|−.000654|−.000430|−.000729") failures.push("完整角色块直接边或总账异常");
if (artifactRoleBlock.layer4Delimiter.activeEffect !== "delimiter_main" || !artifactRoleBlock.layer4Delimiter.depthTitle.includes("冒号→x") || artifactRoleBlock.layer5Interaction.activeEffect !== "head_by_delimiter" || !artifactRoleBlock.layer5Interaction.depthTitle.includes("依赖 delimiter") || !artifactRoleBlock.layer5Interaction.domains[0].direct.includes("head@x − head@colon")) failures.push("完整角色块因子或 interaction 切换异常");
if (artifactRoleBlock.layer5FullInteraction.activeScope !== "full_input" || artifactRoleBlock.layer5FullToken.activeMode !== "token_weighted" || artifactRoleBlock.restored.activeLayer !== "L1" || artifactRoleBlock.restored.activeScope !== "target_content" || artifactRoleBlock.restored.activeMode !== "prompt_balanced" || artifactRoleBlock.restored.activeEffect !== "head_main") failures.push("完整角色块 scope、聚合口径或恢复状态异常");
if (artifactRoleBlock.layer1Head.batchValues.join("|") !== "512 / 512|368 / 512|279 / 512|230 / 512|178 / 512|156 / 512") failures.push("完整角色块 BF16 batch-content 审计异常");
if (artifactEvidence.panel !== "evidence" || artifactEvidence.layers !== 27 || artifactEvidence.executed !== 7 || artifactEvidence.split !== 1 || artifactEvidence.unloaded !== 19 || artifactEvidence.exact !== "31 / 31") failures.push("真实工件执行边界或复跑闸门异常");
if (!artifactEvidence.dependency.includes("Transformers 5.5") || !artifactEvidence.dependency.includes("4.41.2") || !artifactEvidence.boundary.includes("完整 27 层生成")) failures.push("依赖版本或未覆盖边界异常");
if (artifactEvidence.keyboardSelected !== "load" || artifactEvidence.keyboardVisible !== "load") failures.push("真实工件实验键盘 tab 导航异常");
if (home.releaseCards !== 17 || !home.firstRelease.includes("47 页不再压成摘要") || home.firstHref !== "/k3/" || home.paperCount !== "486") failures.push("首页 DeepSeek 首发入口或论文数异常");
if (papers.total !== 486 || !papers.hasFilter || papers.visible < 20 || !papers.hasCoder || !papers.hasEngram) failures.push("论文库 DeepSeek 聚光异常");
if (!mobile.menuVisible || mobile.menuOpen !== "true" || mobile.tabs !== 4 || mobile.artifactTabs !== 11 || mobile.artifactHeatCells !== 64 || mobile.corpusCohorts !== 3 || mobile.lengthDeltaCards !== 4 || mobile.templateLayers !== 6 || mobile.templateScopes !== 2 || mobile.templateModes !== 2 || mobile.templateDomainCards !== 4 || mobile.templateDepthCells !== 24 || mobile.historyLayers !== 6 || mobile.historyScopes !== 2 || mobile.historyModes !== 2 || mobile.historyEffects !== 3 || mobile.historyDomainCards !== 4 || mobile.historyDepthCells !== 24 || mobile.distanceLayers !== 6 || mobile.distanceScopes !== 2 || mobile.distanceModes !== 2 || mobile.distanceContrasts !== 2 || mobile.distanceDomainCards !== 4 || mobile.distanceDepthCells !== 24 || mobile.boundaryLayers !== 6 || mobile.boundaryScopes !== 2 || mobile.boundaryModes !== 2 || mobile.boundaryContrasts !== 3 || mobile.boundaryTokenCards !== 4 || mobile.boundaryDomainCards !== 4 || mobile.boundaryDepthCells !== 24 || mobile.roleLayers !== 6 || mobile.roleScopes !== 2 || mobile.roleModes !== 2 || mobile.roleContrasts !== 3 || mobile.roleLevelCards !== 4 || mobile.roleDomainCards !== 4 || mobile.roleDepthCells !== 24) failures.push("移动端导航或实验异常");
if (!mobile.menuVisible || mobile.menuOpen !== "true" || mobile.tabs !== 4 || mobile.artifactTabs !== 13 || mobile.artifactHeatCells !== 64 || mobile.corpusCohorts !== 3 || mobile.lengthDeltaCards !== 4 || mobile.templateLayers !== 6 || mobile.templateScopes !== 2 || mobile.templateModes !== 2 || mobile.templateDomainCards !== 4 || mobile.templateDepthCells !== 24 || mobile.historyLayers !== 6 || mobile.historyScopes !== 2 || mobile.historyModes !== 2 || mobile.historyEffects !== 3 || mobile.historyDomainCards !== 4 || mobile.historyDepthCells !== 24 || mobile.distanceLayers !== 6 || mobile.distanceScopes !== 2 || mobile.distanceModes !== 2 || mobile.distanceContrasts !== 2 || mobile.distanceDomainCards !== 4 || mobile.distanceDepthCells !== 24 || mobile.boundaryLayers !== 6 || mobile.boundaryScopes !== 2 || mobile.boundaryModes !== 2 || mobile.boundaryContrasts !== 3 || mobile.boundaryTokenCards !== 4 || mobile.boundaryDomainCards !== 4 || mobile.boundaryDepthCells !== 24 || mobile.roleLayers !== 6 || mobile.roleScopes !== 2 || mobile.roleModes !== 2 || mobile.roleContrasts !== 3 || mobile.roleLevelCards !== 4 || mobile.roleDomainCards !== 4 || mobile.roleDepthCells !== 24 || mobile.specialLayers !== 6 || mobile.specialScopes !== 2 || mobile.specialModes !== 2 || mobile.specialContrasts !== 4 || mobile.specialTokenCards !== 4 || mobile.specialDomainCards !== 4 || mobile.specialDepthCells !== 24 || mobile.roleBlockLayers !== 6 || mobile.roleBlockScopes !== 2 || mobile.roleBlockModes !== 2 || mobile.roleBlockEffects !== 3 || mobile.roleBlockMatrixCards !== 4 || mobile.roleBlockDomainCards !== 4 || mobile.roleBlockDepthCells !== 24) failures.push("移动端导航或实验异常");
if (mobile.offenders.length) failures.push(`移动端越界元素:${JSON.stringify(mobile.offenders)}`);
if (exceptions.length) failures.push(`浏览器异常:${exceptions.join(" | ")}`);