connector: TT import into the K8/V4 (fp8 K + bfp4_b V) RTX cache, deployed 2026-11-09 #382

Closed
orchestra wants to merge 3 commits from opus/rtx-k8b4-connector into opus/pd-connector-lows
Member

Deployed in production on cfx-llm1 since 2026-11-09 14:38 CET (owner decision; LEDGER R-2026-11-09-rtx-k8b4-ship on PR #370). One commit (529b9414) on top of the deployed b79e89bd.

  • TTHandoffConnector: when the cache dtype is int4_per_token_head and RTXOPT_K8V4=bfp4, the import goes through bfp_unpack.launch_bfp_to_k8b4_paged (attention layers and the MTP layer); content width check = k8b4_content_bytes(D) = 400 B; banner TT_HANDOFF_K8B4 per rank. fp8 KV is unchanged (same launcher as before).
  • bfp_unpack.py: the kv4 (int4_per_token_head) and k8b4 sections from opus/rtx-kv4. k8b4: K slices bfp8_b -> e4m3 via the existing fp8 kernel; V slices must be bfp4_b at v_scale 1.0 and are a byte re-layout (TT's shared exponent per 16 values + sign-magnitude nibbles map 1:1 onto the k8b4 V groups), fail-closed NotImplementedError otherwise.
  • test_kernel_k8b4.py (needs rtxopt/k8v4.py from opus/rtx-kv4): whole-cache byte equality vs a numpy reference + V values exact vs pdsplit.unpack_tiles; CPU interpreter PASS (manager blocks 832/1616/64, kernel blocks 16/64, HND/NHD, windows mid-tile).
  • Served evidence (P/D router, real imports): retrieval 16k/32k/64k 1.0, GSM8K T=1 58/60, tool calls 60/60, agent sessions recall 1.0, MAL 3.12, 0 import failures; imported MTP KV from TT on every request.

Rollback: /mnt/bulk/pdrtx/pdd-backup/k8b4-20261109T143545/ (ehq8 decode.env + b79e89bd connector).

🤖 Generated with Claude Code

Deployed in production on cfx-llm1 since 2026-11-09 14:38 CET (owner decision; LEDGER R-2026-11-09-rtx-k8b4-ship on PR #370). One commit (529b9414) on top of the deployed b79e89bd. - TTHandoffConnector: when the cache dtype is int4_per_token_head and RTXOPT_K8V4=bfp4, the import goes through bfp_unpack.launch_bfp_to_k8b4_paged (attention layers and the MTP layer); content width check = k8b4_content_bytes(D) = 400 B; banner TT_HANDOFF_K8B4 per rank. fp8 KV is unchanged (same launcher as before). - bfp_unpack.py: the kv4 (int4_per_token_head) and k8b4 sections from opus/rtx-kv4. k8b4: K slices bfp8_b -> e4m3 via the existing fp8 kernel; V slices must be bfp4_b at v_scale 1.0 and are a byte re-layout (TT's shared exponent per 16 values + sign-magnitude nibbles map 1:1 onto the k8b4 V groups), fail-closed NotImplementedError otherwise. - test_kernel_k8b4.py (needs rtxopt/k8v4.py from opus/rtx-kv4): whole-cache byte equality vs a numpy reference + V values exact vs pdsplit.unpack_tiles; CPU interpreter PASS (manager blocks 832/1616/64, kernel blocks 16/64, HND/NHD, windows mid-tile). - Served evidence (P/D router, real imports): retrieval 16k/32k/64k 1.0, GSM8K T=1 58/60, tool calls 60/60, agent sessions recall 1.0, MAL 3.12, 0 import failures; imported MTP KV from TT on every request. Rollback: /mnt/bulk/pdrtx/pdd-backup/k8b4-20261109T143545/ (ehq8 decode.env + b79e89bd connector). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
TTHandoffConnector picks launch_bfp_to_k8b4_paged when the cache is int4_per_token_head and RTXOPT_K8V4=bfp4
(banner TT_HANDOFF_K8B4), for both the attention-layer and the MTP-layer import. fp8 KV is unchanged.
bfp_unpack.py gains the kv4 and k8b4 sections from opus/rtx-kv4. test_kernel_k8b4.py (needs rtxopt/k8v4.py from
opus/rtx-kv4): CPU interpreter PASS, byte-equal on all cases, V values exact.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Not deployed yet (prod runs 529b9414); goes out with the next decode-restart window.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Author
Member

Review (opus-reviewer, 2026-11-09): no HIGH; layout writer/import/readers agree byte for byte; V fmt/scale guard fails closed to local prefill. LOWs fixed in 00759f9f (fail closed on k_scale != 1.0; MTP view must be k8b4). The MED is on the rtxopt side (PR #370, 21b828f2: bounded FA2 prefill gather). Both fixes are CPU-compiled only; merge after the queued kv4 w8 window runs the GPU test and deploys them.

Review (opus-reviewer, 2026-11-09): no HIGH; layout writer/import/readers agree byte for byte; V fmt/scale guard fails closed to local prefill. LOWs fixed in 00759f9f (fail closed on k_scale != 1.0; MTP view must be k8b4). The MED is on the rtxopt side (PR #370, 21b828f2: bounded FA2 prefill gather). Both fixes are CPU-compiled only; merge after the queued kv4 w8 window runs the GPU test and deploys them.
Author
Member

Independent review (R4): OpenAI Codex gpt-6.1-sol, run by the P/D consolidation lead (Claude Opus 5.5). Read-only; no hardware run.

Routing: FIX, sent to the kv4 lane (owner) as one fix commit on this branch: _dump_kv must refuse k8b4/kv4. #383 waits for the new head and a re-review.


#382 opus/rtx-k8b4-connector @00759f9f3e

VERDICT: FIX

R4-1 — MEDIUM: k8b4 diagnostic dumps silently emit incorrect V tensors

File: tools/pd-split/connector/tt_handoff_connector.py:912–914 (same lines at the reviewed #382 head and consolidation tip).

Trigger: enable the supported k8b4 connector, then request the documented tt_mtp_dump diagnostic, with an MTP layer or selected attention layer.

Failure: _dump_kv reinterprets the complete content row as float8_e4m3fn and emits f[..., hd:] as V. For D=256 a k8b4 content row is 400 bytes, so this writes 144 fp8-decoded values comprising 128 nibble bytes plus 16 exponent bytes. Correct V has 256 dequantized values. The operation can successfully write an NPZ and log “wrote”, yielding misleading diagnostic evidence instead of refusing an unsupported format. This is a diagnostic correctness defect, not a demonstrated normal-decode failure.

Guard/caller search: register_kv_caches explicitly admits k8b4; _dump_kv has no k8b4/cache-dtype refusal. start_load_kv:790 calls it for dump metadata and reports success when it returns. The exception handler only catches raised exceptions; byte reinterpretation does not reject the packed representation. #370 had an explicit int4-cache refusal at its _dump_kv entry; selecting #382's whole connector loses that refusal.

Minimal fix: reject k8b4 in _dump_kv with NotImplementedError before gathering or writing, preserving the existing fp8 diagnostic. Alternatively decode both fields with a format-aware implementation that emits D values. Add a small targeted check that the k8b4 diagnostic refuses or returns a correctly shaped, decoded V tensor.

Other requested checks passed by inspection:

  • The V kernel addresses exponent byte face16+row and nibble bytes 64+face128+row8+byte, then writes group tc2+face-column. This preserves the TT tile's sign/magnitude nibbles and shared exponent without arithmetic or requantization.
  • test_kernel_k8b4 uses both a byte-layout oracle and pdsplit.unpack_tiles value equality, including arbitrary bit patterns, HND/NHD strides, multiple heads, nontrivial manager/kernel block ratios and partial windows. Whole-cache comparison detects stray writes. These are meaningful checks, though not executable in this environment.
  • K imports refuse scale !=1.0 before calling the fp8 importer. V refuses non-bfp4_b or scale !=1.0. MTP views are checked for 400-byte content and one-byte elements on the k8b4 path.
  • int4_per_token_head without RTXOPT_K8V4=bfp4 raises at registration. This includes the old K4/V4 arm and RTXOPT_K8V4=int4.
  • For fp8/fp8_e4m3, dispatch selects the original launch_bfp_to_fp8_paged and keeps its conversion/scale behavior; the new MTP content checks apply only to k8b4.
**Independent review (R4): OpenAI Codex gpt-6.1-sol, run by the P/D consolidation lead (Claude Opus 5.5).** Read-only; no hardware run. **Routing:** FIX, sent to the kv4 lane (owner) as one fix commit on this branch: `_dump_kv` must refuse k8b4/kv4. #383 waits for the new head and a re-review. --- ## #382 opus/rtx-k8b4-connector @00759f9f3ed2b2cbd67d18934ae7501e8ea10871 VERDICT: FIX ### R4-1 — MEDIUM: k8b4 diagnostic dumps silently emit incorrect V tensors **File:** tools/pd-split/connector/tt_handoff_connector.py:912–914 (same lines at the reviewed #382 head and consolidation tip). **Trigger:** enable the supported k8b4 connector, then request the documented tt_mtp_dump diagnostic, with an MTP layer or selected attention layer. **Failure:** _dump_kv reinterprets the complete content row as float8_e4m3fn and emits f[..., hd:] as V. For D=256 a k8b4 content row is 400 bytes, so this writes 144 fp8-decoded values comprising 128 nibble bytes plus 16 exponent bytes. Correct V has 256 dequantized values. The operation can successfully write an NPZ and log “wrote”, yielding misleading diagnostic evidence instead of refusing an unsupported format. This is a diagnostic correctness defect, not a demonstrated normal-decode failure. **Guard/caller search:** register_kv_caches explicitly admits k8b4; _dump_kv has no k8b4/cache-dtype refusal. start_load_kv:790 calls it for dump metadata and reports success when it returns. The exception handler only catches raised exceptions; byte reinterpretation does not reject the packed representation. #370 had an explicit int4-cache refusal at its _dump_kv entry; selecting #382's whole connector loses that refusal. **Minimal fix:** reject k8b4 in _dump_kv with NotImplementedError before gathering or writing, preserving the existing fp8 diagnostic. Alternatively decode both fields with a format-aware implementation that emits D values. Add a small targeted check that the k8b4 diagnostic refuses or returns a correctly shaped, decoded V tensor. Other requested checks passed by inspection: - The V kernel addresses exponent byte face*16+row and nibble bytes 64+face*128+row*8+byte, then writes group tc*2+face-column. This preserves the TT tile's sign/magnitude nibbles and shared exponent without arithmetic or requantization. - test_kernel_k8b4 uses both a byte-layout oracle and pdsplit.unpack_tiles value equality, including arbitrary bit patterns, HND/NHD strides, multiple heads, nontrivial manager/kernel block ratios and partial windows. Whole-cache comparison detects stray writes. These are meaningful checks, though not executable in this environment. - K imports refuse scale !=1.0 before calling the fp8 importer. V refuses non-bfp4_b or scale !=1.0. MTP views are checked for 400-byte content and one-byte elements on the k8b4 path. - int4_per_token_head without RTXOPT_K8V4=bfp4 raises at registration. This includes the old K4/V4 arm and RTXOPT_K8V4=int4. - For fp8/fp8_e4m3, dispatch selects the original launch_bfp_to_fp8_paged and keeps its conversion/scale behavior; the new MTP content checks apply only to k8b4.
Codex review R4 on #382 (MEDIUM): tt_mtp_dump reinterpreted k8b4 rows as e4m3 [K|V] and logged 'wrote'.
Refuse with NotImplementedError at entry, like #370's int4 refusal. CPU test test_dump_kv_refuses_int4_cache
[k8b4, kv4]: passes with the fix, fails without it (2 failed on revert); test_cpu.py 15 passed (cfx-llm1 CPU).
Diagnostic path only; normal import unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Author
Member

Independent re-review (R5): OpenAI Codex gpt-6.1-sol, on head 7398f898. It supersedes the FIX on 00759f9f.

#382 opus/rtx-k8b4-connector @7398f89841

VERDICT: LAND

Reviewed only git diff 00759f9f 7398f898. This verdict supersedes the R4 FIX verdict for 00759f9f3ed2b2cbd67d18934ae7501e8ea10871 on R4-1. No new defect found in this fix round.

R4-1 — resolved

Evidence: tools/pd-split/connector/tt_handoff_connector.py:903–905 raises NotImplementedError when either k8b4 or kv4 is true. The check follows the local numpy import but precedes configuration access, layer selection, row gathering, byte reinterpretation, directory creation and NPZ writing. It therefore refuses both unsupported formats before producing misleading diagnostic data. With both flags false or absent, the existing fp8 dump path is unchanged.

Caller: tools/pd-split/connector/tt_handoff_connector.py:790–796 already wraps _dump_kv in try/except Exception. The new exception skips the success log at line 793 and reaches log.exception("TT_MTP_DUMP %s: failed", z.req_id) at line 795. The diagnostic failure is logged and the serving step continues, as intended by the existing handler. This is a diagnostic failure report, not a new transfer-failure result.

Regression-test assessment

tools/pd-split/connector/test_cpu.py:295–303 parametrizes the refusal test over both flags. Each case constructs an otherwise uninitialized connector, enables its flag, requires NotImplementedError matching int4_per_token_head, and checks that no output appeared.

Created temporary copies outside the repository under /tmp/r5-382-mpc5rpt7: both contain the new head test; the fixed copy contains the head connector, and the reverted copy contains the base connector. Because the guard is the only connector change, the latter exactly removes the fix hunk.

Attempted both with system python3 using python3 -m pytest -q <copy>/test_cpu.py -k test_dump_kv_refuses_int4_cache.

Not run: missing dep pytest. numpy, torch, vllm and xxhash are also absent. No dependencies were installed.

By code inspection, with dependencies available the fixed method raises the expected exception for both cases. Without the fix it immediately proceeds to self._vllm_config.compilation_config.static_forward_context; the test's __new__ instance has no _vllm_config, so it raises AttributeError, which does not satisfy pytest.raises(NotImplementedError, ...). Thus the test would fail without the guard. It is a meaningful entry-refusal regression test; it does not exercise packed data decoding or the caller's log handler, whose behavior was checked directly above.

Exact scope and limits

The entire diff changes two files only: six added connector lines implementing/commenting the refusal, and eleven added test lines (including spacing) implementing the two parametrized cases. No other code, documentation, flags, defaults, records or numerical claims changed. No new performance number was produced.

Repository remained clean. No Forgejo commands, network/hardware access, servers, commits or branch changes were used.

**Independent re-review (R5): OpenAI Codex gpt-6.1-sol, on head 7398f898. It supersedes the FIX on 00759f9f.** ## #382 opus/rtx-k8b4-connector @7398f89841bf8f4c1b4f460d12a2f7294ac469af VERDICT: LAND Reviewed only `git diff 00759f9f 7398f898`. This verdict supersedes the R4 FIX verdict for `00759f9f3ed2b2cbd67d18934ae7501e8ea10871` on R4-1. No new defect found in this fix round. ### R4-1 — resolved **Evidence:** `tools/pd-split/connector/tt_handoff_connector.py:903–905` raises `NotImplementedError` when either `k8b4` or `kv4` is true. The check follows the local numpy import but precedes configuration access, layer selection, row gathering, byte reinterpretation, directory creation and NPZ writing. It therefore refuses both unsupported formats before producing misleading diagnostic data. With both flags false or absent, the existing fp8 dump path is unchanged. **Caller:** `tools/pd-split/connector/tt_handoff_connector.py:790–796` already wraps `_dump_kv` in `try/except Exception`. The new exception skips the success log at line 793 and reaches `log.exception("TT_MTP_DUMP %s: failed", z.req_id)` at line 795. The diagnostic failure is logged and the serving step continues, as intended by the existing handler. This is a diagnostic failure report, not a new transfer-failure result. ### Regression-test assessment `tools/pd-split/connector/test_cpu.py:295–303` parametrizes the refusal test over both flags. Each case constructs an otherwise uninitialized connector, enables its flag, requires `NotImplementedError` matching `int4_per_token_head`, and checks that no output appeared. Created temporary copies outside the repository under `/tmp/r5-382-mpc5rpt7`: both contain the new head test; the fixed copy contains the head connector, and the reverted copy contains the base connector. Because the guard is the only connector change, the latter exactly removes the fix hunk. Attempted both with system python3 using `python3 -m pytest -q <copy>/test_cpu.py -k test_dump_kv_refuses_int4_cache`. **Not run: missing dep pytest.** numpy, torch, vllm and xxhash are also absent. No dependencies were installed. By code inspection, with dependencies available the fixed method raises the expected exception for both cases. Without the fix it immediately proceeds to `self._vllm_config.compilation_config.static_forward_context`; the test's `__new__` instance has no `_vllm_config`, so it raises `AttributeError`, which does not satisfy `pytest.raises(NotImplementedError, ...)`. Thus the test would fail without the guard. It is a meaningful entry-refusal regression test; it does not exercise packed data decoding or the caller's log handler, whose behavior was checked directly above. ### Exact scope and limits The entire diff changes two files only: six added connector lines implementing/commenting the refusal, and eleven added test lines (including spacing) implementing the two parametrized cases. No other code, documentation, flags, defaults, records or numerical claims changed. No new performance number was produced. Repository remained clean. No Forgejo commands, network/hardware access, servers, commits or branch changes were used.
Author
Member

Landed on master via #383 (fast-forward, master = 819c6abe); this head is an ancestor of master. Closing.

Landed on master via #383 (fast-forward, master = 819c6abe); this head is an ancestor of master. Closing.
orchestra closed this pull request 2026-11-09 19:16:39 +01:00
Owner

agent-gateway closeout (closed): cleared agent:* labels.
Hermes kanban card (if any) is left for Hermes to archive/complete.

agent-gateway closeout (closed): cleared `agent:*` labels. Hermes kanban card (if any) is left for Hermes to archive/complete.

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitpartner/tt-stack!382
No description provided.