Repository navigation
hrx: claim a standalone f32 PERMUTE whose result owns its storage (TSPECTREE phase (a)) - #136
bong-water-water-bong wants to merge 1 commit into
Conversation
…PECTREE phase (a), item 1) The DFlash2 drafter's encoder and decoder permute activations between head-major and token-major layouts, and llama.cpp's graph leaves those as `GGML_OP_PERMUTE` nodes. Our dispatcher has no registration for `PERMUTE` at all, so any permuted value not followed by a `CONT` is placed on the CPU — one graph split per draft, on the graph we are about to put on the HRX path. A permute does not move data: the result is a view whose strides travel with the dims. So the materialised case (the permuted value owns a contiguous destination buffer) is exactly the strided-source copy that `register_copy_dispatch` already performs for `CONT`, and this reuses the same kernel and parameter set. Because a permute carries each dimension's stride along with the dimension, the destination's `nb[i]` *is* the source stride to read for destination dim `i`, so no axes have to be recovered from `op_params` (which `OpParams` does not carry for `PERMUTE` anyway). Scope, deliberately narrow: - claimed: f32 → f32, output contiguous and packed, same element count and byte count as the source, distinct storage, element strides representable, ≤ 2^30 elements; - **not** claimed: the view form (source and output share storage). That value has no destination buffer, so the materialisation belongs to the following `CONT` — which is already lowered through the same kernel — and claiming it here would need a copy that writes through a permuted *destination* layout. That is a kernel-side variant, written up in `~/briefs/TSPECTREE-STATE.md` under "kernel asks" and handed to gpu-kernels rather than done here. So this fires only where the graph already materialises the permute, and declines everything else to the existing behaviour (CPU). It is the correct hook point for the kernel-side variant later, and it cannot change the result of any graph that works today. **Untested on device**: the lane belongs to the leaderboard, so this has not been compiled or run yet. Build check and the drafter measurement are the first things after "lane shared" / "leaderboard done". 🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
Review (orchestrator): right hook point and correctly narrow (materialised f32 permute only, view form declined to the following CONT, nothing today's graphs do changes). Our code in our own files. Stays a draft until it compiles with GGML_HRX=ON on strixhalo at 'lane shared' and hrx-backend-test passes at 'leaderboard done'; the kernel-side permuted-destination variant goes to gpu-kernels from the state file's 'kernel asks'. |
|
Build check, at the pin ( Green, and the new translation unit links into |
|
Superseded: the DFlash2 drafter graph now runs with 0 nodes off HRX under strict placement (fork #139 port + #140, private gpu-kernels #34 for the selector ops: TOP_K, FILL, GET_ROWS, I32 CPY/CONT); its PERMUTE nodes are handled on that path, so the standalone f32 PERMUTE registration is no longer needed for the drafter. Closing; reopen if a model surfaces a standalone PERMUTE that still falls to the CPU. |
hrx: claim a standalone f32 PERMUTE whose result owns its storage (TSPECTREE phase (a), item 1)
The DFlash2 drafter's encoder and decoder permute activations between head-major and token-major layouts,
and llama.cpp's graph leaves those as
GGML_OP_PERMUTEnodes. Our dispatcher has no registration forPERMUTEat all, so any permuted value not followed by aCONTis placed on the CPU — one graph split perdraft, on the graph we are about to put on the HRX path.
A permute does not move data: the result is a view whose strides travel with the dims. So the materialised
case (the permuted value owns a contiguous destination buffer) is exactly the strided-source copy that
register_copy_dispatchalready performs forCONT, and this reuses the same kernel and parameter set.Because a permute carries each dimension's stride along with the dimension, the destination's
nb[i]isthe source stride to read for destination dim
i, so no axes have to be recovered fromop_params(whichOpParamsdoes not carry forPERMUTEanyway).Scope, deliberately narrow:
storage, element strides representable, ≤ 2^30 elements;
the materialisation belongs to the following
CONT— which is already lowered through the same kernel — andclaiming it here would need a copy that writes through a permuted destination layout. That is a
kernel-side variant, written up in
~/briefs/TSPECTREE-STATE.mdunder "kernel asks" and handed togpu-kernels rather than done here.
So this fires only where the graph already materialises the permute, and declines everything else to the
existing behaviour (CPU). It is the correct hook point for the kernel-side variant later, and it cannot
change the result of any graph that works today.
Untested on device: the lane belongs to the leaderboard, so this has not been compiled or run yet. Build
check and the drafter measurement are the first things after "lane shared" / "leaderboard done".
🤖 Generated with Claude Code