Skip to content

perf(BACKEND-ROCM): cooperate across Q8_K activation blocks - #2472

Merged
mudler merged 12 commits into
mudler:mainfrom
VikashLoomba:row/BACKEND-ROCM-Q8K-COOP
Sep 2, 2026
Merged

perf(BACKEND-ROCM): cooperate across Q8_K activation blocks#2472
mudler merged 12 commits into
mudler:mainfrom
VikashLoomba:row/BACKEND-ROCM-Q8K-COOP

Conversation

@VikashLoomba

Copy link
Copy Markdown
Contributor

Row

BACKEND-ROCM

Before starting

  • Issue QuantizeQ8KK is thread-per-superblock: 95.5us/call against llama.cpp's 1.6us, and 41% of the ROCm decode gap #1876 tracks the serial ROCm Q8_K activation quantizer. The owning specification lists it under ## Owed because the authenticated account cannot add its live Row: line.
  • The recorded choice uses one pull request for specification and implementation.
  • .agents/specs/rocm-q8k-cooperative-quantizer.md was committed before product code. It owns the byte oracle, production routes, architecture policy, acceptance gate, evidence, and remaining work.
  • The implementation mirrors src/vt/cuda/cuda_quant_dot.cu::QuantizeQ8KPreqKernel and LaunchQuantizeQ8K. The CPU QuantizeRowQ8_K path supplies an independent byte oracle.

What changed

The ROCm Q8_K activation quantizer now cooperates across one 256-thread block instead of assigning one thread to each 256-element superblock. One shared launcher serves both dense and grouped production paths.

The encoder preserves all 292 bytes of BlockQ8_K, including signed first-occurrence ties. Kernel-resident test witnesses prove which arm executed instead of relying only on host dispatch counters.

Unset selection enables the cooperative arm only when the queue-device resolver returns gfx1100. Exact VT_ROCM_Q8K_BLOCK=0 keeps the permanent legacy arm, exact 1 forces the diagnostic candidate, and other values fail. Unset remains legacy for gfx1200, gfx1201, unknown architectures, and resolver failure.

Evidence

  • Final reviewed head 0ee8722daac3199de6d395af099eff3d230c9fa5 has tree 31563a03b5a202a552fcd68c1fcce773295a962b. Fresh immutable review returned findings NONE and verdict PASS.
  • The focused ROCm gate passed 3/3 cases and 3,561/3,561 assertions. It compared every byte with legacy GPU and CPU encoders across f32, f16, bf16, zero, random, signed-tie, padded, multi-row, and varied-superblock inputs.
  • Dense and grouped public operations proved exclusive host selection and arm-distinct writes from inside the launched kernels for exact 0, exact 1, unset, and invalid values.
  • Independent mutations disabled the accepted default, changed exact 0, bypassed grouped candidate execution, removed environment documentation, removed issue ownership, and injected an integration overlap. Each failed for its intended reason and restored byte-for-byte.
  • Integrated and exact-parent full CTest each ran 700 tests with the same 32 failures and six skips. No integrated-only failure or skip appeared.
  • The final unset real-checkpoint run produced 256 tokens with SHA-256 769bf8eebae5390db7b6aec5b9ab8e84caa9bc4124f659d77b7240f4494ed245.
  • Hermetic full and staged preflights returned 0 and compiled 456/456 scoped translation units. They declared five argument-dependent checks skipped and explicitly did not call that result green.
  • docs/ROCM.md, docs/USAGE.md, and docs/ENVIRONMENT.md document the architecture-scoped default and strict rollback control.

Speed claims

  • The operator ran one discarded warmup and five same-binary pairs per arm under /home/vikash/gpu.lock on an RX 7900 XTX. The candidate won 5/5 pairs: median decode rose from 30.943 to 40.316 tok/s, a 31.377% median paired improvement with one-sided sign-test p=0.03125.
  • Two rocprofv3 subtraction pairs per arm measured 129 quantizer calls per token. Median quantizer time fell from 7.8811 to 0.3426 ms/token, while total kernel time fell from 25.7287 to 18.1923 ms/token.
  • The specification records the exact model, prompt, binaries, raw artifact hashes, profiler method, memory resolution, hardware mapping, contention checks, and rejected first campaign. This change adds no public benchmark ID, so docs/BENCHMARKS.md does not change.

Honest gaps

Addresses #1876.

FOLLOWING_AGENTS_PROTOCOL

Following-Agents-Protocol: true
AI-Assisted: true
Assisted-by: AGENT:gpt-5 [codex]

Issue mudler#1876 needs a committed correctness and measurement contract before
the ROCm kernel changes. This specification pins the byte oracle, both
production routes, the same-binary lever, and the gfx1100 adoption gate.

FOLLOWING_AGENTS_PROTOCOL

Following-Agents-Protocol: true
AI-Assisted: true
Assisted-by: AGENT:gpt-5 [codex]
Pull request mudler#2270 owns the reviewed gate prompt, so this branch must not duplicate it.
The gate now permits local validation against the immutable reviewed worktree.
Publication remains ordered after a maintainer lands the prompt.

FOLLOWING_AGENTS_PROTOCOL

Following-Agents-Protocol: true
AI-Assisted: true
Assisted-by: AGENT:gpt-5 [codex]
Only gfx1100 has accepted measurement authority. A global unset default could therefore enable the cooperative arm on unvalidated devices.

The specification now makes unset selection device-scoped and requires resolver-keyed policy tests before product code.

FOLLOWING_AGENTS_PROTOCOL

Following-Agents-Protocol: true
AI-Assisted: true
Assisted-by: AGENT:gpt-5 [codex]
The legacy ROCm quantizer serializes each 256-element activation block.
Use one 256-thread block while preserving the Q8_K byte encoding.

Keep the architecture-scoped unset policy on the legacy arm until the
operator accepts the real-checkpoint performance gates.

FOLLOWING_AGENTS_PROTOCOL

Following-Agents-Protocol: true
AI-Assisted: true
Assisted-by: AGENT:gpt-5 [codex]
Host route counters proved selection before launch, so a legacy kernel
could still satisfy the candidate route assertion.

Record one arm-specific count inside the launched kernel and combine it
with both production route checks.

FOLLOWING_AGENTS_PROTOCOL

Following-Agents-Protocol: true
AI-Assisted: true
Assisted-by: AGENT:gpt-5 [codex]
The accepted gfx1100 correctness, route, engine, and profiler gates justify the architecture-scoped default. Other architectures remain legacy, and strict controls retain same-binary diagnosis and rollback.

FOLLOWING_AGENTS_PROTOCOL

Following-Agents-Protocol: true
AI-Assisted: true
Assisted-by: AGENT:gpt-5 [codex]
Pull request mudler#2270 supplies the tracked TG200 prompt and current main's derived issue-ownership policy.

This merge retains the fully reviewed gfx1100 Q8_K behavior and takes the frozen completed issue index byte-for-byte from current main.

FOLLOWING_AGENTS_PROTOCOL

Following-Agents-Protocol: true
AI-Assisted: true
Assisted-by: AGENT:gpt-5 [codex]
Pull request mudler#2270 supplies the tracked prompt prerequisite. Issue mudler#1876
remains open for gfx1200 and gfx1201 acceptance. The authenticated account
cannot add the live `Row:` line. The spec's `## Owed` link supplies
`BACKEND-ROCM` ownership.

FOLLOWING_AGENTS_PROTOCOL

Following-Agents-Protocol: true
AI-Assisted: true
Assisted-by: AGENT:gpt-5 [codex]
Current main adds the attention-window resolver and the GLM5 k-pool device seam. Its eighteen changed paths do not overlap the six reviewed Q8_K surfaces.

The merge keeps every reviewed Q8_K blob, the specification ownership repair, and the tracked prompt byte-for-byte unchanged.

FOLLOWING_AGENTS_PROTOCOL

Following-Agents-Protocol: true
AI-Assisted: true
Assisted-by: AGENT:gpt-5 [codex]
Current main carries the connector tile repair across ten CPU and LTX2.5 paths. None overlaps the six reviewed Q8_K target-relative paths.

The merge preserves every reviewed Q8_K blob and the tracked publication prompt byte-for-byte.

FOLLOWING_AGENTS_PROTOCOL

Following-Agents-Protocol: true
AI-Assisted: true
Assisted-by: AGENT:gpt-5 [codex]
Publication-time main adds the multimodal input pipeline without touching the six reviewed Q8_K paths.

The merge preserves those blobs and the tracked TG200 prompt while retaining current main’s GLM and preflight changes.

FOLLOWING_AGENTS_PROTOCOL

Following-Agents-Protocol: true
AI-Assisted: true
Assisted-by: AGENT:gpt-5 [codex]
@VikashLoomba

VikashLoomba commented Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

CI classification for reviewed head 0ee8722daac3:

The three red jobs reproduce on target main and are not introduced by this six-path ROCm change.

  • windows-msvc-cpu and windows-msvc-vulkan each fail the same three test_openai_api_server cases with rc=-1073740791: cases 56, 57, and 59. Main's scheduled run at ed5ecea2e has the same three failures in both jobs (CPU, Vulkan). The same signatures also predate this PR at main ancestor 7a1a98760 (scheduled run).
  • sanitize-cpu (address,undefined) reports the same target-main failures. In particular, the 384-byte, four-allocation leak in test_glm_moe_dsa_schedule.cpp:680 is byte-for-byte the main signature; the remaining failed test names also match main's run at ed5ecea2e (main job, PR job).

The pull-request diff contains only the Q8_K specification, three documentation projections, src/vt/rocm/rocm_grouped_gemm.hip, and tests/vt/test_backend_cross_device.cpp. It does not change the Windows API server, GLM DSA scheduler, CPU backend, or sanitizer configuration. Existing issues #2403 and #2431 own the Windows aborts and GLM test leak, respectively.

All other executed PR jobs passed, including build-test-cpu, build-test-vulkan, build-newest-gcc, both container verification jobs, CUDA fat build, ARM64 CPU build, agent record, documentation, commit protocol, and PR size. The exact ROCm focused gate and real-checkpoint gate remain PASS as recorded in the body.

…ec header extraction

main moved the four device half/bfloat16 conversions out of
rocm_grouped_gemm.hip into vt/rocm/rocm_f16_codec.h when BACKEND-ROCM-EXL3
needed two of them for the trellis decode. This branch adds an include of
vt/rocm/rocm_runtime.h at the same line, so the two additions collided
textually while agreeing semantically.

Resolved by keeping BOTH includes. The header declares the four helpers in
namespace vt::rocm, which is the namespace this translation unit's code already
sits in, so the 16 unqualified uses across the cooperative Q8_K work still
resolve. The conflict was one line on each side and no other hunk in the file
was contested: the merge otherwise takes main's Fmt==3 Q6_K small-private arm,
Q6KSmallPrivateEnabled and its dispatch, and the IQ3_S spelling in the
unsupported-dtype message, alongside this branch's Q8_K cooperative kernel and
its witness counter.

Not verified by compilation. This host has no hipcc, and no CI lane here builds
a .hip translation unit, so this resolution is checked by symbol and namespace
resolution and by confirming the file's brace balance is unchanged. The ROCm
arm rests on the contributor's own gfx1100 evidence.

FOLLOWING_AGENTS_PROTOCOL

Following-Agents-Protocol: true
AI-Assisted: true
Assisted-by: claude-code:claude-opus-5 [Claude Code]
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