Skip to content

hip families: refuse a token id at or past the embedding table before the lookup - #3046

Merged
ashhart merged 2 commits into
mainfrom
security/token-ids-hip
Nov 13, 2026
Merged

ashhart merged 2 commits into
mainfrom
security/token-ids-hip

Conversation

@ashhart

@ashhart ashhart commented Nov 12, 2026

Copy link
Copy Markdown
Owner

What this changes

Before: on these paths a token id reached the embedding lookup unchecked, and no embedding kernel bounds its ids, so an id at or past the table read device memory past it. After: each path refuses such an id on the host before the ids are uploaded, and the loaders that took the embedding table as stored refuse one whose rows are not the vocabulary's. ROCm paths: nemotron, flashnext, qwen3_5 and nemotron_parse's draft path.

  • Issue: n/a. SECURITY.md asks for private reports, so there is no public issue.
  • Stacked on: main.
  • atc overlap --json: not run.

Checks on this head

  • Head commit: 2e59e1b97875fdbd5c58e87abfcc36da2e8bd534
  • Lean checker, python3 tools/zig/lean_check.py, on the base and on this head: 345 on the base, 345 on this head, 0 new.
  • Tests run, with the command and pass, fail and skip counts:
    • zig fmt --check on 14 files: passes
    • git diff --check: passes
    • zig build native: 66/66 steps succeeded
    • zig build check-native-cuda-host compile-flashnext-mtp-parity-host compile-glm-native-open: 11/11 steps succeeded
    • zig build -Dhip=true check-native-hip-host test-native-hip-host test-environment-hip-host test-hip-family-offers-host test-qwen3-hip-host: 19/19 steps succeeded; 29/29 tests passed
    • zig build xpu-native with stand-ins for Intel's ocloc and nGEN headers: 47/47 steps succeeded
    • the nemotron HIP module's security: tests, through a temporary filter step: 4/4 steps succeeded; 4/4 tests passed
    • zig build test-step5-host test-lfm3-host test-lfm3-prefill-host test-minimax-info-host test-minimax-cuda-host test-xpu-refusal-host test-draft-xpu-host test-qwen27-config-xpu-host test-nemotron-round-depth-host test-nemotron-prefill-widths-host test-nemotron-mtp-policy-host test-nemotron-restored-head-host test-nemotron-subset-head-host test-nemotron-grants-host test-nemotron-copies-host test-gemma4-load-parts-host test-gemma4-owners-host test-gemma4-contract-host test-gemma4-prompt-head-host test-gemma4-tower-host test-glm-window-contract-host test-glm-contract-host test-glm-formats-host test-glm-copies-host test-flashnext-host test-flashnext-batch-host test-flashnext-mtp-plan-host test-flashnext-driver-host test-flashnext-single-session-host test-flashnext-scheduling-host test-flashnext-constraint-host test-flashnext-prefill-pairs-host test-flashnext-contract-host test-qwen35-rounds-host test-qwen35-verify-host test-qwen35-prefill-host test-qwen35-draft-frames-host: 194/194 steps succeeded; 881/885 tests passed (4 skipped)
    • zig build test-golden test-server-security test-pull-security: 76/76 steps succeeded; 31/31 tests passed
  • New tests:
    • security: a round refuses a token at or past the vocabulary before its plan is written
  • CI: runs on this push.
  • Not run, and why: One new unit test, in nemotron's round planner. It has no step of its own and ran through a temporary filter step that is not part of the branch. zig build test and every step that runs on a GPU were not run: this Mac's GPU was serving a model, and no CUDA, ROCm or Intel hardware was available.

Receipt

  • Main against branch: could not be run. It needs a ROCm device, and none was run.
  • Boxes it reaches: ROCm serving of the families listed above.
  • New switch? Default, accepted values, profile row: none.
  • Environment, with the TensorFold commit, Zig and backend toolchain, machine and GPU, checkpoint and revision: this head on Zig 0.17.0, on an Apple silicon Mac, CPU-only steps. No GPU and no checkpoint was used.
  • Paths and platforms the change reaches, which I ran and which I could not: all four servers compile with this change. The ROCm host steps ran on macOS with stub kernels.
  • Exactness: not measured. The change adds host comparisons before an upload and changes no kernel and no arithmetic, so a valid prompt takes the same path as on main.
  • Main against this branch, same machine and checkpoint: not run, for the reason above.
  • Decode speed before and after: not measured.
  • Prompt speed before and after: not measured.
  • Licence of any new weights or drafter: n/a.

Checklist

  • The title and description match the head commit, including the receipt and the stack.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency. Each new test was shown to fail without its fix on the earlier base b38a4dd02. On this base only the passing side was rerun.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths in the diff or its commits. No AI attribution lines.

For a change that reaches inference:

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. Not measured: no served run.
  • No precision traded for speed.
  • Decode and prompt processing are no slower than main. Not measured: no served run.

Notes for the reviewer

  • A request that carries such an id now fails with an error where it used to read past the table.
  • A checkpoint whose embedding table does not match its configured vocabulary is refused at load. Most of these checks want an exact match, so a table with more rows than the vocabulary is refused too.
  • Not changed here: the training paths, the dev and timing tools, and output heads that are loaded unshaped.

Suggested changelog line

ROCm: nemotron, flashnext, qwen3_5 and nemotron_parse refuse a token id at or past the embedding table before the lookup.

@ashhart
ashhart marked this pull request as ready for review November 12, 2026 17:46
@ashhart

ashhart commented Nov 12, 2026

Copy link
Copy Markdown
Owner Author

Review: ready. We have no AMD or Intel GPU, so we checked the new load-time shape checks against real checkpoints' safetensors headers and configs instead. Every check passes on every checkpoint we could read:

  • Flash Next MLX 4-bit;
  • Nemotron 3.5 Lightning MLX 4-bit;
  • Qwen3.5/3.6/3.8 MLX and BF16 heads;
  • Gemma 4 E4B MLX 4-bit, both embedding tables;
  • LFM3 1.7B MLX 4-bit;
  • Qwen3.8-27B GPTQ;
  • the DFlash2 drafter's codebooks.

A few checkpoints would fail a new check, but none of them was ever supported on that path: 8-bit Nemotron and LFM3-VL on XPU, which are refused earlier, and Qwen3.8-27B MLX 8-bit on XPU, which this check now refuses by name. No bound refuses a legitimate id, and the checks are host-side compares with no added sync. Not checked: runtime on AMD or Intel hardware.

  • Synthena (Ash's Agent)

… the lookup

The embedding kernels read the table at the id they are given and none of them bounds it, so the host check
is the only one. Each path now refuses an id at or past the vocabulary before it uploads the ids, and the loaders
that took the table as stored refuse one whose rows are not the vocabulary's.
@ashhart
ashhart force-pushed the security/token-ids-hip branch from 2e59e1b to 7f82afa Compare November 13, 2026 02:01
@ashhart
ashhart merged commit ce7932c into main Nov 13, 2026
2 of 10 checks passed
@ashhart
ashhart deleted the security/token-ids-hip branch November 13, 2026 02:02
ashhart added a commit that referenced this pull request Nov 13, 2026
Figures and scope corrected to the PRs (#2948, #2863, #2934, #2933, #2921, #2906, #2878, #2892, #2851, #2728, #3072,
#2915, #2864, #2854 and others), promises of later work removed (#2903, #2875, #1630, #1720), #3074 and #3047/#3046
said as their PRs scope them, the duplicate #2861, #2585, #2321 and #2719 entries and two copies of released 1.2.5
lines removed, #1953's line named for its PR, and a line for #3255. Released sections unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant