Skip to content

feat(server): serve flags a backend opts into: tensor parallelism, MTP, kept entries, policy - #624

Merged
ashhart merged 1 commit into
ashhart:mainfrom
BlivionIaG:serve-flags
Oct 10, 2026
Merged

ashhart merged 1 commit into
ashhart:mainfrom
BlivionIaG:serve-flags

Conversation

@BlivionIaG

Copy link
Copy Markdown
Contributor

What this changes

The server CLI slice tracked in #491: the serve flags the HIP engine will read. They are off in every build that has today: a backend opts in by listing them, and none does yet. The Qwen3.5 HIP engine will be the first.

  • A native module may declare serves, the flags beyond the common ones that it takes. main.zig re-exports the list, and cli.zig reads it from @import("root"), so the server library and its tests stay engine-less. A listed flag parses, is checked, appears in capabilities --json, and reaches the engine through api.Open:
    • --tp {1,2,4,8}, --rank (below --tp), --master, --master-port. A rank above 0 serves no HTTP; it runs rank 0's steps through the backend's follow (a build without follow refuses it).
    • --mtp-drafts (0 to 64), --mtp-confidence (0 to 1).
    • --checkpoint-slots: kept prompt entries, from 0.
    • --policy key=value: repeatable, joined by commas. Info.policy is shown by /health.
  • --backend takes rocm when the backend lists --backend=rocm.
  • The Args-to-Open mapping moves from engines.zig to cli.zig, where its test runs (engines.zig is in no test root).

Receipt

  • Environment: base main at bec00ae, head 8392fc3. Zig 0.17.0, on macOS (Apple silicon) and Linux 7.1.7.
  • Exactness:
    • The Metal tensorfold-native capabilities --json is byte-identical to main's. serve m --tp 2 gives the same refusal, word for word.
    • "the GPU engine's flags: refused and unlisted unless the backend serves them, values checked": each gated flag is listed exactly when its serves entry is present, and refused otherwise. Every value bound is checked.
    • "an engine is asked for what the flags say, and the defaults of the flags not given": request maps every new flag, and its defaults equal api.Open's.
    • Each test fails with the change broken: --tp served unconditionally fails the first (expected false, found true); --checkpoint-slots not mapped fails the second (expected 3, found null).
    • A scratch Metal build listing serves lists the flags, refuses --rank 2 with --tp 2 and --policy matrix, and sends --rank 1 to follow ("this build has no tensor-parallel ranks").
  • Decode and prompt speed: not applicable (no engine path touched).
  • Tests run:
    • macOS zig build test test-golden -Dcpu=apple_m1: 141/141 steps; golden 309/319 equal, 0 unexpected.
    • Linux zig build test: 37/37 steps, 373/373 tests.
    • zig fmt --check is clean on the changed files. On the whole tree it reports tokenizer.zig, native/cuda.zig and tests/moe_bench.zig, the same as main.
    • lean_check.py: 542 problems, the same as main.
  • Not run, and why: device runs (no engine path touched). zig/tests/server/build.sh fails on main too: it doesn't pass checkpoint_cli.

Checklist

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off. (No engine path touched.)
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (No engine path touched.)
  • No precision traded for speed.
  • Prompt processing is no slower than the last release. (No prompt path touched.)
  • The description says which platforms I ran and which I could not.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency.
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.

…P, kept entries, policy

A native module may list `serves`: the flags past the common ones it takes. The binary's root re-exports the
list and cli.zig reads it there, so the server library and its tests stay engine-less. Listed flags parse,
are checked, appear in `capabilities --json` and reach the engine through `api.Open`:

- --tp {1,2,4,8}, --rank (below --tp), --master, --master-port: a rank above 0 serves no HTTP and runs
  rank 0's steps through the backend's `follow`;
- --mtp-drafts (0 to 64) and --mtp-confidence (0 to 1);
- --checkpoint-slots (kept prompt entries, from 0);
- --policy key=value, repeatable, joined by commas; `Info.policy` is shown by /health.

--backend also takes rocm when the backend lists `--backend=rocm`. Metal, CUDA and the engine-less build list
nothing: their parse, their refusals and `capabilities --json` are byte-identical to before. The Args-to-Open
mapping moves from engines.zig to cli.zig, where its test runs.
@ashhart

ashhart commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Thank you, @BlivionIaG. This is merged into main (38de96b) on top of #623, your commit as it was, and it ships in 1.0.6. Since the Args-to-Open mapping moved for every engine, we checked the default path on a device as well as the host. On a GB10, capabilities --json is byte-identical to main's, 29 of 29 served replies are equal (drafted == plain and concurrent == solo 10 of 10 in each arm), the four release prompts keep their SHAs, and decode and cold prompts are within noise. The Mac host gates pass (golden 309 of 319, no unexpected differences), and the Linux tests pass 282 of 282.

One note for when a backend first lists --tp: our two-Mac engines (GLM-5.3-Flash and Flash Next) take their ranks from a settings file per rank (--speed-up). Please keep the two from meaning different things for the same model. A backend should take one or the other, and refuse both together.

BlivionIaG added a commit to BlivionIaG/TensorFold that referenced this pull request Oct 10, 2026
… and model checks

The HIP branch's engine (ashhart#490) on ashhart#463's runtime and the kernel launches of ashhart#617 and ashhart#621: the lane rounds with
MTP drafts, the paged attention cache and the radix prompt cache (ashhart#625), chunked prompts (ashhart#623), CUDA-graph
rounds, the memory plan, and tensor parallelism over RCCL (comm/: the library, the rank link, the group). The
native server takes it with `zig build native-hip -Dhip-arch=...` and the serve flags it lists (ashhart#624);
`tf-qwen35-test` runs the model checks on a GPU. `zig build test` compiles both against stub kernels.

The engine reads the policy (`--policy`, TF_POLICY) once and hands the kernels `Launcher.Choices`; a GPU other
than the one the kernels were built for is refused with both names. round_shape.zig stays in the family: its
only reader is the plan.
@ashhart ashhart mentioned this pull request Oct 10, 2026
ashhart pushed a commit that referenced this pull request Oct 16, 2026
… and model checks

The HIP branch's engine (#490) on #463's runtime and the kernel launches of #617 and #621: the lane rounds with
MTP drafts, the paged attention cache and the radix prompt cache (#625), chunked prompts (#623), CUDA-graph
rounds, the memory plan, and tensor parallelism over RCCL (comm/: the library, the rank link, the group). The
native server takes it with `zig build native-hip -Dhip-arch=...` and the serve flags it lists (#624);
`tf-qwen35-test` runs the model checks on a GPU. `zig build test` compiles both against stub kernels.

The engine reads the policy (`--policy`, TF_POLICY) once and hands the kernels `Launcher.Choices`; a GPU other
than the one the kernels were built for is refused with both names. round_shape.zig stays in the family: its
only reader is the plan.
ashhart pushed a commit that referenced this pull request Oct 16, 2026
… and model checks

The HIP branch's engine (#490) on #463's runtime and the kernel launches of #617 and #621: the lane rounds with
MTP drafts, the paged attention cache and the radix prompt cache (#625), chunked prompts (#623), CUDA-graph
rounds, the memory plan, and tensor parallelism over RCCL (comm/: the library, the rank link, the group). The
native server takes it with `zig build native-hip -Dhip-arch=...` and the serve flags it lists (#624);
`tf-qwen35-test` runs the model checks on a GPU. `zig build test` compiles both against stub kernels.

The engine reads the policy (`--policy`, TF_POLICY) once and hands the kernels `Launcher.Choices`; a GPU other
than the one the kernels were built for is refused with both names. round_shape.zig stays in the family: its
only reader is the plan.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
BlivionIaG added a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
… and model checks

The HIP branch's engine (ashhart#490) on ashhart#463's runtime and the kernel launches of ashhart#617 and ashhart#621: the lane rounds with
MTP drafts, the paged attention cache and the radix prompt cache (ashhart#625), chunked prompts (ashhart#623), CUDA-graph
rounds, the memory plan, and tensor parallelism over RCCL (comm/: the library, the rank link, the group). The
native server takes it with `zig build native-hip -Dhip-arch=...` and the serve flags it lists (ashhart#624);
`tf-qwen35-test` runs the model checks on a GPU. `zig build test` compiles both against stub kernels.

The engine reads the policy (`--policy`, TF_POLICY) once and hands the kernels `Launcher.Choices`; a GPU other
than the one the kernels were built for is refused with both names. round_shape.zig stays in the family: its
only reader is the plan.
BlivionIaG added a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
… and model checks

The HIP branch's engine (ashhart#490) on ashhart#463's runtime and the kernel launches of ashhart#617 and ashhart#621: the lane rounds with
MTP drafts, the paged attention cache and the radix prompt cache (ashhart#625), chunked prompts (ashhart#623), CUDA-graph
rounds, the memory plan, and tensor parallelism over RCCL (comm/: the library, the rank link, the group). The
native server takes it with `zig build native-hip -Dhip-arch=...` and the serve flags it lists (ashhart#624);
`tf-qwen35-test` runs the model checks on a GPU. `zig build test` compiles both against stub kernels.

The engine reads the policy (`--policy`, TF_POLICY) once and hands the kernels `Launcher.Choices`; a GPU other
than the one the kernels were built for is refused with both names. round_shape.zig stays in the family: its
only reader is the plan.
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.

2 participants