chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,166 @@
|
||||
#include "ds4_gpu.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
static double monotonic_seconds(void) {
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
return (double)ts.tv_sec + (double)ts.tv_nsec / 1000000000.0;
|
||||
}
|
||||
|
||||
static double getenv_seconds(const char *name, double fallback) {
|
||||
const char *s = getenv(name);
|
||||
if (!s || !s[0]) return fallback;
|
||||
char *end = NULL;
|
||||
const double v = strtod(s, &end);
|
||||
return end != s && v > 0.0 ? v : fallback;
|
||||
}
|
||||
|
||||
static int check_large_topk(void) {
|
||||
const uint32_t n_comp = 32768;
|
||||
const uint32_t n_tokens = 32;
|
||||
const uint32_t top_k = 512;
|
||||
const uint64_t score_count = (uint64_t)n_comp * n_tokens;
|
||||
float *scores_host = (float *)malloc((size_t)score_count * sizeof(float));
|
||||
uint32_t *selected_host = (uint32_t *)malloc((size_t)n_tokens * top_k * sizeof(uint32_t));
|
||||
if (!scores_host || !selected_host) return 1;
|
||||
|
||||
for (uint32_t t = 0; t < n_tokens; t++) {
|
||||
for (uint32_t i = 0; i < n_comp; i++) {
|
||||
scores_host[(uint64_t)t * n_comp + i] = (float)i;
|
||||
}
|
||||
}
|
||||
|
||||
ds4_gpu_tensor *scores = ds4_gpu_tensor_alloc(score_count * sizeof(float));
|
||||
ds4_gpu_tensor *selected = ds4_gpu_tensor_alloc((uint64_t)n_tokens * top_k * sizeof(uint32_t));
|
||||
int rc = 1;
|
||||
double elapsed = 0.0;
|
||||
if (scores && selected &&
|
||||
ds4_gpu_tensor_write(scores, 0, scores_host, score_count * sizeof(float))) {
|
||||
/* Exclude one-time CUDA module/kernel setup from the throughput guard. */
|
||||
if (!ds4_gpu_indexer_topk_tensor(selected, scores, n_comp, n_tokens, top_k) ||
|
||||
!ds4_gpu_synchronize()) {
|
||||
rc = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
const double t0 = monotonic_seconds();
|
||||
if (ds4_gpu_indexer_topk_tensor(selected, scores, n_comp, n_tokens, top_k) &&
|
||||
ds4_gpu_synchronize()) {
|
||||
elapsed = monotonic_seconds() - t0;
|
||||
rc = ds4_gpu_tensor_read(selected, 0, selected_host,
|
||||
(uint64_t)n_tokens * top_k * sizeof(uint32_t)) ? 0 : 1;
|
||||
}
|
||||
}
|
||||
if (rc == 0) {
|
||||
for (uint32_t t = 0; t < n_tokens && rc == 0; t++) {
|
||||
for (uint32_t i = 0; i < top_k; i++) {
|
||||
const uint32_t expected = n_comp - 1u - i;
|
||||
const uint32_t got = selected_host[(uint64_t)t * top_k + i];
|
||||
if (got != expected) {
|
||||
fprintf(stderr, "top-k mismatch token=%u rank=%u got=%u expected=%u\n",
|
||||
t, i, got, expected);
|
||||
rc = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rc == 0) {
|
||||
const double max_seconds = getenv_seconds("DS4_CUDA_TOPK_REGRESSION_SEC", 2.0);
|
||||
fprintf(stderr, "cuda-regression: top-k n_comp=%u n_tokens=%u elapsed=%.3fs\n",
|
||||
n_comp, n_tokens, elapsed);
|
||||
if (elapsed > max_seconds) {
|
||||
fprintf(stderr, "top-k regression: %.3fs exceeds %.3fs\n", elapsed, max_seconds);
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
ds4_gpu_tensor_free(selected);
|
||||
ds4_gpu_tensor_free(scores);
|
||||
free(selected_host);
|
||||
free(scores_host);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int check_decode_attention_overflow_path(void) {
|
||||
const uint32_t n_head = 8;
|
||||
const uint32_t head_dim = 512;
|
||||
const uint32_t n_raw = 128;
|
||||
const uint32_t n_comp = 8100;
|
||||
const uint64_t q_count = (uint64_t)n_head * head_dim;
|
||||
const uint64_t raw_count = (uint64_t)n_raw * head_dim;
|
||||
const uint64_t comp_count = (uint64_t)n_comp * head_dim;
|
||||
|
||||
float *sinks = (float *)calloc(n_head, sizeof(float));
|
||||
float *q_host = (float *)calloc((size_t)q_count, sizeof(float));
|
||||
float *raw_host = (float *)calloc((size_t)raw_count, sizeof(float));
|
||||
float *comp_host = (float *)calloc((size_t)comp_count, sizeof(float));
|
||||
float *heads_host = (float *)calloc((size_t)q_count, sizeof(float));
|
||||
if (!sinks || !q_host || !raw_host || !comp_host || !heads_host) return 1;
|
||||
|
||||
for (uint32_t c = 0; c < n_comp; c++) {
|
||||
comp_host[(uint64_t)c * head_dim] = 1.0f;
|
||||
}
|
||||
|
||||
ds4_gpu_tensor *heads = ds4_gpu_tensor_alloc(q_count * sizeof(float));
|
||||
ds4_gpu_tensor *q = ds4_gpu_tensor_alloc(q_count * sizeof(float));
|
||||
ds4_gpu_tensor *raw = ds4_gpu_tensor_alloc(raw_count * sizeof(float));
|
||||
ds4_gpu_tensor *comp = ds4_gpu_tensor_alloc(comp_count * sizeof(float));
|
||||
int rc = 1;
|
||||
if (heads && q && raw && comp &&
|
||||
ds4_gpu_tensor_write(q, 0, q_host, q_count * sizeof(float)) &&
|
||||
ds4_gpu_tensor_write(raw, 0, raw_host, raw_count * sizeof(float)) &&
|
||||
ds4_gpu_tensor_write(comp, 0, comp_host, comp_count * sizeof(float)) &&
|
||||
ds4_gpu_attention_decode_heads_tensor(heads,
|
||||
sinks,
|
||||
n_head * sizeof(float),
|
||||
0,
|
||||
q,
|
||||
raw,
|
||||
n_raw,
|
||||
n_raw,
|
||||
0,
|
||||
comp,
|
||||
0,
|
||||
n_comp,
|
||||
NULL,
|
||||
0,
|
||||
n_head,
|
||||
head_dim) &&
|
||||
ds4_gpu_synchronize() &&
|
||||
ds4_gpu_tensor_read(heads, 0, heads_host, q_count * sizeof(float))) {
|
||||
rc = 0;
|
||||
for (uint32_t h = 0; h < n_head; h++) {
|
||||
const float v = heads_host[(uint64_t)h * head_dim];
|
||||
if (v < 0.90f) {
|
||||
fprintf(stderr, "attention fallback ignored compressed rows for head=%u value=%f\n",
|
||||
h, (double)v);
|
||||
rc = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ds4_gpu_tensor_free(comp);
|
||||
ds4_gpu_tensor_free(raw);
|
||||
ds4_gpu_tensor_free(q);
|
||||
ds4_gpu_tensor_free(heads);
|
||||
free(heads_host);
|
||||
free(comp_host);
|
||||
free(raw_host);
|
||||
free(q_host);
|
||||
free(sinks);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
if (!ds4_gpu_init()) return 1;
|
||||
int rc = check_large_topk();
|
||||
if (check_decode_attention_overflow_path() != 0) rc = 1;
|
||||
ds4_gpu_cleanup();
|
||||
if (rc == 0) puts("cuda long-context regression: OK");
|
||||
return rc;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#define DS4_AGENT_TEST
|
||||
#define DS4_AGENT_TEST_NO_MAIN
|
||||
#include "../ds4_agent.c"
|
||||
|
||||
int main(void) {
|
||||
ds4_agent_unit_tests_run();
|
||||
if (agent_test_failures) {
|
||||
fprintf(stderr, "ds4-agent tests: %d failure(s)\n",
|
||||
agent_test_failures);
|
||||
return 1;
|
||||
}
|
||||
puts("ds4-agent tests: ok");
|
||||
return 0;
|
||||
}
|
||||
+2308
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,196 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate the long-context fact-recall prompt used by ds4_test.
|
||||
|
||||
The fixture is intentionally prose instead of a synthetic table. The model has
|
||||
to retrieve person -> number assignments scattered through a long story, convert
|
||||
the spelled-out numbers to digits, and emit a parseable list.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import random
|
||||
from pathlib import Path
|
||||
|
||||
BOS = "<|begin▁of▁sentence|>"
|
||||
USER = "<|User|>"
|
||||
ASSISTANT = "<|Assistant|>"
|
||||
|
||||
FACTS = [
|
||||
("Bob", "thirty-four", 34),
|
||||
("Alice", "fifty-two", 52),
|
||||
("Clara", "seventy-one", 71),
|
||||
("Diego", "ninety-three", 93),
|
||||
("Elena", "sixteen", 16),
|
||||
("Felix", "eighty-eight", 88),
|
||||
("Greta", "forty-seven", 47),
|
||||
("Hugo", "twenty-nine", 29),
|
||||
("Iris", "sixty-four", 64),
|
||||
("Jonas", "twelve", 12),
|
||||
("Kira", "eighty-one", 81),
|
||||
("Leo", "thirty-nine", 39),
|
||||
("Marta", "seventy-six", 76),
|
||||
("Nadia", "twenty-three", 23),
|
||||
("Owen", "fifty-eight", 58),
|
||||
("Priya", "ninety-seven", 97),
|
||||
]
|
||||
|
||||
OPENING = """\
|
||||
You are reading a long story from the harbor town of Bellwether. The story is
|
||||
ordinary on purpose: people speak, walk, remember, repair things, argue about
|
||||
weather, and sometimes receive a private assignment number written out in
|
||||
words. Your job at the end is to recover the assignment numbers.
|
||||
|
||||
Important rule while reading: only assignments stated as "was assigned the
|
||||
number ..." count. Other ages, prices, dates, distances, room numbers, rumors,
|
||||
or guesses do not count. The assignment numbers in the story are written in
|
||||
words, not numerals.
|
||||
|
||||
"""
|
||||
|
||||
SCENE_TEMPLATES = [
|
||||
"""\
|
||||
At first light the harbor smelled of rope, rain, and cedar smoke. {lead} crossed
|
||||
the quay with a folded map tucked under one arm, stopping whenever gulls made a
|
||||
mess of the chalk marks near the fish stalls. {friend} had promised to fix the
|
||||
south gate before supper, but the hinges complained so loudly that everyone
|
||||
pretended not to hear them. In the bakery window, loaves cooled beneath linen
|
||||
while a child counted shells in a wooden bowl. No one was in a hurry, because
|
||||
Bellwether moved by tide and habit, not by the bells on the council tower.
|
||||
|
||||
The archivist Mara wrote notes in brown ink, never black, because black ink made
|
||||
old ledgers look like court summonses. She watched {lead} and {friend} pass the
|
||||
fountain, then added a line about the morning fog. Her notes often wandered into
|
||||
small details: the color of a scarf, the chipped rim of a cup, the way a door
|
||||
kept opening after it had been firmly shut.
|
||||
""",
|
||||
"""\
|
||||
By noon the market had filled with baskets of pears, lamp oil, brass hooks, and
|
||||
paper flowers. {lead} bargained for twine while {friend} listened to a sailor
|
||||
describe a storm that seemed to grow taller every time he retold it. The town
|
||||
clock had stopped again, but nobody agreed on when, so every shopkeeper chose a
|
||||
different hour and defended it with confidence.
|
||||
|
||||
Mara sat outside the apothecary and copied the day's ordinary business into the
|
||||
festival ledger. She liked ordinary business best. Extraordinary business came
|
||||
with signatures, seals, and people who leaned over her shoulder. Ordinary
|
||||
business arrived quietly, sat down, and became history before anyone noticed.
|
||||
""",
|
||||
"""\
|
||||
In the afternoon, a rehearsal for the midsummer play blocked the west road.
|
||||
{lead} carried a crate of lantern glass through the crowd while {friend} read
|
||||
lines from a damp script. Someone had painted the moon too blue on the backdrop,
|
||||
and three people argued about whether a theatrical moon was allowed to be wrong.
|
||||
The argument lasted longer than the scene.
|
||||
|
||||
The ledger lay open on a bench. Mara kept it weighted with two smooth stones
|
||||
from the beach. She recorded who borrowed the theater ladder, who returned the
|
||||
wrong kettle, and who claimed the missing red umbrella. The handwriting was calm
|
||||
even when the town was not.
|
||||
""",
|
||||
"""\
|
||||
Evening brought a quiet wind and the sound of shutters being latched one after
|
||||
another. {lead} helped carry chairs into the assembly hall, where the floor had
|
||||
been scrubbed until it smelled faintly of salt. {friend} found a lost button
|
||||
near the door and pinned it to the notice board with a note that said, simply,
|
||||
"lonely."
|
||||
|
||||
Mara walked the perimeter of the hall with the ledger pressed to her chest. She
|
||||
had learned that important facts hid best inside unimportant days. A missing
|
||||
button, a changed route, a corrected name, a number assigned without ceremony:
|
||||
these were the things that later made sense of everything else.
|
||||
""",
|
||||
"""\
|
||||
Rain arrived after midnight and softened every sound in Bellwether. {lead}
|
||||
stood beneath the awning of the rope-maker's shop, waiting for {friend}, who had
|
||||
gone back for a forgotten satchel. The street lamps shone in puddles like coins
|
||||
that nobody could spend. From the hill, the lighthouse blinked with patient
|
||||
regularity.
|
||||
|
||||
Mara remained awake in the archive room. She sharpened a pencil, rejected it,
|
||||
and returned to brown ink. The festival ledger had grown heavy with the week:
|
||||
weather notes, repairs, errands, apologies, and a few facts she underlined only
|
||||
once so they would not look too important.
|
||||
""",
|
||||
]
|
||||
|
||||
BRIDGE_SENTENCES = [
|
||||
"The town talked around the matter without naming it directly.",
|
||||
"A kettle whistled somewhere nearby and broke the silence at exactly the right moment.",
|
||||
"Mara did not decorate the sentence; she wanted it to be easy to find later.",
|
||||
"The phrase was spoken once, then folded into the rest of the day's business.",
|
||||
"No one treated the entry like a puzzle, which is why it survived unchanged.",
|
||||
"The ledger page smelled of dust, salt, and the faint sweetness of drying glue.",
|
||||
]
|
||||
|
||||
|
||||
def assignment_sentence(name: str, word: str) -> str:
|
||||
return (
|
||||
f"During that same scene, {name} was assigned the number {word}. "
|
||||
f"Mara wrote the assignment in words, closed the ledger for a moment, "
|
||||
f"and then returned to the smaller gossip of the harbor."
|
||||
)
|
||||
|
||||
|
||||
def make_story() -> str:
|
||||
rng = random.Random(20260513)
|
||||
names = [name for name, _, _ in FACTS]
|
||||
fact_by_scene = {7 + i * 11: fact for i, fact in enumerate(FACTS)}
|
||||
scenes: list[str] = []
|
||||
|
||||
for scene_index in range(190):
|
||||
lead = rng.choice(names)
|
||||
friend = rng.choice([n for n in names if n != lead])
|
||||
template = SCENE_TEMPLATES[scene_index % len(SCENE_TEMPLATES)]
|
||||
scene = template.format(lead=lead, friend=friend)
|
||||
|
||||
if scene_index in fact_by_scene:
|
||||
name, word, _ = fact_by_scene[scene_index]
|
||||
scene += "\n" + rng.choice(BRIDGE_SENTENCES) + " " + assignment_sentence(name, word) + "\n"
|
||||
elif scene_index % 9 == 3:
|
||||
scene += (
|
||||
"\nMara heard someone mention an old rumor about a numbered key, "
|
||||
"but she crossed it out because it was not an assignment and did "
|
||||
"not belong in the final list.\n"
|
||||
)
|
||||
elif scene_index % 11 == 6:
|
||||
scene += (
|
||||
"\nA shop sign advertised a discount in careful words, but prices "
|
||||
"and discounts were not assignment numbers, so Mara ignored them.\n"
|
||||
)
|
||||
|
||||
scenes.append(scene)
|
||||
|
||||
final_names = ", ".join(name for name, _, _ in FACTS)
|
||||
expected_hint = "Bob=34"
|
||||
question = f"""\
|
||||
|
||||
Final task:
|
||||
|
||||
Compile the assignment ledger from the story. Convert the spelled-out numbers to
|
||||
ordinary decimal numerals. Write only lines in the form Name=number. The first
|
||||
example line is {expected_hint}; include that line and all remaining people.
|
||||
|
||||
People to list: {final_names}.
|
||||
|
||||
No bullets, no prose, no explanation.
|
||||
"""
|
||||
return OPENING + "\n".join(scenes) + question
|
||||
|
||||
|
||||
def main() -> None:
|
||||
root = Path(__file__).resolve().parent
|
||||
story = make_story()
|
||||
rendered = (
|
||||
BOS
|
||||
+ "You are a careful assistant. Read the story, remember the assignments, "
|
||||
+ "and answer the final task exactly."
|
||||
+ USER
|
||||
+ story
|
||||
+ ASSISTANT
|
||||
+ "</think>"
|
||||
)
|
||||
(root / "long_context_story_prompt.txt").write_text(rendered, encoding="utf-8")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,64 @@
|
||||
# DeepSeek V4 Flash Test Vectors
|
||||
|
||||
These vectors were captured from the official DeepSeek V4 Flash API using
|
||||
`deepseek-v4-flash`, greedy decoding, thinking disabled, and
|
||||
`top_logprobs=20`. The hosted API does not expose full logits, so these files
|
||||
store the best logprob slice the API provides.
|
||||
|
||||
Files:
|
||||
|
||||
- `prompts/*.txt`: exact user prompts.
|
||||
- `official/*.official.json`: official API continuations and top-logprobs.
|
||||
- `official.vec`: compact C-test fixture generated from the official JSON.
|
||||
- `local-golden.vec`: local top-k/logit fixture captured from a known-sane DS4
|
||||
Flash run. It is used to catch substantial backend drift that can keep the
|
||||
same greedy token while damaging the logits distribution.
|
||||
|
||||
Regenerate official vectors:
|
||||
|
||||
```sh
|
||||
DEEPSEEK_API_KEY=... ./tests/test-vectors/fetch_official_vectors.py
|
||||
```
|
||||
|
||||
Running the fetcher without `--only` also regenerates `official.vec`.
|
||||
|
||||
The C runner consumes `official.vec` directly:
|
||||
|
||||
```sh
|
||||
./ds4_test --logprob-vectors
|
||||
```
|
||||
|
||||
It also consumes the local golden fixture:
|
||||
|
||||
```sh
|
||||
./ds4_test --local-golden-vectors
|
||||
```
|
||||
|
||||
The Metal SSD-streaming cache-pressure repro for issue #384 is a focused
|
||||
variant of the official-vector check. It forces a 16GiB routed-expert cache and
|
||||
runs only the `short_code_completion` case that exposes wrong logits when
|
||||
layer-batched decode reuses expert-cache buffers before the command buffer has
|
||||
completed:
|
||||
|
||||
```sh
|
||||
DS4_TEST_MODEL=gguf/DeepSeek-V4-Flash-IQ2XXS-w2Q2K-AProjQ8-SExpQ8-OutQ8-chat-v2-imatrix.gguf \
|
||||
./ds4_test --metal-ssd-streaming-cache-pressure
|
||||
```
|
||||
|
||||
The runner opens the normal non-quality path with accelerator-specific fast
|
||||
routes disabled and pins `DS4_METAL_PREFILL_CHUNK=2048` for this strict
|
||||
official-vector check.
|
||||
|
||||
`official.vec` is intentionally trivial to parse from C: each case points to a
|
||||
prompt file and each expected token is hex-encoded by bytes. The official JSON
|
||||
files remain in the tree so the compact fixture can be audited against the raw
|
||||
API response.
|
||||
|
||||
To inspect a local top-logprob dump manually:
|
||||
|
||||
```sh
|
||||
./ds4 --metal --nothink -sys "" --temp 0 -n 4 --ctx 16384 \
|
||||
--prompt-file tests/test-vectors/prompts/long_code_audit.txt \
|
||||
--dump-logprobs /tmp/long_code_audit.ds4.json \
|
||||
--logprobs-top-k 20
|
||||
```
|
||||
Executable
+277
@@ -0,0 +1,277 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Fetch small DeepSeek V4 Flash logprob vectors from the official API.
|
||||
|
||||
The API exposes top-logprobs, not full logits. These vectors are therefore
|
||||
golden continuation slices: useful for catching tokenizer/template/attention
|
||||
regressions, but not a replacement for a full internal logit dump.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
MODEL = "deepseek-v4-flash"
|
||||
ENDPOINT = "https://api.deepseek.com/chat/completions"
|
||||
TOP_LOGPROBS = 20
|
||||
MAX_TOKENS = 4
|
||||
CTX_BY_ID = {
|
||||
"short_italian_fact": 16384,
|
||||
"short_code_completion": 4096,
|
||||
"short_reasoning_plain": 4096,
|
||||
"long_memory_archive": 16384,
|
||||
"long_code_audit": 16384,
|
||||
}
|
||||
|
||||
|
||||
def long_memory_prompt() -> str:
|
||||
block = (
|
||||
"Record {i:03d}: the archive entry says that component alpha keeps a "
|
||||
"compressed index, component beta keeps raw observations, and component "
|
||||
"gamma reports anomalies only after the checksum phrase appears. "
|
||||
"Do not summarize yet; retain the exact final question.\n"
|
||||
)
|
||||
body = "".join(block.format(i=i) for i in range(72))
|
||||
return (
|
||||
"You are checking a long technical archive. Read the repeated records "
|
||||
"and answer only the final question with one short sentence.\n\n"
|
||||
+ body
|
||||
+ "\nFinal question: which component reports anomalies after the checksum phrase appears?"
|
||||
)
|
||||
|
||||
|
||||
def long_code_prompt() -> str:
|
||||
stanza = (
|
||||
"Function f_{i} validates a queue entry, calls normalize_path(), then "
|
||||
"appends a compact audit line. The invariant is that strlen() must not "
|
||||
"be recomputed when a trusted length returned by snprintf() is already "
|
||||
"available. Security note {i}: reject negative sizes before casting.\n"
|
||||
)
|
||||
body = "".join(stanza.format(i=i) for i in range(68))
|
||||
return (
|
||||
"Review this generated C-code audit log. After the log, complete the "
|
||||
"sentence with the most likely next words.\n\n"
|
||||
+ body
|
||||
+ "\nCompletion target: The most important code quality issue is"
|
||||
)
|
||||
|
||||
|
||||
PROMPTS = [
|
||||
{
|
||||
"id": "short_italian_fact",
|
||||
"kind": "short",
|
||||
"prompt": "Rispondi in italiano con una frase: chi era Ada Lovelace?",
|
||||
},
|
||||
{
|
||||
"id": "short_code_completion",
|
||||
"kind": "short",
|
||||
"prompt": "Complete the C statement with the next exact token only:\nreturn snprintf(buf, sizeof(buf), \"%d\", value",
|
||||
},
|
||||
{
|
||||
"id": "short_reasoning_plain",
|
||||
"kind": "short",
|
||||
"prompt": "Answer with only the number: 2048 divided by 128 is",
|
||||
},
|
||||
{
|
||||
"id": "long_memory_archive",
|
||||
"kind": "long",
|
||||
"prompt": long_memory_prompt(),
|
||||
},
|
||||
{
|
||||
"id": "long_code_audit",
|
||||
"kind": "long",
|
||||
"prompt": long_code_prompt(),
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def token_bytes(token: str, value) -> list[int]:
|
||||
if isinstance(value, list):
|
||||
return [int(x) for x in value]
|
||||
return list(token.encode("utf-8"))
|
||||
|
||||
|
||||
def request_vector(api_key: str, prompt: str) -> dict:
|
||||
payload = {
|
||||
"model": MODEL,
|
||||
"messages": [{"role": "user", "content": prompt}],
|
||||
"temperature": 0,
|
||||
"max_tokens": MAX_TOKENS,
|
||||
"logprobs": True,
|
||||
"top_logprobs": TOP_LOGPROBS,
|
||||
"thinking": {"type": "disabled"},
|
||||
"stream": False,
|
||||
}
|
||||
req = urllib.request.Request(
|
||||
ENDPOINT,
|
||||
data=json.dumps(payload).encode("utf-8"),
|
||||
headers={
|
||||
"Authorization": f"Bearer {api_key}",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
method="POST",
|
||||
)
|
||||
try:
|
||||
with urllib.request.urlopen(req, timeout=120) as fp:
|
||||
return json.loads(fp.read().decode("utf-8"))
|
||||
except urllib.error.HTTPError as e:
|
||||
body = e.read().decode("utf-8", "replace")
|
||||
raise RuntimeError(f"DeepSeek API HTTP {e.code}: {body}") from e
|
||||
|
||||
|
||||
def normalize_record(prompt_spec: dict, response: dict) -> dict:
|
||||
choice = response["choices"][0]
|
||||
logprob_items = choice.get("logprobs", {}).get("content", []) or []
|
||||
steps = []
|
||||
for step, item in enumerate(logprob_items):
|
||||
top = []
|
||||
for alt in item.get("top_logprobs", []) or []:
|
||||
tok = alt.get("token", "")
|
||||
top.append(
|
||||
{
|
||||
"token": {
|
||||
"text": tok,
|
||||
"bytes": token_bytes(tok, alt.get("bytes")),
|
||||
},
|
||||
"logprob": alt.get("logprob"),
|
||||
}
|
||||
)
|
||||
tok = item.get("token", "")
|
||||
steps.append(
|
||||
{
|
||||
"step": step,
|
||||
"token": {
|
||||
"text": tok,
|
||||
"bytes": token_bytes(tok, item.get("bytes")),
|
||||
},
|
||||
"logprob": item.get("logprob"),
|
||||
"top_logprobs": top,
|
||||
}
|
||||
)
|
||||
|
||||
return {
|
||||
"schema": "ds4-official-logprobs-v1",
|
||||
"source": "deepseek-official-api",
|
||||
"model": MODEL,
|
||||
"endpoint": ENDPOINT,
|
||||
"created_at": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
|
||||
"id": prompt_spec["id"],
|
||||
"kind": prompt_spec["kind"],
|
||||
"prompt": prompt_spec["prompt"],
|
||||
"request": {
|
||||
"model": MODEL,
|
||||
"temperature": 0,
|
||||
"max_tokens": MAX_TOKENS,
|
||||
"logprobs": True,
|
||||
"top_logprobs": TOP_LOGPROBS,
|
||||
"thinking": {"type": "disabled"},
|
||||
"messages": [{"role": "user", "content": prompt_spec["prompt"]}],
|
||||
},
|
||||
"usage": response.get("usage"),
|
||||
"finish_reason": choice.get("finish_reason"),
|
||||
"message": choice.get("message", {}),
|
||||
"logits_available": False,
|
||||
"steps": steps,
|
||||
}
|
||||
|
||||
|
||||
def hex_bytes(values: list[int]) -> str:
|
||||
return "".join(f"{int(x):02x}" for x in values)
|
||||
|
||||
|
||||
def write_compact_fixture(root: Path, manifest: dict) -> None:
|
||||
lines = [
|
||||
"# ds4-official-logprob-vectors-v1",
|
||||
"# case <id> <ctx> <steps> <prompt-file>",
|
||||
"# step <index> <selected-hex> <top-count>",
|
||||
"# top <token-hex> <official-logprob>",
|
||||
"",
|
||||
]
|
||||
for prompt in manifest["prompts"]:
|
||||
vector_id = prompt["id"]
|
||||
record = json.loads((root / prompt["official_file"]).read_text(encoding="utf-8"))
|
||||
steps = record["steps"]
|
||||
prompt_file = root / prompt["prompt_file"]
|
||||
lines.append(f"case {vector_id} {CTX_BY_ID[vector_id]} {len(steps)} {prompt_file}")
|
||||
for i, step in enumerate(steps):
|
||||
top = []
|
||||
for alt in step.get("top_logprobs", []):
|
||||
lp = float(alt.get("logprob", -9999))
|
||||
if lp <= -1000:
|
||||
continue
|
||||
token_hex = hex_bytes(alt["token"]["bytes"])
|
||||
if token_hex:
|
||||
top.append((token_hex, lp))
|
||||
lines.append(f"step {i} {hex_bytes(step['token']['bytes'])} {len(top)}")
|
||||
for token_hex, lp in top:
|
||||
lines.append(f"top {token_hex} {lp:.9g}")
|
||||
lines.append("end")
|
||||
lines.append("")
|
||||
(root / "official.vec").write_text("\n".join(lines), encoding="ascii")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--out", default="tests/test-vectors", help="output directory")
|
||||
parser.add_argument("--only", action="append", help="fetch only the named prompt id")
|
||||
args = parser.parse_args()
|
||||
|
||||
api_key = os.environ.get("DEEPSEEK_API_KEY")
|
||||
if not api_key:
|
||||
print("DEEPSEEK_API_KEY is required", file=sys.stderr)
|
||||
return 2
|
||||
|
||||
root = Path(args.out)
|
||||
prompt_dir = root / "prompts"
|
||||
official_dir = root / "official"
|
||||
prompt_dir.mkdir(parents=True, exist_ok=True)
|
||||
official_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
wanted = set(args.only or [])
|
||||
manifest = {
|
||||
"schema": "ds4-test-vector-manifest-v1",
|
||||
"source": "deepseek-official-api",
|
||||
"model": MODEL,
|
||||
"endpoint": ENDPOINT,
|
||||
"top_logprobs": TOP_LOGPROBS,
|
||||
"max_tokens": MAX_TOKENS,
|
||||
"prompts": [],
|
||||
}
|
||||
|
||||
for spec in PROMPTS:
|
||||
if wanted and spec["id"] not in wanted:
|
||||
continue
|
||||
prompt_path = prompt_dir / f"{spec['id']}.txt"
|
||||
prompt_path.write_text(spec["prompt"], encoding="utf-8")
|
||||
|
||||
response = request_vector(api_key, spec["prompt"])
|
||||
record = normalize_record(spec, response)
|
||||
out_path = official_dir / f"{spec['id']}.official.json"
|
||||
out_path.write_text(json.dumps(record, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
|
||||
manifest["prompts"].append(
|
||||
{
|
||||
"id": spec["id"],
|
||||
"kind": spec["kind"],
|
||||
"prompt_file": str(prompt_path.relative_to(root)),
|
||||
"official_file": str(out_path.relative_to(root)),
|
||||
"prompt_chars": len(spec["prompt"]),
|
||||
"steps": len(record["steps"]),
|
||||
}
|
||||
)
|
||||
print(f"wrote {out_path}")
|
||||
|
||||
(root / "manifest.json").write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8")
|
||||
if not wanted:
|
||||
write_compact_fixture(root, manifest)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -0,0 +1,70 @@
|
||||
# ds4-local-golden-v1
|
||||
# Generated from a known-sane local Metal Flash run.
|
||||
# case <id> <mode> <ctx> <frontier> <prompt-file> <top-count>
|
||||
# top <rank> <token-id> <logit>
|
||||
case long_story_4096 text 5000 4096 tests/long_context_story_prompt.txt 64
|
||||
top 0 4371 36.5096703
|
||||
top 1 523 18.6111526
|
||||
top 2 3195 18.5823841
|
||||
top 3 1181 16.966589
|
||||
top 4 284 16.6814995
|
||||
top 5 2358 16.3420849
|
||||
top 6 17095 16.191246
|
||||
top 7 4124 16.1311493
|
||||
top 8 271 15.1333857
|
||||
top 9 89425 14.6275482
|
||||
top 10 201 14.584446
|
||||
top 11 19686 14.4264259
|
||||
top 12 37265 14.4157028
|
||||
top 13 15 14.2485847
|
||||
top 14 2389 13.6055794
|
||||
top 15 99571 12.89781
|
||||
top 16 1808 12.892416
|
||||
top 17 16 12.639905
|
||||
top 18 260 12.3910465
|
||||
top 19 576 12.3076944
|
||||
top 20 6848 12.2386274
|
||||
top 21 767 12.1215076
|
||||
top 22 14 12.0363045
|
||||
top 23 3433 11.966959
|
||||
top 24 31772 11.9614077
|
||||
top 25 339 11.8386555
|
||||
top 26 10 11.7675905
|
||||
top 27 305 11.7428093
|
||||
top 28 9552 11.5920877
|
||||
top 29 1613 11.5360451
|
||||
top 30 1522 11.2983799
|
||||
top 31 3108 11.2624083
|
||||
top 32 52972 11.2255793
|
||||
top 33 7905 11.1018257
|
||||
top 34 11409 11.0852222
|
||||
top 35 20 11.0794544
|
||||
top 36 6717 11.0632544
|
||||
top 37 44025 11.0552616
|
||||
top 38 1248 10.9015293
|
||||
top 39 1640 10.8808842
|
||||
top 40 10013 10.8344564
|
||||
top 41 1 10.7051525
|
||||
top 42 12110 10.657053
|
||||
top 43 4378 10.6250381
|
||||
top 44 690 10.5749454
|
||||
top 45 13920 10.554635
|
||||
top 46 1311 10.528142
|
||||
top 47 27002 10.5103617
|
||||
top 48 19 10.5007963
|
||||
top 49 4341 10.4806595
|
||||
top 50 29 10.4164429
|
||||
top 51 39 10.3944435
|
||||
top 52 21998 10.2973881
|
||||
top 53 5013 10.2796888
|
||||
top 54 9128 10.2171707
|
||||
top 55 23426 10.2086124
|
||||
top 56 74368 10.1682949
|
||||
top 57 223 10.1407642
|
||||
top 58 30 10.1099615
|
||||
top 59 1462 10.0838194
|
||||
top 60 32040 10.0451183
|
||||
top 61 68945 9.98346901
|
||||
top 62 1381 9.96955109
|
||||
top 63 59485 9.95218468
|
||||
end
|
||||
@@ -0,0 +1,50 @@
|
||||
{
|
||||
"schema": "ds4-test-vector-manifest-v1",
|
||||
"source": "deepseek-official-api",
|
||||
"model": "deepseek-v4-flash",
|
||||
"endpoint": "https://api.deepseek.com/chat/completions",
|
||||
"top_logprobs": 20,
|
||||
"max_tokens": 4,
|
||||
"prompts": [
|
||||
{
|
||||
"id": "short_italian_fact",
|
||||
"kind": "short",
|
||||
"prompt_file": "prompts/short_italian_fact.txt",
|
||||
"official_file": "official/short_italian_fact.official.json",
|
||||
"prompt_chars": 57,
|
||||
"steps": 4
|
||||
},
|
||||
{
|
||||
"id": "short_code_completion",
|
||||
"kind": "short",
|
||||
"prompt_file": "prompts/short_code_completion.txt",
|
||||
"official_file": "official/short_code_completion.official.json",
|
||||
"prompt_chars": 102,
|
||||
"steps": 4
|
||||
},
|
||||
{
|
||||
"id": "short_reasoning_plain",
|
||||
"kind": "short",
|
||||
"prompt_file": "prompts/short_reasoning_plain.txt",
|
||||
"official_file": "official/short_reasoning_plain.official.json",
|
||||
"prompt_chars": 51,
|
||||
"steps": 1
|
||||
},
|
||||
{
|
||||
"id": "long_memory_archive",
|
||||
"kind": "long",
|
||||
"prompt_file": "prompts/long_memory_archive.txt",
|
||||
"official_file": "official/long_memory_archive.official.json",
|
||||
"prompt_chars": 18503,
|
||||
"steps": 4
|
||||
},
|
||||
{
|
||||
"id": "long_code_audit",
|
||||
"kind": "long",
|
||||
"prompt_file": "prompts/long_code_audit.txt",
|
||||
"official_file": "official/long_code_audit.official.json",
|
||||
"prompt_chars": 18851,
|
||||
"steps": 4
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
# ds4-official-logprob-vectors-v1
|
||||
# case <id> <ctx> <steps> <prompt-file>
|
||||
# step <index> <selected-hex> <top-count>
|
||||
# top <token-hex> <official-logprob>
|
||||
|
||||
case short_italian_fact 16384 4 tests/test-vectors/prompts/short_italian_fact.txt
|
||||
step 0 416461 1
|
||||
top 416461 0
|
||||
step 1 204c6f76 1
|
||||
top 204c6f76 0
|
||||
step 2 656c 1
|
||||
top 656c 0
|
||||
step 3 616365 1
|
||||
top 616365 0
|
||||
end
|
||||
|
||||
case short_code_completion 4096 4 tests/test-vectors/prompts/short_code_completion.txt
|
||||
step 0 606060 1
|
||||
top 606060 0
|
||||
step 1 63 1
|
||||
top 63 0
|
||||
step 2 0a 1
|
||||
top 0a 0
|
||||
step 3 72657475726e 1
|
||||
top 72657475726e 0
|
||||
end
|
||||
|
||||
case short_reasoning_plain 4096 1 tests/test-vectors/prompts/short_reasoning_plain.txt
|
||||
step 0 3136 1
|
||||
top 3136 0
|
||||
end
|
||||
|
||||
case long_memory_archive 16384 4 tests/test-vectors/prompts/long_memory_archive.txt
|
||||
step 0 436f6d706f6e656e74 1
|
||||
top 436f6d706f6e656e74 0
|
||||
step 1 2067616d6d61 1
|
||||
top 2067616d6d61 0
|
||||
step 2 207265706f727473 1
|
||||
top 207265706f727473 0
|
||||
step 3 20616e6f6d616c696573 1
|
||||
top 20616e6f6d616c696573 0
|
||||
end
|
||||
|
||||
case long_code_audit 16384 4 tests/test-vectors/prompts/long_code_audit.txt
|
||||
step 0 546865 1
|
||||
top 546865 0
|
||||
step 1 206d6f7374 1
|
||||
top 206d6f7374 0
|
||||
step 2 20696d706f7274616e74 1
|
||||
top 20696d706f7274616e74 0
|
||||
step 3 20636f6465 1
|
||||
top 20636f6465 0
|
||||
end
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,982 @@
|
||||
{
|
||||
"schema": "ds4-official-logprobs-v1",
|
||||
"source": "deepseek-official-api",
|
||||
"model": "deepseek-v4-flash",
|
||||
"endpoint": "https://api.deepseek.com/chat/completions",
|
||||
"created_at": "2026-05-06T22:09:33Z",
|
||||
"id": "short_italian_fact",
|
||||
"kind": "short",
|
||||
"prompt": "Rispondi in italiano con una frase: chi era Ada Lovelace?",
|
||||
"request": {
|
||||
"model": "deepseek-v4-flash",
|
||||
"temperature": 0,
|
||||
"max_tokens": 4,
|
||||
"logprobs": true,
|
||||
"top_logprobs": 20,
|
||||
"thinking": {
|
||||
"type": "disabled"
|
||||
},
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Rispondi in italiano con una frase: chi era Ada Lovelace?"
|
||||
}
|
||||
]
|
||||
},
|
||||
"usage": {
|
||||
"prompt_tokens": 21,
|
||||
"completion_tokens": 4,
|
||||
"total_tokens": 25,
|
||||
"prompt_tokens_details": {
|
||||
"cached_tokens": 0
|
||||
},
|
||||
"prompt_cache_hit_tokens": 0,
|
||||
"prompt_cache_miss_tokens": 21
|
||||
},
|
||||
"finish_reason": "length",
|
||||
"message": {
|
||||
"role": "assistant",
|
||||
"content": "Ada Lovelace"
|
||||
},
|
||||
"logits_available": false,
|
||||
"steps": [
|
||||
{
|
||||
"step": 0,
|
||||
"token": {
|
||||
"text": "Ada",
|
||||
"bytes": [
|
||||
65,
|
||||
100,
|
||||
97
|
||||
]
|
||||
},
|
||||
"logprob": 0.0,
|
||||
"top_logprobs": [
|
||||
{
|
||||
"token": {
|
||||
"text": "Ada",
|
||||
"bytes": [
|
||||
65,
|
||||
100,
|
||||
97
|
||||
]
|
||||
},
|
||||
"logprob": 0.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "August",
|
||||
"bytes": [
|
||||
65,
|
||||
117,
|
||||
103,
|
||||
117,
|
||||
115,
|
||||
116
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "Lady",
|
||||
"bytes": [
|
||||
76,
|
||||
97,
|
||||
100,
|
||||
121
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "**",
|
||||
"bytes": [
|
||||
42,
|
||||
42
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "Una",
|
||||
"bytes": [
|
||||
85,
|
||||
110,
|
||||
97
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "La",
|
||||
"bytes": [
|
||||
76,
|
||||
97
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": " Ada",
|
||||
"bytes": [
|
||||
32,
|
||||
65,
|
||||
100,
|
||||
97
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "E",
|
||||
"bytes": [
|
||||
69
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "Consider",
|
||||
"bytes": [
|
||||
67,
|
||||
111,
|
||||
110,
|
||||
115,
|
||||
105,
|
||||
100,
|
||||
101,
|
||||
114
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "Ad",
|
||||
"bytes": [
|
||||
65,
|
||||
100
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "Chi",
|
||||
"bytes": [
|
||||
67,
|
||||
104,
|
||||
105
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "Mat",
|
||||
"bytes": [
|
||||
77,
|
||||
97,
|
||||
116
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "Fig",
|
||||
"bytes": [
|
||||
70,
|
||||
105,
|
||||
103
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "Cert",
|
||||
"bytes": [
|
||||
67,
|
||||
101,
|
||||
114,
|
||||
116
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "L",
|
||||
"bytes": [
|
||||
76
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "A",
|
||||
"bytes": [
|
||||
65
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "\"",
|
||||
"bytes": [
|
||||
34
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "Il",
|
||||
"bytes": [
|
||||
73,
|
||||
108
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "È",
|
||||
"bytes": [
|
||||
195,
|
||||
136
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "C",
|
||||
"bytes": [
|
||||
67
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 1,
|
||||
"token": {
|
||||
"text": " Lov",
|
||||
"bytes": [
|
||||
32,
|
||||
76,
|
||||
111,
|
||||
118
|
||||
]
|
||||
},
|
||||
"logprob": 0.0,
|
||||
"top_logprobs": [
|
||||
{
|
||||
"token": {
|
||||
"text": " Lov",
|
||||
"bytes": [
|
||||
32,
|
||||
76,
|
||||
111,
|
||||
118
|
||||
]
|
||||
},
|
||||
"logprob": 0.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "<||end▁of▁sentence||>",
|
||||
"bytes": [
|
||||
60,
|
||||
239,
|
||||
189,
|
||||
156,
|
||||
239,
|
||||
189,
|
||||
156,
|
||||
101,
|
||||
110,
|
||||
100,
|
||||
226,
|
||||
150,
|
||||
129,
|
||||
111,
|
||||
102,
|
||||
226,
|
||||
150,
|
||||
129,
|
||||
115,
|
||||
101,
|
||||
110,
|
||||
116,
|
||||
101,
|
||||
110,
|
||||
99,
|
||||
101,
|
||||
239,
|
||||
189,
|
||||
156,
|
||||
239,
|
||||
189,
|
||||
156,
|
||||
62
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "!",
|
||||
"bytes": [
|
||||
33
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "\"",
|
||||
"bytes": [
|
||||
34
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "#",
|
||||
"bytes": [
|
||||
35
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "%",
|
||||
"bytes": [
|
||||
37
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "&",
|
||||
"bytes": [
|
||||
38
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "'",
|
||||
"bytes": [
|
||||
39
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "(",
|
||||
"bytes": [
|
||||
40
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": ")",
|
||||
"bytes": [
|
||||
41
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "*",
|
||||
"bytes": [
|
||||
42
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "+",
|
||||
"bytes": [
|
||||
43
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": ",",
|
||||
"bytes": [
|
||||
44
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "-",
|
||||
"bytes": [
|
||||
45
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": ".",
|
||||
"bytes": [
|
||||
46
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "/",
|
||||
"bytes": [
|
||||
47
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "1",
|
||||
"bytes": [
|
||||
49
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "2",
|
||||
"bytes": [
|
||||
50
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "3",
|
||||
"bytes": [
|
||||
51
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": " &",
|
||||
"bytes": [
|
||||
32,
|
||||
38
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 2,
|
||||
"token": {
|
||||
"text": "el",
|
||||
"bytes": [
|
||||
101,
|
||||
108
|
||||
]
|
||||
},
|
||||
"logprob": 0.0,
|
||||
"top_logprobs": [
|
||||
{
|
||||
"token": {
|
||||
"text": "el",
|
||||
"bytes": [
|
||||
101,
|
||||
108
|
||||
]
|
||||
},
|
||||
"logprob": 0.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "<||end▁of▁sentence||>",
|
||||
"bytes": [
|
||||
60,
|
||||
239,
|
||||
189,
|
||||
156,
|
||||
239,
|
||||
189,
|
||||
156,
|
||||
101,
|
||||
110,
|
||||
100,
|
||||
226,
|
||||
150,
|
||||
129,
|
||||
111,
|
||||
102,
|
||||
226,
|
||||
150,
|
||||
129,
|
||||
115,
|
||||
101,
|
||||
110,
|
||||
116,
|
||||
101,
|
||||
110,
|
||||
99,
|
||||
101,
|
||||
239,
|
||||
189,
|
||||
156,
|
||||
239,
|
||||
189,
|
||||
156,
|
||||
62
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "!",
|
||||
"bytes": [
|
||||
33
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "ateg",
|
||||
"bytes": [
|
||||
97,
|
||||
116,
|
||||
101,
|
||||
103
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "\"",
|
||||
"bytes": [
|
||||
34
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "#",
|
||||
"bytes": [
|
||||
35
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "%",
|
||||
"bytes": [
|
||||
37
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "&",
|
||||
"bytes": [
|
||||
38
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "'",
|
||||
"bytes": [
|
||||
39
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "(",
|
||||
"bytes": [
|
||||
40
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "í",
|
||||
"bytes": [
|
||||
195,
|
||||
173
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "che",
|
||||
"bytes": [
|
||||
99,
|
||||
104,
|
||||
101
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "ari",
|
||||
"bytes": [
|
||||
97,
|
||||
114,
|
||||
105
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "*",
|
||||
"bytes": [
|
||||
42
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": ",",
|
||||
"bytes": [
|
||||
44
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "-",
|
||||
"bytes": [
|
||||
45
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": ".",
|
||||
"bytes": [
|
||||
46
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "/",
|
||||
"bytes": [
|
||||
47
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "0",
|
||||
"bytes": [
|
||||
48
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "1",
|
||||
"bytes": [
|
||||
49
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"step": 3,
|
||||
"token": {
|
||||
"text": "ace",
|
||||
"bytes": [
|
||||
97,
|
||||
99,
|
||||
101
|
||||
]
|
||||
},
|
||||
"logprob": 0.0,
|
||||
"top_logprobs": [
|
||||
{
|
||||
"token": {
|
||||
"text": "ace",
|
||||
"bytes": [
|
||||
97,
|
||||
99,
|
||||
101
|
||||
]
|
||||
},
|
||||
"logprob": 0.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "<||end▁of▁sentence||>",
|
||||
"bytes": [
|
||||
60,
|
||||
239,
|
||||
189,
|
||||
156,
|
||||
239,
|
||||
189,
|
||||
156,
|
||||
101,
|
||||
110,
|
||||
100,
|
||||
226,
|
||||
150,
|
||||
129,
|
||||
111,
|
||||
102,
|
||||
226,
|
||||
150,
|
||||
129,
|
||||
115,
|
||||
101,
|
||||
110,
|
||||
116,
|
||||
101,
|
||||
110,
|
||||
99,
|
||||
101,
|
||||
239,
|
||||
189,
|
||||
156,
|
||||
239,
|
||||
189,
|
||||
156,
|
||||
62
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "ateg",
|
||||
"bytes": [
|
||||
97,
|
||||
116,
|
||||
101,
|
||||
103
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "'",
|
||||
"bytes": [
|
||||
39
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "(",
|
||||
"bytes": [
|
||||
40
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "che",
|
||||
"bytes": [
|
||||
99,
|
||||
104,
|
||||
101
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "*",
|
||||
"bytes": [
|
||||
42
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": ",",
|
||||
"bytes": [
|
||||
44
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "-",
|
||||
"bytes": [
|
||||
45
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": ".",
|
||||
"bytes": [
|
||||
46
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "/",
|
||||
"bytes": [
|
||||
47
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "ike",
|
||||
"bytes": [
|
||||
105,
|
||||
107,
|
||||
101
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "ole",
|
||||
"bytes": [
|
||||
111,
|
||||
108,
|
||||
101
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "ances",
|
||||
"bytes": [
|
||||
97,
|
||||
110,
|
||||
99,
|
||||
101,
|
||||
115
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "2",
|
||||
"bytes": [
|
||||
50
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "4",
|
||||
"bytes": [
|
||||
52
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "8",
|
||||
"bytes": [
|
||||
56
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "9",
|
||||
"bytes": [
|
||||
57
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "<",
|
||||
"bytes": [
|
||||
60
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "way",
|
||||
"bytes": [
|
||||
119,
|
||||
97,
|
||||
121
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,287 @@
|
||||
{
|
||||
"schema": "ds4-official-logprobs-v1",
|
||||
"source": "deepseek-official-api",
|
||||
"model": "deepseek-v4-flash",
|
||||
"endpoint": "https://api.deepseek.com/chat/completions",
|
||||
"created_at": "2026-05-06T22:09:34Z",
|
||||
"id": "short_reasoning_plain",
|
||||
"kind": "short",
|
||||
"prompt": "Answer with only the number: 2048 divided by 128 is",
|
||||
"request": {
|
||||
"model": "deepseek-v4-flash",
|
||||
"temperature": 0,
|
||||
"max_tokens": 4,
|
||||
"logprobs": true,
|
||||
"top_logprobs": 20,
|
||||
"thinking": {
|
||||
"type": "disabled"
|
||||
},
|
||||
"messages": [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "Answer with only the number: 2048 divided by 128 is"
|
||||
}
|
||||
]
|
||||
},
|
||||
"usage": {
|
||||
"prompt_tokens": 18,
|
||||
"completion_tokens": 1,
|
||||
"total_tokens": 19,
|
||||
"prompt_tokens_details": {
|
||||
"cached_tokens": 0
|
||||
},
|
||||
"prompt_cache_hit_tokens": 0,
|
||||
"prompt_cache_miss_tokens": 18
|
||||
},
|
||||
"finish_reason": "stop",
|
||||
"message": {
|
||||
"role": "assistant",
|
||||
"content": "16"
|
||||
},
|
||||
"logits_available": false,
|
||||
"steps": [
|
||||
{
|
||||
"step": 0,
|
||||
"token": {
|
||||
"text": "16",
|
||||
"bytes": [
|
||||
49,
|
||||
54
|
||||
]
|
||||
},
|
||||
"logprob": 0.0,
|
||||
"top_logprobs": [
|
||||
{
|
||||
"token": {
|
||||
"text": "16",
|
||||
"bytes": [
|
||||
49,
|
||||
54
|
||||
]
|
||||
},
|
||||
"logprob": 0.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "204",
|
||||
"bytes": [
|
||||
50,
|
||||
48,
|
||||
52
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "<||end▁of▁sentence||>",
|
||||
"bytes": [
|
||||
60,
|
||||
239,
|
||||
189,
|
||||
156,
|
||||
239,
|
||||
189,
|
||||
156,
|
||||
101,
|
||||
110,
|
||||
100,
|
||||
226,
|
||||
150,
|
||||
129,
|
||||
111,
|
||||
102,
|
||||
226,
|
||||
150,
|
||||
129,
|
||||
115,
|
||||
101,
|
||||
110,
|
||||
116,
|
||||
101,
|
||||
110,
|
||||
99,
|
||||
101,
|
||||
239,
|
||||
189,
|
||||
156,
|
||||
239,
|
||||
189,
|
||||
156,
|
||||
62
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "To",
|
||||
"bytes": [
|
||||
84,
|
||||
111
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "15",
|
||||
"bytes": [
|
||||
49,
|
||||
53
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "Let",
|
||||
"bytes": [
|
||||
76,
|
||||
101,
|
||||
116
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "The",
|
||||
"bytes": [
|
||||
84,
|
||||
104,
|
||||
101
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "14",
|
||||
"bytes": [
|
||||
49,
|
||||
52
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "We",
|
||||
"bytes": [
|
||||
87,
|
||||
101
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "1",
|
||||
"bytes": [
|
||||
49
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "\n",
|
||||
"bytes": [
|
||||
10
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "64",
|
||||
"bytes": [
|
||||
54,
|
||||
52
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "8",
|
||||
"bytes": [
|
||||
56
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "4",
|
||||
"bytes": [
|
||||
52
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "Since",
|
||||
"bytes": [
|
||||
83,
|
||||
105,
|
||||
110,
|
||||
99,
|
||||
101
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "0",
|
||||
"bytes": [
|
||||
48
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "I",
|
||||
"bytes": [
|
||||
73
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "18",
|
||||
"bytes": [
|
||||
49,
|
||||
56
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "10",
|
||||
"bytes": [
|
||||
49,
|
||||
48
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
},
|
||||
{
|
||||
"token": {
|
||||
"text": "6",
|
||||
"bytes": [
|
||||
54
|
||||
]
|
||||
},
|
||||
"logprob": -9999.0
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
Review this generated C-code audit log. After the log, complete the sentence with the most likely next words.
|
||||
|
||||
Function f_0 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 0: reject negative sizes before casting.
|
||||
Function f_1 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 1: reject negative sizes before casting.
|
||||
Function f_2 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 2: reject negative sizes before casting.
|
||||
Function f_3 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 3: reject negative sizes before casting.
|
||||
Function f_4 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 4: reject negative sizes before casting.
|
||||
Function f_5 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 5: reject negative sizes before casting.
|
||||
Function f_6 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 6: reject negative sizes before casting.
|
||||
Function f_7 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 7: reject negative sizes before casting.
|
||||
Function f_8 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 8: reject negative sizes before casting.
|
||||
Function f_9 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 9: reject negative sizes before casting.
|
||||
Function f_10 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 10: reject negative sizes before casting.
|
||||
Function f_11 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 11: reject negative sizes before casting.
|
||||
Function f_12 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 12: reject negative sizes before casting.
|
||||
Function f_13 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 13: reject negative sizes before casting.
|
||||
Function f_14 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 14: reject negative sizes before casting.
|
||||
Function f_15 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 15: reject negative sizes before casting.
|
||||
Function f_16 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 16: reject negative sizes before casting.
|
||||
Function f_17 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 17: reject negative sizes before casting.
|
||||
Function f_18 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 18: reject negative sizes before casting.
|
||||
Function f_19 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 19: reject negative sizes before casting.
|
||||
Function f_20 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 20: reject negative sizes before casting.
|
||||
Function f_21 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 21: reject negative sizes before casting.
|
||||
Function f_22 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 22: reject negative sizes before casting.
|
||||
Function f_23 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 23: reject negative sizes before casting.
|
||||
Function f_24 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 24: reject negative sizes before casting.
|
||||
Function f_25 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 25: reject negative sizes before casting.
|
||||
Function f_26 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 26: reject negative sizes before casting.
|
||||
Function f_27 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 27: reject negative sizes before casting.
|
||||
Function f_28 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 28: reject negative sizes before casting.
|
||||
Function f_29 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 29: reject negative sizes before casting.
|
||||
Function f_30 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 30: reject negative sizes before casting.
|
||||
Function f_31 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 31: reject negative sizes before casting.
|
||||
Function f_32 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 32: reject negative sizes before casting.
|
||||
Function f_33 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 33: reject negative sizes before casting.
|
||||
Function f_34 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 34: reject negative sizes before casting.
|
||||
Function f_35 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 35: reject negative sizes before casting.
|
||||
Function f_36 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 36: reject negative sizes before casting.
|
||||
Function f_37 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 37: reject negative sizes before casting.
|
||||
Function f_38 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 38: reject negative sizes before casting.
|
||||
Function f_39 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 39: reject negative sizes before casting.
|
||||
Function f_40 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 40: reject negative sizes before casting.
|
||||
Function f_41 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 41: reject negative sizes before casting.
|
||||
Function f_42 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 42: reject negative sizes before casting.
|
||||
Function f_43 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 43: reject negative sizes before casting.
|
||||
Function f_44 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 44: reject negative sizes before casting.
|
||||
Function f_45 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 45: reject negative sizes before casting.
|
||||
Function f_46 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 46: reject negative sizes before casting.
|
||||
Function f_47 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 47: reject negative sizes before casting.
|
||||
Function f_48 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 48: reject negative sizes before casting.
|
||||
Function f_49 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 49: reject negative sizes before casting.
|
||||
Function f_50 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 50: reject negative sizes before casting.
|
||||
Function f_51 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 51: reject negative sizes before casting.
|
||||
Function f_52 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 52: reject negative sizes before casting.
|
||||
Function f_53 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 53: reject negative sizes before casting.
|
||||
Function f_54 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 54: reject negative sizes before casting.
|
||||
Function f_55 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 55: reject negative sizes before casting.
|
||||
Function f_56 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 56: reject negative sizes before casting.
|
||||
Function f_57 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 57: reject negative sizes before casting.
|
||||
Function f_58 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 58: reject negative sizes before casting.
|
||||
Function f_59 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 59: reject negative sizes before casting.
|
||||
Function f_60 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 60: reject negative sizes before casting.
|
||||
Function f_61 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 61: reject negative sizes before casting.
|
||||
Function f_62 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 62: reject negative sizes before casting.
|
||||
Function f_63 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 63: reject negative sizes before casting.
|
||||
Function f_64 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 64: reject negative sizes before casting.
|
||||
Function f_65 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 65: reject negative sizes before casting.
|
||||
Function f_66 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 66: reject negative sizes before casting.
|
||||
Function f_67 validates a queue entry, calls normalize_path(), then appends a compact audit line. The invariant is that strlen() must not be recomputed when a trusted length returned by snprintf() is already available. Security note 67: reject negative sizes before casting.
|
||||
|
||||
Completion target: The most important code quality issue is
|
||||
@@ -0,0 +1,76 @@
|
||||
You are checking a long technical archive. Read the repeated records and answer only the final question with one short sentence.
|
||||
|
||||
Record 000: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 001: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 002: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 003: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 004: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 005: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 006: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 007: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 008: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 009: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 010: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 011: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 012: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 013: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 014: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 015: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 016: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 017: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 018: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 019: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 020: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 021: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 022: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 023: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 024: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 025: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 026: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 027: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 028: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 029: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 030: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 031: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 032: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 033: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 034: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 035: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 036: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 037: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 038: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 039: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 040: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 041: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 042: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 043: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 044: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 045: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 046: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 047: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 048: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 049: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 050: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 051: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 052: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 053: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 054: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 055: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 056: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 057: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 058: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 059: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 060: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 061: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 062: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 063: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 064: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 065: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 066: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 067: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 068: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 069: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 070: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
Record 071: the archive entry says that component alpha keeps a compressed index, component beta keeps raw observations, and component gamma reports anomalies only after the checksum phrase appears. Do not summarize yet; retain the exact final question.
|
||||
|
||||
Final question: which component reports anomalies after the checksum phrase appears?
|
||||
@@ -0,0 +1,2 @@
|
||||
Complete the C statement with the next exact token only:
|
||||
return snprintf(buf, sizeof(buf), "%d", value
|
||||
@@ -0,0 +1 @@
|
||||
Rispondi in italiano con una frase: chi era Ada Lovelace?
|
||||
@@ -0,0 +1 @@
|
||||
Answer with only the number: 2048 divided by 128 is
|
||||
@@ -0,0 +1,249 @@
|
||||
/*
|
||||
* Unit test for Q4_K block layout, scale extraction, and dot product.
|
||||
* Build: cc -O2 -Wall -DDS4_NO_GPU -DDS4_Q4K_DOT_TEST_MAIN -I. -o tests/test_q4k_dot tests/test_q4k_dot.c -lm -pthread
|
||||
* Run: ./tests/test_q4k_dot
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define QK_K 256
|
||||
|
||||
typedef struct {
|
||||
uint16_t d;
|
||||
uint16_t dmin;
|
||||
uint8_t scales[12];
|
||||
uint8_t qs[QK_K / 2];
|
||||
} block_q4_K;
|
||||
|
||||
typedef struct {
|
||||
float d;
|
||||
int8_t qs[QK_K];
|
||||
int16_t bsums[QK_K / 16];
|
||||
} block_q8_K;
|
||||
|
||||
static inline float f16_to_f32(uint16_t h) {
|
||||
uint32_t sign = (h & 0x8000) << 16;
|
||||
int32_t exp = (h >> 10) & 0x1F;
|
||||
uint32_t frac = h & 0x3FF;
|
||||
if (exp == 0) return *(float *)&sign;
|
||||
if (exp == 31) return *(float *)(uint32_t[]){ sign | 0x7F800000 | (frac << 13) };
|
||||
uint32_t f = sign | ((exp + 127 - 15) << 23) | (frac << 13);
|
||||
float out;
|
||||
memcpy(&out, &f, sizeof(out));
|
||||
return out;
|
||||
}
|
||||
|
||||
static inline void q4_k_get_scale_min(int j, const uint8_t *q, uint8_t *sc, uint8_t *m) {
|
||||
if (j < 4) {
|
||||
*sc = q[j] & 63;
|
||||
*m = q[j + 4] & 63;
|
||||
} else {
|
||||
*sc = (q[j + 4] & 0xF) | ((q[j - 4] >> 6) << 4);
|
||||
*m = (q[j + 4] >> 4) | ((q[j - 0] >> 6) << 4);
|
||||
}
|
||||
}
|
||||
|
||||
/* The corrected dot product, matching ds4.c after the fix. */
|
||||
static void vec_dot_q4_K_q8_K(int n, float *s, const block_q4_K *x, const block_q8_K *y) {
|
||||
const int nb = n / QK_K;
|
||||
float sumf = 0.0f;
|
||||
|
||||
for (int i = 0; i < nb; i++) {
|
||||
const float d = y[i].d * f16_to_f32(x[i].d);
|
||||
const float dm = -y[i].d * f16_to_f32(x[i].dmin);
|
||||
|
||||
const uint8_t *qs = x[i].qs;
|
||||
const uint8_t *sc = x[i].scales;
|
||||
const int8_t *q8 = y[i].qs;
|
||||
|
||||
int summs = 0;
|
||||
for (int j = 0; j < QK_K / 32; j++) {
|
||||
uint8_t sc_val, m_val;
|
||||
q4_k_get_scale_min(j, sc, &sc_val, &m_val);
|
||||
int32_t gsum = (int32_t)y[i].bsums[j * 2] + (int32_t)y[i].bsums[j * 2 + 1];
|
||||
summs += m_val * gsum;
|
||||
}
|
||||
|
||||
int isum = 0;
|
||||
for (int j = 0; j < QK_K / 32; j++) {
|
||||
uint8_t sc_val, m_val;
|
||||
q4_k_get_scale_min(j, sc, &sc_val, &m_val);
|
||||
|
||||
const int byte_off = (j >> 1) * 32;
|
||||
const int shift = (j & 1) * 4;
|
||||
|
||||
for (int l = 0; l < 32; l++) {
|
||||
isum += ((qs[byte_off + l] >> shift) & 0xF) * (int)q8[j * 32 + l] * sc_val;
|
||||
}
|
||||
}
|
||||
|
||||
sumf += d * (float)isum + dm * (float)summs;
|
||||
}
|
||||
|
||||
*s = sumf;
|
||||
}
|
||||
|
||||
/* Reference: fully dequantize Q4_K to float, then dot with Q8_K's dequantized values. */
|
||||
static float ref_dot(const block_q4_K *bx, const block_q8_K *by) {
|
||||
float x[QK_K];
|
||||
const float d = f16_to_f32(bx->d);
|
||||
const float dm = f16_to_f32(bx->dmin);
|
||||
|
||||
for (int j = 0; j < QK_K / 32; j++) {
|
||||
uint8_t sc_val, m_val;
|
||||
q4_k_get_scale_min(j, bx->scales, &sc_val, &m_val);
|
||||
const int byte_off = (j >> 1) * 32;
|
||||
const int shift = (j & 1) * 4;
|
||||
for (int l = 0; l < 32; l++) {
|
||||
int q = (bx->qs[byte_off + l] >> shift) & 0xF;
|
||||
x[j * 32 + l] = d * sc_val * (float)q - dm * m_val;
|
||||
}
|
||||
}
|
||||
|
||||
float sum = 0.0f;
|
||||
for (int i = 0; i < QK_K; i++) sum += x[i] * by->d * (float)by->qs[i];
|
||||
return sum;
|
||||
}
|
||||
|
||||
static void fill_q4_K(block_q4_K *bx, uint32_t seed) {
|
||||
uint8_t *p = (uint8_t *)bx;
|
||||
uint32_t s = seed;
|
||||
for (size_t i = 0; i < sizeof(block_q4_K); i++) {
|
||||
s = s * 1103515245u + 12345u;
|
||||
p[i] = (uint8_t)(s >> 16);
|
||||
}
|
||||
/* Ensure d/dmin are valid finite f16 */
|
||||
bx->d &= 0x7BFF;
|
||||
bx->dmin &= 0x7BFF;
|
||||
}
|
||||
|
||||
static void fill_q8_K(block_q8_K *by, uint32_t seed) {
|
||||
uint32_t s = seed;
|
||||
by->d = ((s & 0xFFFF) / 65536.0f) * 2.0f + 0.01f;
|
||||
for (int i = 0; i < QK_K; i++) {
|
||||
s = s * 1103515245u + 12345u;
|
||||
by->qs[i] = (int8_t)((s >> 16) & 0xFF);
|
||||
}
|
||||
for (int j = 0; j < QK_K / 16; j++) {
|
||||
int32_t sum = 0;
|
||||
for (int l = 0; l < 16; l++) sum += (int32_t)by->qs[j * 16 + l];
|
||||
by->bsums[j] = (int16_t)sum;
|
||||
}
|
||||
}
|
||||
|
||||
static int test_block_sizes(void) {
|
||||
int ok = (sizeof(block_q4_K) == 144 && sizeof(block_q8_K) == 292);
|
||||
printf(" block sizes: Q4_K=%zu (expect 144), Q8_K=%zu (expect 292): %s\n",
|
||||
sizeof(block_q4_K), sizeof(block_q8_K), ok ? "PASS" : "FAIL");
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
|
||||
static int test_scale_extraction(void) {
|
||||
uint8_t scales[12] = {0};
|
||||
uint8_t expected_sc[8] = {5, 12, 30, 60, 7, 15, 31, 63};
|
||||
uint8_t expected_m[8] = {3, 8, 20, 45, 1, 10, 25, 50};
|
||||
|
||||
for (int j = 0; j < 4; j++) {
|
||||
scales[j] = expected_sc[j];
|
||||
scales[j + 4] = expected_m[j];
|
||||
}
|
||||
for (int j = 4; j < 8; j++) {
|
||||
scales[j + 4] = (expected_sc[j] & 0xF) | ((expected_m[j] & 0xF) << 4);
|
||||
scales[j - 4] |= ((expected_sc[j] >> 4) << 6);
|
||||
scales[j - 0] |= ((expected_m[j] >> 4) << 6);
|
||||
}
|
||||
|
||||
int ok = 1;
|
||||
for (int j = 0; j < 8; j++) {
|
||||
uint8_t sc, m;
|
||||
q4_k_get_scale_min(j, scales, &sc, &m);
|
||||
if (sc != expected_sc[j] || m != expected_m[j]) {
|
||||
printf(" j=%d: expected sc=%d m=%d, got sc=%d m=%d\n",
|
||||
j, expected_sc[j], expected_m[j], sc, m);
|
||||
ok = 0;
|
||||
}
|
||||
}
|
||||
|
||||
printf(" scale extraction: %s\n", ok ? "PASS" : "FAIL");
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
|
||||
static int test_dot_reference(void) {
|
||||
int ok = 1;
|
||||
for (uint32_t seed = 1; seed <= 50; seed++) {
|
||||
block_q4_K bx;
|
||||
block_q8_K by;
|
||||
fill_q4_K(&bx, seed);
|
||||
fill_q8_K(&by, seed * 7 + 13);
|
||||
|
||||
float result = 0.0f;
|
||||
vec_dot_q4_K_q8_K(QK_K, &result, &bx, &by);
|
||||
float expected = ref_dot(&bx, &by);
|
||||
|
||||
float err = fabsf(result - expected);
|
||||
float rel = fabsf(expected) > 1e-3f ? err / fabsf(expected) : err;
|
||||
if (rel > 0.01f) {
|
||||
printf(" seed=%u: result=%.6f expected=%.6f rel_err=%.6f\n",
|
||||
seed, result, expected, rel);
|
||||
ok = 0;
|
||||
}
|
||||
}
|
||||
|
||||
printf(" dot vs reference (50 random blocks): %s\n", ok ? "PASS" : "FAIL");
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
|
||||
/* Test with a hand-crafted known block. */
|
||||
static int test_dot_known(void) {
|
||||
block_q4_K bx;
|
||||
block_q8_K by;
|
||||
memset(&bx, 0, sizeof(bx));
|
||||
memset(&by, 0, sizeof(by));
|
||||
|
||||
/* d=1.0 f16=0x3C00, dmin=0, all scales=1 (sc=1, m=0), all qs=0x88 (value 8) */
|
||||
bx.d = 0x3C00;
|
||||
bx.dmin = 0;
|
||||
/* Groups 0-3: sc=1 m=0 */
|
||||
for (int j = 0; j < 4; j++) {
|
||||
bx.scales[j] = 1;
|
||||
bx.scales[j + 4] = 0;
|
||||
}
|
||||
/* Groups 4-7: sc=1 m=0, high bits=0 */
|
||||
for (int j = 4; j < 8; j++) {
|
||||
bx.scales[j + 4] = (1 & 0xF) | (0 << 4);
|
||||
/* high bits already 0 */
|
||||
}
|
||||
/* All qs = 0x88: low nibble=8, high nibble=8 */
|
||||
memset(bx.qs, 0x88, sizeof(bx.qs));
|
||||
|
||||
/* Q8: all +1, d=1.0 */
|
||||
by.d = 1.0f;
|
||||
for (int i = 0; i < QK_K; i++) by.qs[i] = 1;
|
||||
for (int j = 0; j < QK_K / 16; j++) by.bsums[j] = 16;
|
||||
|
||||
/* Expected: d=1, dm=0, isum = sum over 8 groups * 32 values * 8 * 1 * sc(=1) = 8*32*8 = 2048 */
|
||||
float result = 0.0f;
|
||||
vec_dot_q4_K_q8_K(QK_K, &result, &bx, &by);
|
||||
float expected = 2048.0f;
|
||||
|
||||
int ok = (fabsf(result - expected) < 0.5f);
|
||||
printf(" dot known: result=%.1f expected=%.1f: %s\n", result, expected, ok ? "PASS" : "FAIL");
|
||||
return ok ? 0 : 1;
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
int failures = 0;
|
||||
|
||||
printf("Q4_K unit tests:\n");
|
||||
failures += test_block_sizes();
|
||||
failures += test_scale_extraction();
|
||||
failures += test_dot_known();
|
||||
failures += test_dot_reference();
|
||||
|
||||
printf("\n%d/%d tests passed\n", 4 - failures, 4);
|
||||
return failures ? 1 : 0;
|
||||
}
|
||||
Reference in New Issue
Block a user