Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/no-gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ jobs:
strategy:
fail-fast: false
matrix:
suite: [fast, host, compile, hip]
suite: [fast, host, compile, hip, deepseek]
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4.4.0
with:
Expand All @@ -303,9 +303,12 @@ jobs:
run: |
printf 'Runner class: %s %s\n' "$RUNNER_OS" "$RUNNER_ARCH"
flags=()
limit=10m
if [ "$SUITE" = hip ]; then flags=(-Dhip=true); fi
# One DeepSeek aot-needs test runs about 10 minutes on a fast core; macOS gives it 30 too.
if [ "$SUITE" = deepseek ]; then limit=30m; fi
TIMEFORMAT='Host checks wall seconds: %R'
time zig build -Dfixed-cpu "${flags[@]}" "test-host-ci-linux-$SUITE" --test-timeout 10m
time zig build -Dfixed-cpu "${flags[@]}" "test-host-ci-linux-$SUITE" --test-timeout "$limit"
host-nightly-macos:
if: ${{ github.event_name == 'schedule' }}
runs-on: macos-26
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ Each release's page on GitHub has its notes and measurements. See [the 1.0.0 rel

## Unreleased

- CI: the nightly Linux host job gains a `deepseek` shard that runs `test-dsv41-device-host` and `test-dsv41-forward`, so their Linux-only tests (a forked child's fail-fast exit and the model's fatal callback without an NCCL abort) run on Linux; Linux CI only compiled these steps before, and macOS skips those tests (#2598).

- CI: the macOS nightly also runs the thirteen host checks it held back until their fixes landed (#2566).
- Qwen3.8-Flash-Next on HIP fills prompts faster: its sparse attention runs a new kernel with the same sums as before (a lane holds a key and several heads, keys and values staged in the cache type), so replies are unchanged. On a Radeon 8060S (gfx1151), cold prompts of 2,048 to 63,728 tokens finish 29 to 41% sooner; other HIP chips take the kernel but weren't run (#1877). Thanks to @gilby.
- Tools: `tools/conformance.py` runs a family's served exactness gates from one JSON profile, and its own tests run in CI with no device against a fake server with planted faults (#2467, part of #2460). Thanks to @jschmied.

- HIP on gfx12 under `--policy matrix=on`: Qwen3 dense checkpoints load each layer's gate and up weights interleaved as one weight, and one WMMA product writes silu(gate) x up in its epilogue instead of two products and `tf_silu_mul`, with the same output bytes: Qwen3-Reranker-8B ranks 16 documents in 0.657 to 0.661 s instead of 0.687 to 0.697 s and Qwen3-Embedding-8B embeds 100 short inputs in 0.901 to 0.911 s instead of 0.940 to 0.948 s on a Radeon AI PRO R9700. The kernel contract checks both fused blocks byte for byte against the unfused launches (part of #2245). Thanks to @laudney.
- Nemotron on Macs: the masked prompt shader calls the shared `tf_paged_row` page helper again, so its prompt sources compile; #2322 had used the name #2283 retired the same day (#2548).
- Server: control bytes in a request line (C0, DEL and C1) appear in the access log as `\xNN`, so a request cannot write terminal escapes into the log; ordinary lines are unchanged (#2542). Thanks to @chadhurley25075-png.
Expand Down
445 changes: 445 additions & 0 deletions tools/conformance.py

Large diffs are not rendered by default.

79 changes: 79 additions & 0 deletions tools/conformance_profiles/gemma4-cuda.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"name": "gemma4-cuda",
"family": "gemma4 on CUDA",
"checkpoint": "a Gemma 4 31B 4-bit MLX checkpoint with its DFlash drafter",
"serve": [
"--backend",
"cuda",
"--context",
"16384",
"--parallel",
"8",
"--no-thinking",
"--drafter",
"{drafter}"
],
"sampled": {
"temperature": 0.8,
"top_p": 0.95,
"top_k": 64
},
"tokens": 64,
"seed": 7,
"levels": [
1,
2,
4,
8
],
"prompt_cache_gib": 2,
"ignore_eos": true,
"prompts": {
"poem": "Write a short poem about the sea.",
"primes": "List the first twelve prime numbers, separated by commas.",
"sky": "Explain in two sentences why the sky is blue.",
"count": "Count from one to thirty in words.",
"copy": "Repeat exactly: The harbor lights came on one by one as the fishing boats returned to the quay."
},
"long_items": 500,
"conversation": [
"Name three rivers in Europe and one fact about each.",
"Now give the length of each river in kilometres.",
"Which of them is the longest? Answer in one sentence."
],
"conversation_context_items": 900,
"refusals": [
{
"name": "n_two",
"body": {
"n": 2
},
"status": 400,
"error": "n must be 1; multiple choices are not supported"
},
{
"name": "top_logprobs_without_logprobs",
"body": {
"top_logprobs": 3
},
"status": 400,
"error": "top_logprobs requires logprobs: true"
},
{
"name": "presence_penalty_out_of_range",
"body": {
"presence_penalty": 3
},
"status": 400,
"error": "presence_penalty must be between -2 and 2, or null"
},
{
"name": "reply_past_context",
"body": {
"max_tokens": 10000000
},
"status": 400,
"error": "This server's maximum context length is"
}
]
}
79 changes: 79 additions & 0 deletions tools/conformance_profiles/qwen35-cuda.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"name": "qwen35-cuda",
"family": "qwen3_5 on CUDA",
"checkpoint": "a Qwen 3.5/3.8 27B NVFP4 checkpoint with its DFlash2 drafter",
"serve": [
"--backend",
"cuda",
"--context",
"16384",
"--parallel",
"8",
"--no-thinking",
"--drafter",
"{drafter}"
],
"sampled": {
"temperature": 0.8,
"top_p": 0.95,
"top_k": 20
},
"tokens": 64,
"seed": 7,
"levels": [
1,
2,
4,
8
],
"prompt_cache_gib": 2,
"ignore_eos": true,
"prompts": {
"poem": "Write a short poem about the sea.",
"primes": "List the first twelve prime numbers, separated by commas.",
"sky": "Explain in two sentences why the sky is blue.",
"count": "Count from one to thirty in words.",
"copy": "Repeat exactly: The harbor lights came on one by one as the fishing boats returned to the quay."
},
"long_items": 500,
"conversation": [
"Name three rivers in Europe and one fact about each.",
"Now give the length of each river in kilometres.",
"Which of them is the longest? Answer in one sentence."
],
"conversation_context_items": 900,
"refusals": [
{
"name": "n_two",
"body": {
"n": 2
},
"status": 400,
"error": "n must be 1; multiple choices are not supported"
},
{
"name": "top_logprobs_without_logprobs",
"body": {
"top_logprobs": 3
},
"status": 400,
"error": "top_logprobs requires logprobs: true"
},
{
"name": "presence_penalty_out_of_range",
"body": {
"presence_penalty": 3
},
"status": 400,
"error": "presence_penalty must be between -2 and 2, or null"
},
{
"name": "reply_past_context",
"body": {
"max_tokens": 10000000
},
"status": 400,
"error": "This server's maximum context length is"
}
]
}
126 changes: 126 additions & 0 deletions tools/tests/fake_served_api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
"""A fake served API for the conformance kit's tests: deterministic chat replies on loopback, with planted faults.

A clean fake passes every gate. Each fault breaks one property the kit gates, and only that one:

- drafted: a drafted reply to the copy prompt differs from its plain reply.
- repeat: a drafted reply to the sky prompt differs the second time that request arrives.
- concurrent: a reply differs while another request is in flight.
- resumed: the cached server reports no cached prompt tokens.
- refusals: an out-of-range presence_penalty is answered instead of refused.

Standard library only; no device, no network beyond 127.0.0.1.
"""
import contextlib
import hashlib
import http.server
import json
import threading
import time

FAULTS = ("drafted", "repeat", "concurrent", "resumed", "refusals")
BATCH_WINDOW = 0.15 # seconds a lone request waits for a partner under the concurrent fault


def doc(sha="a" * 64, cached=0, accepted=2, drafted=3, text="hi"):
"""A chat completion body carrying the fields the kit reads."""
return {"choices": [{"message": {"content": text}}], "tensorfold": {"token_sha256": sha},
"speculative": {"accepted": accepted, "drafted": drafted},
"usage": {"prompt_tokens": 9, "completion_tokens": 4, "prompt_tokens_details": {"cached_tokens": cached}}}


def refusal(body, fault=None):
"""The error a real server gives for the profile's refused requests, else None."""
if body.get("n", 1) != 1:
return "n must be 1; multiple choices are not supported"
if "top_logprobs" in body and not body.get("logprobs"):
return "top_logprobs requires logprobs: true"
if abs(body.get("presence_penalty", 0)) > 2 and fault != "refusals":
return "presence_penalty must be between -2 and 2, or null"
if body.get("max_tokens", 0) > 100000:
return "This server's maximum context length is 16384 tokens"
return None


def text_of(body) -> str:
return " ".join(m.get("content", "") for m in body.get("messages", []))


class FakeEngine(http.server.BaseHTTPRequestHandler):
"""The reply hash depends on the messages and, when sampling, the seed; never on draft, cache or batch."""

def log_message(self, *_):
pass

def do_GET(self):
self.reply(200, {"object": "list", "data": [{"id": "fake", "object": "model"}]})

def do_POST(self):
server = self.server
body = json.loads(self.rfile.read(int(self.headers["Content-Length"])))
error = refusal(body, server.fault)
if error:
return self.reply(400, {"error": {"message": error, "type": "invalid_request_error"}})
key = json.dumps(body, sort_keys=True)
with server.lock:
server.seen[key] = server.seen.get(key, 0) + 1
arrival = server.seen[key]
server.inflight += 1
try:
batched = self.batched() if server.fault == "concurrent" else False
seed = body["seed"] if body.get("temperature") else None
salt = self.salt(body, arrival, batched)
sha = hashlib.sha256(json.dumps([body["messages"], seed, salt]).encode()).hexdigest()
cached = 5 if server.cache and server.fault != "resumed" and len(body["messages"]) > 1 else 0
accepted = 2 if body.get("draft", True) else 0
payload = doc(sha=sha, cached=cached, accepted=accepted, drafted=accepted, text="r" + sha[:6])
finally:
with server.lock:
server.inflight -= 1
# Out of flight before the reply is written: the client's next request must not find this one still counted.
self.reply(200, payload)
time.sleep(server.linger)

def batched(self) -> bool:
"""True when another request shares the server with this one within the batch window."""
server = self.server
with server.cond:
server.cond.notify_all()
return server.cond.wait_for(lambda: server.inflight > 1, timeout=BATCH_WINDOW)

def salt(self, body, arrival, batched):
"""A planted fault changes the reply by adding a salt to its hash; None leaves it correct."""
fault, draft = self.server.fault, body.get("draft", True)
if fault == "drafted" and draft and "Repeat exactly" in text_of(body):
return "drafted"
if fault == "repeat" and draft and "sky" in text_of(body) and arrival == 2:
return "repeat"
if fault == "concurrent" and batched:
return "batched"
return None

def reply(self, status, payload):
raw = json.dumps(payload).encode()
self.send_response(status)
self.send_header("Content-Type", "application/json")
self.send_header("Content-Length", str(len(raw)))
self.end_headers()
self.wfile.write(raw)


@contextlib.contextmanager
def fake(cache, fault=None, linger=0.0):
"""A running fake on 127.0.0.1 port 0, yielding its base URL; cache=False is the cache-off server."""
# linger: seconds each handler stays alive after its reply, widening any window between reply and exit.
if fault not in (None, *FAULTS):
raise ValueError(f"unknown fault {fault}")
server = http.server.ThreadingHTTPServer(("127.0.0.1", 0), FakeEngine)
server.cache, server.fault, server.seen, server.inflight, server.linger = cache, fault, {}, 0, linger
server.lock = threading.Lock()
server.cond = threading.Condition(server.lock)
thread = threading.Thread(target=server.serve_forever, daemon=True)
thread.start()
try:
yield f"http://127.0.0.1:{server.server_address[1]}"
finally:
server.shutdown()
server.server_close()
Loading
Loading