Skip to content

feat(pcie_dma): add block-INT8 wire modes to b12x v20#69

Closed
yatesdr wants to merge 1 commit into
local-inference-lab:masterfrom
yatesdr:feat/sparkinfer-v20-int8-wire
Closed

feat(pcie_dma): add block-INT8 wire modes to b12x v20#69
yatesdr wants to merge 1 commit into
local-inference-lab:masterfrom
yatesdr:feat/sparkinfer-v20-int8-wire

Conversation

@yatesdr

@yatesdr yatesdr commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Ports the block-INT8 PCIe-DMA wire modes from #46 onto current b12x master for the GLM-5.2 v20 stack. The repository has been renamed back to b12x; its current Python distribution and source namespace remain sparkinfer, so the implementation paths in this PR are under sparkinfer/.

  • i8: BF16 reduce-scatter plus block-INT8 all-gather
  • i8_ring: block-INT8 reduce-scatter ring plus block-INT8 all-gather
  • i8_a2a: quantize-once block-INT8 all-to-all plus block-INT8 broadcast

Each 128-value block uses 128 signed payload bytes and one FP32 scale, so INT8 uses the same 132-byte wire and staging layout as E4M3. Existing BF16 and E4M3 routes are unchanged.

This is a clean replacement for #46, whose head predates the b12x/ to sparkinfer/ source-namespace migration and is now conflicting with master.

Why

GLM-5.2 long-context validation isolated a residual E4M3 representation loss after the rank-consistency fix in #44:

Wire mode 300k 350k
E4M3 AG 0/3 0/3
block-INT8 AG 3/3 3/3

All INT8 topologies later passed needle retrieval through 475k. On the tested TP4/DCP4 PCIe system, i8_ring reached 1,641 tok/s cold prefill at 50k, matching E4M3 ring at 1,639 tok/s, while retaining the full 644,864-token KV pool. Full historical evidence remains in #46.

V20 integration

The published v20 artifact pins the b12x runtime commit 6a92bcc0f2bf03b13dd03dbc7ce97e26133c580e, which contains E4M3 ag, ring, and a2a but not the INT8 codec. The complete patch in this PR passes git apply --check against that exact release commit without conflicts.

The v20 launcher currently validates only F8_DMA=0|ag|ring; accepting i8, i8_ring, and i8_a2a belongs in the separate blackwell-llm-docker integration repository after this runtime support is available.

Implementation

  • Adds BF16-to-signed-INT8 quantization with one FP32 scale per 128 values.
  • Adds INT8-to-BF16 materialization.
  • Adds multi-source INT8 dequantization with FP32 accumulation for A2A.
  • Adds fused INT8 dequantize-add-requantize for ring reduce-scatter hops.
  • Routes all three topologies through the matching codec while preserving rank-invariant eligibility.
  • Materializes the owner shard from the same canonical payload forwarded to peers.
  • Extends eager, graph-replay, and four-rank bit-identity gates.
  • Documents topology, eligibility, wire size, and selection guidance.

Validation

Completed locally on current master:

Previously completed on the target four-GPU system for the same codec implementation:

Pending before this draft is marked ready:

  • build against the exact v20 image stack
  • rerun four-rank eager and graph identity gates
  • rerun 300k, 350k, and 475k needles
  • confirm wire mode: int8-ring, throughput, KV pool, and zero restarts

Files

  • sparkinfer/comm/pcie/pcie_dma.cu
  • sparkinfer/comm/pcie/pcie_dma.py
  • tests/comm/test_pcie_dma_gpu.py
  • tests/comm/test_pcie_dma_rank_consistency_gpu.py
  • tests/comm/test_pcie_dma_int8_codec.py
  • README.md

Signed-off-by: Derek Yates derek.yates@live.com

Summary by CodeRabbit

  • New Features

    • Added signed INT8 compressed wire modes for PCIe DMA all-reduce.
    • Supports ring, all-gather, and all-to-all INT8 configurations, including aliases and environment-variable setup.
    • Added documentation covering supported modes, configuration, compression behavior, and usage examples.
  • Tests

    • Expanded GPU coverage for all compressed wire modes.
    • Added INT8 codec validation, round-trip accuracy, layout, zero-value, and rank-consistency checks.

Signed-off-by: derek <derek.yates@live.com>
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

PCIe DMA compressed wire support now includes block-scaled signed INT8 quantization across ring, all-gather, and all-to-all modes, with updated CUDA kernels, transport routing, documentation, and tests.

PCIe DMA INT8 compressed communication

Layer / File(s) Summary
INT8 codec kernels and bindings
sparkinfer/comm/pcie/pcie_dma.cu
Adds signed INT8 quantization, dequantization, accumulation, requantization kernels, host wrappers, and Python bindings.
Compressed mode selection and public configuration
sparkinfer/comm/pcie/pcie_dma.py, README.md
Normalizes INT8 aliases, assigns INT8 wire identifiers, and documents supported compressed wire modes and constraints.
Compressed all-reduce execution
sparkinfer/comm/pcie/pcie_dma.py
Routes INT8 kernels through ring, all-gather, and all-to-all scheduling, including compressed forwarding and BF16 materialization.
INT8 and compressed-mode validation
tests/comm/test_pcie_dma_int8_codec.py, tests/comm/test_pcie_dma_mode.py, tests/comm/test_pcie_dma_gpu.py, tests/comm/test_pcie_dma_rank_consistency_gpu.py
Adds codec and mode-normalization tests, and expands GPU and rank-consistency coverage to INT8 modes.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant PCIeDmaAllReduce
  participant _all_reduce_fp8
  participant INT8Kernels
  participant BF16Output
  Caller->>PCIeDmaAllReduce: select i8, i8_ring, or i8_a2a
  PCIeDmaAllReduce->>_all_reduce_fp8: route compressed all-reduce
  _all_reduce_fp8->>INT8Kernels: quantize and exchange INT8 payloads
  INT8Kernels->>BF16Output: dequantize reduced results
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding block-INT8 PCIe-DMA wire modes.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@yatesdr yatesdr changed the title feat(pcie_dma): add block-INT8 wire modes to SparkInfer feat(pcie_dma): add block-INT8 wire modes to b12x v20 Jul 22, 2026
@yatesdr
yatesdr marked this pull request as ready for review July 22, 2026 18:30

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
sparkinfer/comm/pcie/pcie_dma.py (1)

72-92: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Silent fallback to "ag" on unrecognized mode strings.

Any misspelled SPARKINFER_PCIE_DMA_FP8 value (e.g. i8_rnig) silently normalizes to "ag" (Line 92) rather than raising, so a typo intending INT8 quantization silently falls back to the FP8 E4M3 codec with only a debug log line as evidence. Now that this function accepts a much larger set of i8/int8 aliases, the odds of an unnoticed typo changing the wire codec in production increase.

♻️ Proposed fix: raise on unrecognized non-empty values
-    if raw in ("i8_a2a", "i8-a2a", "int8_a2a", "int8-a2a", "a2a_i8"):
-        return "i8_a2a"
-    return "ag"
+    if raw in ("i8_a2a", "i8-a2a", "int8_a2a", "int8-a2a", "a2a_i8"):
+        return "i8_a2a"
+    if raw in ("ag", "1"):
+        return "ag"
+    raise ValueError(f"unrecognized SPARKINFER_PCIE_DMA_FP8 mode: {value!r}")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@sparkinfer/comm/pcie/pcie_dma.py` around lines 72 - 92, Update
_normalize_fp8_mode to raise an appropriate error for any unrecognized non-empty
mode value instead of returning "ag"; preserve the existing normalization for
supported aliases and the empty/false values that disable the mode.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@sparkinfer/comm/pcie/pcie_dma.py`:
- Around line 72-92: Update _normalize_fp8_mode to raise an appropriate error
for any unrecognized non-empty mode value instead of returning "ag"; preserve
the existing normalization for supported aliases and the empty/false values that
disable the mode.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f09fe0f7-ab7d-4fd8-8944-15e294162013

📥 Commits

Reviewing files that changed from the base of the PR and between d4f82a6 and d6f0baa.

📒 Files selected for processing (6)
  • README.md
  • sparkinfer/comm/pcie/pcie_dma.cu
  • sparkinfer/comm/pcie/pcie_dma.py
  • tests/comm/test_pcie_dma_gpu.py
  • tests/comm/test_pcie_dma_int8_codec.py
  • tests/comm/test_pcie_dma_rank_consistency_gpu.py

@voipmonitor voipmonitor changed the title feat(pcie_dma): add block-INT8 wire modes to b12x v20 feat(pcie_dma): add block-INT8 wire modes Jul 22, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/comm/test_pcie_dma_mode.py (1)

10-29: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Cover the complete INT8 alias contract.

The implementation in sparkinfer/comm/pcie/pcie_dma.py, Lines 72-94, accepts canonical i8, i8_ring, and i8_a2a values plus additional aliases, but this test does not exercise the canonical INT8 values and covers only a subset of accepted spellings. Parameterize the full alias table, including at least one whitespace/case-normalization case.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/comm/test_pcie_dma_mode.py` around lines 10 - 29, Expand
test_supported_wire_mode_aliases to cover the complete INT8 alias contract from
_normalize_fp8_mode, including canonical i8, i8_ring, and i8_a2a values plus
every accepted INT8 alias. Add at least one input with surrounding whitespace
and mixed case, asserting it normalizes to the expected canonical value while
preserving the existing non-INT8 cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@tests/comm/test_pcie_dma_mode.py`:
- Around line 10-29: Expand test_supported_wire_mode_aliases to cover the
complete INT8 alias contract from _normalize_fp8_mode, including canonical i8,
i8_ring, and i8_a2a values plus every accepted INT8 alias. Add at least one
input with surrounding whitespace and mixed case, asserting it normalizes to the
expected canonical value while preserving the existing non-INT8 cases.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5a702d96-9eb7-472b-81a0-f2e994af5e8a

📥 Commits

Reviewing files that changed from the base of the PR and between d6f0baa and edf199d.

📒 Files selected for processing (3)
  • sparkinfer/comm/pcie/pcie_dma.py
  • tests/comm/test_pcie_dma_int8_codec.py
  • tests/comm/test_pcie_dma_mode.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/comm/test_pcie_dma_int8_codec.py
  • sparkinfer/comm/pcie/pcie_dma.py

@voipmonitor
voipmonitor force-pushed the feat/sparkinfer-v20-int8-wire branch from a43ef01 to d6f0baa Compare July 22, 2026 20:41
@voipmonitor voipmonitor changed the title feat(pcie_dma): add block-INT8 wire modes feat(pcie_dma): add block-INT8 wire modes to b12x v20 Jul 22, 2026
@voipmonitor

Copy link
Copy Markdown
Contributor

Superseded by #72, which preserves the block-INT8 implementation and adds the validated standard MXFP8 wire modes, including mx_ring. Closing this PR without deleting the contributor branch so its history remains available.

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