Archived
Merge upstream main (v1.12 -> v1.15.1, 408 commits) into the SYCL port
Conflicts from the old m2xfp branch take upstream's version. Two libxe2 fixes the merge needs:
- rad_plugin_abi_layout: the plugin now exports the ABI layout hash the loader checks.
- gemm_nt_q_w4a16: upstream 492d33c sends bf16 activations to the w4a16 GEMM (the separate cast
is gone); the fast kernel took only f16, so every call fell back to the exact path (decode
~2.5 tok/s). A bf16 activation is narrowed to f16 (round to nearest even) into a workspace first,
the dropped cast bit for bit; decode back to ~57 tok/s on one request.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
7580ec3d17
937 files changed
+285776
-8914
No files matched your search
+25
-8
@@ -13,12 +13,15 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* Bumped whenever anything a plugin compiles against changes shape: this header, rad_types.h,
|
||||
* rad_builder.h, rad_runtime.h, rad_device.h, rad_encoding.h, rad_quant.h or rad_sample.h. Every
|
||||
* kind of plugin reports it, and a plugin that does not report exactly this version is refused at
|
||||
* load with both versions printed. A new optional export (e.g. rad_plugin_reference) is not a
|
||||
* change of shape: a plugin without it gets the default. rad_sycl.h is versioned on its own
|
||||
* (RAD_SYCL_STREAM_VERSION), since only SYCL kernel libraries read it. */
|
||||
#define RAD_ABI_VERSION 26u
|
||||
* rad_builder.h, rad_runtime.h, rad_device.h, rad_encoding.h, rad_quant.h, rad_sample.h or
|
||||
* rad_spechub.h, a field appended to a struct included; the release that ships the change assigns
|
||||
* the number. Every kind of plugin reports it, and a plugin that does not report exactly this
|
||||
* version is refused at load with both versions printed. Each also exports the layout's fingerprint
|
||||
* (rad_abi_layout.h), so two layouts given one number are refused as well. A new optional export
|
||||
* (e.g. rad_plugin_reference) is not a change of shape: a plugin without it gets the default.
|
||||
* rad_sycl.h is versioned on its own (RAD_SYCL_STREAM_VERSION), since only SYCL kernel libraries
|
||||
* read it. */
|
||||
#define RAD_ABI_VERSION 32u
|
||||
|
||||
/* ================================================================== plugin identity */
|
||||
/* One value per plugin, not flags (QUANT is 3). RAD_PLUGIN_QUANT is a quantiser plugin:
|
||||
@@ -36,8 +39,10 @@ typedef struct RadPluginInfo {
|
||||
const char* build_target;
|
||||
} RadPluginInfo;
|
||||
|
||||
/* Every plugin exports these two. */
|
||||
/* Every plugin exports these three; rad_plugin_abi_layout is RAD_PLUGIN_ABI_LAYOUT_EXPORT
|
||||
* (rad_abi_layout.h). */
|
||||
uint32_t rad_plugin_abi_version(void);
|
||||
uint64_t rad_plugin_abi_layout(void);
|
||||
const RadPluginInfo* rad_plugin_info(void);
|
||||
|
||||
/* ================================================================== execution domain */
|
||||
@@ -550,9 +555,21 @@ typedef int (*RadKernelCollectiveFn)(int i);
|
||||
* - the engine refuses to serve a model with an op only a reference library implements, unless
|
||||
* given --debug-accept-reference-kernels;
|
||||
* - rad-kbench checks every other library against it.
|
||||
* Without the symbol, or with 0, it is an ordinary library. Symbol name: `rad_plugin_reference`. */
|
||||
* Without the symbol, or with 0, it is an ordinary library. Symbol name: `rad_plugin_reference`.
|
||||
*
|
||||
* It is a whole-library answer, because a library is usually one implementation of one thing. A
|
||||
* plugin that ships a device row AND the host oracle beside it is not: marking the library would
|
||||
* mark its device rows too, and the engine would refuse to serve an op that has a real kernel.
|
||||
* Such a plugin exports `rad_kernel_reference` below and leaves this one 0. */
|
||||
typedef int (*RadPluginReferenceFn)(void);
|
||||
|
||||
/* Optional, per row: nonzero says kernel `i` of rad_kernel_at is that row's reference
|
||||
* implementation. Overrides `rad_plugin_reference` for the rows it is exported for, so one
|
||||
* library can declare a device row (0) and its host oracle (1) side by side. A plugin that
|
||||
* exports neither leaves every row classified by `rad_plugin_reference`. Symbol name:
|
||||
* `rad_kernel_reference`. */
|
||||
typedef int (*RadKernelReferenceFn)(int i);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/* rad_abi_layout.h -- the plugin ABI's layout fingerprint: a hash of the size of every struct abi/
|
||||
* exports and of the offset and size of each of its fields (rad_abi_layout_rows.h), as the
|
||||
* translation unit that includes this header sees them.
|
||||
*
|
||||
* RAD_ABI_VERSION names a layout, but two trees can give the same number to different layouts, and
|
||||
* a plugin built against one then reads the other's structs at the wrong offsets, with no error. A
|
||||
* plugin exports its own fingerprint (RAD_PLUGIN_ABI_LAYOUT_EXPORT, once in the plugin), and the
|
||||
* loader refuses one whose fingerprint differs from the engine's under the same version. C and C++.
|
||||
*/
|
||||
#ifndef RAD_ABI_LAYOUT_H
|
||||
#define RAD_ABI_LAYOUT_H
|
||||
|
||||
#include "rad_abi.h"
|
||||
#include "rad_builder.h"
|
||||
#include "rad_device.h"
|
||||
#include "rad_encoding.h"
|
||||
#include "rad_format.h"
|
||||
#include "rad_philox.h"
|
||||
#include "rad_planes.h"
|
||||
#include "rad_plugin.h"
|
||||
#include "rad_quant.h"
|
||||
#include "rad_runtime.h"
|
||||
#include "rad_sample.h"
|
||||
#include "rad_spechub.h"
|
||||
#include "rad_sycl.h"
|
||||
#include "rad_types.h"
|
||||
#include "rad_yarn.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* FNV-1a over the eight bytes of `v`, little end first. */
|
||||
static inline uint64_t rad_abi_layout_mix(uint64_t h, uint64_t v) {
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
h ^= (v >> (8 * i)) & 0xffu;
|
||||
h *= 0x100000001b3ull;
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
/* The fingerprint of the abi/ headers this translation unit was compiled against. */
|
||||
static inline uint64_t rad_abi_layout(void) {
|
||||
uint64_t h = 0xcbf29ce484222325ull;
|
||||
h = rad_abi_layout_mix(h, RAD_ABI_VERSION);
|
||||
#define ABI_STRUCT(T) h = rad_abi_layout_mix(h, sizeof(T));
|
||||
#define ABI_FIELD(T, f) \
|
||||
h = rad_abi_layout_mix(h, offsetof(T, f)); \
|
||||
h = rad_abi_layout_mix(h, sizeof(((T*)0)->f));
|
||||
#include "rad_abi_layout_rows.h"
|
||||
#undef ABI_STRUCT
|
||||
#undef ABI_FIELD
|
||||
return h;
|
||||
}
|
||||
|
||||
/* The export the loader reads beside rad_plugin_abi_version: written once in a plugin, at file
|
||||
* scope. */
|
||||
#ifdef __cplusplus
|
||||
#define RAD_PLUGIN_ABI_LAYOUT_EXPORT \
|
||||
extern "C" uint64_t rad_plugin_abi_layout(void) { return rad_abi_layout(); }
|
||||
#else
|
||||
#define RAD_PLUGIN_ABI_LAYOUT_EXPORT \
|
||||
uint64_t rad_plugin_abi_layout(void) { return rad_abi_layout(); }
|
||||
#endif
|
||||
|
||||
#endif /* RAD_ABI_LAYOUT_H */
|
||||
@@ -0,0 +1,900 @@
|
||||
/* rad_abi_layout_rows.h -- every struct abi/ exports and each of its top-level fields, as
|
||||
* ABI_STRUCT(type) and ABI_FIELD(type, field) lines; the includer defines both. rad_abi_layout.h
|
||||
* hashes them into the layout fingerprint every plugin exports, and tests/abi_c_test.c and
|
||||
* tests/abi_layout_test.cpp list them, so the C and C++ translation units see the same rows.
|
||||
*
|
||||
* A struct or field added to abi/ is added here too: abi_layout_test fails on a struct whose
|
||||
* listed fields do not account for its size. Included once per table, so it has no include guard.
|
||||
*/
|
||||
ABI_STRUCT(RadArchProbe)
|
||||
ABI_FIELD(RadArchProbe, draft_depth)
|
||||
ABI_FIELD(RadArchProbe, draft_depth_fixed)
|
||||
ABI_FIELD(RadArchProbe, shape_probe_ok)
|
||||
ABI_FIELD(RadArchProbe, enc_merge)
|
||||
ABI_FIELD(RadArchProbe, audio_frames)
|
||||
ABI_FIELD(RadArchProbe, gen_rows)
|
||||
ABI_FIELD(RadArchProbe, gen_patches)
|
||||
ABI_FIELD(RadArchProbe, gen_audio)
|
||||
ABI_FIELD(RadArchProbe, gen_ctx)
|
||||
ABI_FIELD(RadArchProbe, gen_video)
|
||||
ABI_FIELD(RadArchProbe, kv_quant_ok)
|
||||
ABI_FIELD(RadArchProbe, chain_pays)
|
||||
ABI_FIELD(RadArchProbe, kv_stream_ok)
|
||||
ABI_FIELD(RadArchProbe, control_vector_ok)
|
||||
ABI_FIELD(RadArchProbe, tp_attn_rows_ok)
|
||||
ABI_FIELD(RadArchProbe, state_f16_ok)
|
||||
ABI_FIELD(RadArchProbe, tree_pays)
|
||||
ABI_FIELD(RadArchProbe, gen_max_pixels)
|
||||
ABI_FIELD(RadArchProbe, gen_max_refs)
|
||||
ABI_STRUCT(RadArgs)
|
||||
ABI_FIELD(RadArgs, t)
|
||||
ABI_FIELD(RadArgs, n_t)
|
||||
ABI_FIELD(RadArgs, p)
|
||||
ABI_FIELD(RadArgs, n_p)
|
||||
ABI_FIELD(RadArgs, scratch)
|
||||
ABI_FIELD(RadArgs, scratch_bytes)
|
||||
ABI_FIELD(RadArgs, instance)
|
||||
ABI_FIELD(RadArgs, rank)
|
||||
ABI_FIELD(RadArgs, world_size)
|
||||
ABI_STRUCT(RadBatch)
|
||||
ABI_FIELD(RadBatch, phase)
|
||||
ABI_FIELD(RadBatch, step)
|
||||
ABI_FIELD(RadBatch, n_tok)
|
||||
ABI_FIELD(RadBatch, n_seq)
|
||||
ABI_FIELD(RadBatch, token_ids)
|
||||
ABI_FIELD(RadBatch, positions)
|
||||
ABI_FIELD(RadBatch, cu_seqlens)
|
||||
ABI_FIELD(RadBatch, seq_ids)
|
||||
ABI_FIELD(RadBatch, lora_slot)
|
||||
ABI_FIELD(RadBatch, n_out)
|
||||
ABI_FIELD(RadBatch, out_ids)
|
||||
ABI_FIELD(RadBatch, q_lens)
|
||||
ABI_FIELD(RadBatch, ctx_lens)
|
||||
ABI_FIELD(RadBatch, max_q_len)
|
||||
ABI_FIELD(RadBatch, max_ctx_len)
|
||||
ABI_FIELD(RadBatch, n_kv_groups)
|
||||
ABI_FIELD(RadBatch, kv)
|
||||
ABI_FIELD(RadBatch, n_spec)
|
||||
ABI_FIELD(RadBatch, num_accepted)
|
||||
ABI_FIELD(RadBatch, spec_parent)
|
||||
ABI_FIELD(RadBatch, draft_pass)
|
||||
ABI_FIELD(RadBatch, n_checkpoints)
|
||||
ABI_FIELD(RadBatch, checkpoint_tok)
|
||||
ABI_FIELD(RadBatch, checkpoint_slot)
|
||||
ABI_FIELD(RadBatch, n_seq_decode)
|
||||
ABI_FIELD(RadBatch, n_tok_decode)
|
||||
ABI_FIELD(RadBatch, max_q_len_decode)
|
||||
ABI_FIELD(RadBatch, max_q_len_prefill)
|
||||
ABI_FIELD(RadBatch, n_draft_out)
|
||||
ABI_FIELD(RadBatch, draft_out_ids)
|
||||
ABI_FIELD(RadBatch, n_ahead)
|
||||
ABI_FIELD(RadBatch, rope_pos)
|
||||
ABI_FIELD(RadBatch, rope_mixed)
|
||||
ABI_FIELD(RadBatch, n_mm_rows)
|
||||
ABI_FIELD(RadBatch, mm_rows)
|
||||
ABI_FIELD(RadBatch, mm_embd)
|
||||
ABI_FIELD(RadBatch, enc)
|
||||
ABI_FIELD(RadBatch, enc_n_patch)
|
||||
ABI_FIELD(RadBatch, enc_pixels)
|
||||
ABI_FIELD(RadBatch, enc_coord)
|
||||
ABI_FIELD(RadBatch, enc_n_seg)
|
||||
ABI_FIELD(RadBatch, enc_cu)
|
||||
ABI_FIELD(RadBatch, enc_max_seg)
|
||||
ABI_FIELD(RadBatch, gen)
|
||||
ABI_FIELD(RadBatch, gen_b)
|
||||
ABI_FIELD(RadBatch, agen_b)
|
||||
ABI_FIELD(RadBatch, vgen_b)
|
||||
ABI_FIELD(RadBatch, control_vector)
|
||||
ABI_FIELD(RadBatch, enc_seg_h)
|
||||
ABI_FIELD(RadBatch, enc_seg_w)
|
||||
ABI_FIELD(RadBatch, score_only)
|
||||
ABI_FIELD(RadBatch, n_plugin_words)
|
||||
ABI_FIELD(RadBatch, plugin_words)
|
||||
ABI_FIELD(RadBatch, plugin_cu)
|
||||
ABI_FIELD(RadBatch, plugin_words_h)
|
||||
ABI_FIELD(RadBatch, plugin_cu_h)
|
||||
ABI_STRUCT(RadBufDecl)
|
||||
ABI_FIELD(RadBufDecl, dtype)
|
||||
ABI_FIELD(RadBufDecl, rank)
|
||||
ABI_FIELD(RadBufDecl, shape)
|
||||
ABI_FIELD(RadBufDecl, kind)
|
||||
ABI_FIELD(RadBufDecl, domain)
|
||||
ABI_FIELD(RadBufDecl, derive)
|
||||
ABI_FIELD(RadBufDecl, kv)
|
||||
ABI_STRUCT(RadBuildCtx)
|
||||
ABI_FIELD(RadBuildCtx, rank)
|
||||
ABI_FIELD(RadBuildCtx, world_size)
|
||||
ABI_FIELD(RadBuildCtx, max_tok)
|
||||
ABI_FIELD(RadBuildCtx, max_seqs)
|
||||
ABI_FIELD(RadBuildCtx, max_ctx)
|
||||
ABI_FIELD(RadBuildCtx, max_spec)
|
||||
ABI_FIELD(RadBuildCtx, tp_wire_lossy)
|
||||
ABI_FIELD(RadBuildCtx, tp_wire_min_bytes)
|
||||
ABI_FIELD(RadBuildCtx, kv_dtype)
|
||||
ABI_FIELD(RadBuildCtx, is_draft)
|
||||
ABI_FIELD(RadBuildCtx, scope)
|
||||
ABI_FIELD(RadBuildCtx, shape_probe)
|
||||
ABI_FIELD(RadBuildCtx, max_enc_patches)
|
||||
ABI_FIELD(RadBuildCtx, max_out_rows)
|
||||
ABI_FIELD(RadBuildCtx, max_audio_frames)
|
||||
ABI_FIELD(RadBuildCtx, max_mixed_tok)
|
||||
ABI_FIELD(RadBuildCtx, kv_quant)
|
||||
ABI_FIELD(RadBuildCtx, attn_prefill_fp8)
|
||||
ABI_FIELD(RadBuildCtx, kv_resident_blocks)
|
||||
ABI_FIELD(RadBuildCtx, kv_stream_ok)
|
||||
ABI_FIELD(RadBuildCtx, cvec)
|
||||
ABI_FIELD(RadBuildCtx, tp_attn_rows)
|
||||
ABI_FIELD(RadBuildCtx, state_dtype)
|
||||
ABI_FIELD(RadBuildCtx, draft_coupling)
|
||||
ABI_FIELD(RadBuildCtx, weight_prefetch_off)
|
||||
ABI_FIELD(RadBuildCtx, draft_tree)
|
||||
ABI_FIELD(RadBuildCtx, calib_dir)
|
||||
ABI_FIELD(RadBuildCtx, calib_layer_lo)
|
||||
ABI_FIELD(RadBuildCtx, calib_layer_hi)
|
||||
ABI_FIELD(RadBuildCtx, calib_tokens)
|
||||
ABI_FIELD(RadBuildCtx, gen_max_pixels)
|
||||
ABI_FIELD(RadBuildCtx, gen_max_refs)
|
||||
ABI_STRUCT(RadAudioGenBatch)
|
||||
ABI_FIELD(RadAudioGenBatch, n_lane)
|
||||
ABI_FIELD(RadAudioGenBatch, lane)
|
||||
ABI_FIELD(RadAudioGenBatch, lane_h)
|
||||
ABI_FIELD(RadAudioGenBatch, last)
|
||||
ABI_FIELD(RadAudioGenBatch, last_h)
|
||||
ABI_FIELD(RadAudioGenBatch, frame)
|
||||
ABI_FIELD(RadAudioGenBatch, frame_h)
|
||||
ABI_FIELD(RadAudioGenBatch, seed)
|
||||
ABI_FIELD(RadAudioGenBatch, slot)
|
||||
ABI_FIELD(RadAudioGenBatch, last_row)
|
||||
ABI_FIELD(RadAudioGenBatch, prefix)
|
||||
ABI_FIELD(RadAudioGenBatch, t)
|
||||
ABI_FIELD(RadAudioGenBatch, t_next)
|
||||
ABI_FIELD(RadAudioGenBatch, cfg)
|
||||
ABI_FIELD(RadAudioGenBatch, pair)
|
||||
ABI_FIELD(RadAudioGenBatch, win_lane)
|
||||
ABI_FIELD(RadAudioGenBatch, win_lane_h)
|
||||
ABI_FIELD(RadAudioGenBatch, flags)
|
||||
ABI_FIELD(RadAudioGenBatch, flags_h)
|
||||
ABI_FIELD(RadAudioGenBatch, win_index)
|
||||
ABI_FIELD(RadAudioGenBatch, win_index_h)
|
||||
ABI_FIELD(RadAudioGenBatch, win_frame0)
|
||||
ABI_FIELD(RadAudioGenBatch, win_frame0_h)
|
||||
ABI_FIELD(RadAudioGenBatch, win_frames)
|
||||
ABI_FIELD(RadAudioGenBatch, win_frames_h)
|
||||
ABI_FIELD(RadAudioGenBatch, lat_rows)
|
||||
ABI_FIELD(RadAudioGenBatch, lat_cu)
|
||||
ABI_FIELD(RadAudioGenBatch, lat_cu_h)
|
||||
ABI_FIELD(RadAudioGenBatch, lat_src)
|
||||
ABI_FIELD(RadAudioGenBatch, voc_lane)
|
||||
ABI_FIELD(RadAudioGenBatch, voc_window)
|
||||
ABI_FIELD(RadAudioGenBatch, voc_latents)
|
||||
ABI_FIELD(RadAudioGenBatch, voc_left)
|
||||
ABI_FIELD(RadAudioGenBatch, voc_right)
|
||||
ABI_FIELD(RadAudioGenBatch, voc_frame0)
|
||||
ABI_FIELD(RadAudioGenBatch, prev_slot)
|
||||
ABI_FIELD(RadAudioGenBatch, prev_pos)
|
||||
ABI_FIELD(RadAudioGenBatch, prev_used)
|
||||
ABI_FIELD(RadAudioGenBatch, n_ref)
|
||||
ABI_FIELD(RadAudioGenBatch, ref_samples)
|
||||
ABI_FIELD(RadAudioGenBatch, ref_audio)
|
||||
ABI_FIELD(RadAudioGenBatch, ref_cu)
|
||||
ABI_FIELD(RadAudioGenBatch, ref_cu_h)
|
||||
ABI_FIELD(RadAudioGenBatch, ref_frame)
|
||||
ABI_FIELD(RadAudioGenBatch, ref_frame_h)
|
||||
ABI_STRUCT(RadAudioGenDecl)
|
||||
ABI_FIELD(RadAudioGenDecl, name)
|
||||
ABI_FIELD(RadAudioGenDecl, tmpl)
|
||||
ABI_FIELD(RadAudioGenDecl, neg_token)
|
||||
ABI_FIELD(RadAudioGenDecl, neg_keep_head)
|
||||
ABI_FIELD(RadAudioGenDecl, neg_keep_tail)
|
||||
ABI_FIELD(RadAudioGenDecl, max_prompt)
|
||||
ABI_FIELD(RadAudioGenDecl, max_frames)
|
||||
ABI_FIELD(RadAudioGenDecl, frame_rate_num)
|
||||
ABI_FIELD(RadAudioGenDecl, frame_rate_den)
|
||||
ABI_FIELD(RadAudioGenDecl, win_frames)
|
||||
ABI_FIELD(RadAudioGenDecl, win_hop)
|
||||
ABI_FIELD(RadAudioGenDecl, win_lead)
|
||||
ABI_FIELD(RadAudioGenDecl, lat_num)
|
||||
ABI_FIELD(RadAudioGenDecl, lat_den)
|
||||
ABI_FIELD(RadAudioGenDecl, latent_channels)
|
||||
ABI_FIELD(RadAudioGenDecl, win_crop_left)
|
||||
ABI_FIELD(RadAudioGenDecl, win_crop_right)
|
||||
ABI_FIELD(RadAudioGenDecl, samples_per_latent)
|
||||
ABI_FIELD(RadAudioGenDecl, sample_rate)
|
||||
ABI_FIELD(RadAudioGenDecl, channels)
|
||||
ABI_FIELD(RadAudioGenDecl, default_steps)
|
||||
ABI_FIELD(RadAudioGenDecl, default_cfg)
|
||||
ABI_FIELD(RadAudioGenDecl, max_lanes)
|
||||
ABI_FIELD(RadAudioGenDecl, status)
|
||||
ABI_FIELD(RadAudioGenDecl, audio_out)
|
||||
ABI_FIELD(RadAudioGenDecl, tmpl_plain)
|
||||
ABI_FIELD(RadAudioGenDecl, neg_tmpl)
|
||||
ABI_FIELD(RadAudioGenDecl, prompt_whole)
|
||||
ABI_FIELD(RadAudioGenDecl, first_frame)
|
||||
ABI_FIELD(RadAudioGenDecl, voc_chunk)
|
||||
ABI_FIELD(RadAudioGenDecl, voc_context)
|
||||
ABI_FIELD(RadAudioGenDecl, branches)
|
||||
ABI_FIELD(RadAudioGenDecl, input_special)
|
||||
ABI_FIELD(RadAudioGenDecl, tmpl_ref)
|
||||
ABI_FIELD(RadAudioGenDecl, ref_item)
|
||||
ABI_FIELD(RadAudioGenDecl, ref_rate)
|
||||
ABI_FIELD(RadAudioGenDecl, ref_hop)
|
||||
ABI_FIELD(RadAudioGenDecl, ref_max_samples)
|
||||
ABI_FIELD(RadAudioGenDecl, ref_max)
|
||||
ABI_STRUCT(RadControlVector)
|
||||
ABI_FIELD(RadControlVector, dir)
|
||||
ABI_FIELD(RadControlVector, scales)
|
||||
ABI_FIELD(RadControlVector, n_embd)
|
||||
ABI_FIELD(RadControlVector, n_layers)
|
||||
ABI_STRUCT(RadAudioFormat)
|
||||
ABI_FIELD(RadAudioFormat, struct_size)
|
||||
ABI_FIELD(RadAudioFormat, audio_open)
|
||||
ABI_FIELD(RadAudioFormat, audio_close)
|
||||
ABI_FIELD(RadAudioFormat, transcribe_prompt)
|
||||
ABI_FIELD(RadAudioFormat, language_prompt)
|
||||
ABI_FIELD(RadAudioFormat, transcript_open)
|
||||
ABI_FIELD(RadAudioFormat, language_lead)
|
||||
ABI_FIELD(RadAudioFormat, languages)
|
||||
ABI_FIELD(RadAudioFormat, n_languages)
|
||||
ABI_STRUCT(RadChatFormat)
|
||||
ABI_FIELD(RadChatFormat, struct_size)
|
||||
ABI_FIELD(RadChatFormat, name)
|
||||
ABI_FIELD(RadChatFormat, reasoning_open)
|
||||
ABI_FIELD(RadChatFormat, reasoning_close)
|
||||
ABI_FIELD(RadChatFormat, reasoning_breaks)
|
||||
ABI_FIELD(RadChatFormat, n_reasoning_breaks)
|
||||
ABI_FIELD(RadChatFormat, reasoning_in_prompt)
|
||||
ABI_FIELD(RadChatFormat, section_open)
|
||||
ABI_FIELD(RadChatFormat, section_close)
|
||||
ABI_FIELD(RadChatFormat, call_separator)
|
||||
ABI_FIELD(RadChatFormat, call_open)
|
||||
ABI_FIELD(RadChatFormat, call_close)
|
||||
ABI_FIELD(RadChatFormat, name_prefix)
|
||||
ABI_FIELD(RadChatFormat, name_suffix)
|
||||
ABI_FIELD(RadChatFormat, call_end)
|
||||
ABI_FIELD(RadChatFormat, arg_prefix)
|
||||
ABI_FIELD(RadChatFormat, arg_name_suffix)
|
||||
ABI_FIELD(RadChatFormat, arg_value_prefix)
|
||||
ABI_FIELD(RadChatFormat, arg_value_suffix)
|
||||
ABI_FIELD(RadChatFormat, string_value)
|
||||
ABI_FIELD(RadChatFormat, other_value)
|
||||
ABI_FIELD(RadChatFormat, value_newlines)
|
||||
ABI_FIELD(RadChatFormat, triggers)
|
||||
ABI_FIELD(RadChatFormat, n_triggers)
|
||||
ABI_FIELD(RadChatFormat, args_form)
|
||||
ABI_FIELD(RadChatFormat, object_string_open)
|
||||
ABI_FIELD(RadChatFormat, object_string_close)
|
||||
ABI_FIELD(RadChatFormat, object_bare_keys)
|
||||
ABI_FIELD(RadChatFormat, reasoning_anywhere)
|
||||
ABI_FIELD(RadChatFormat, arg_json_value_prefix)
|
||||
ABI_STRUCT(RadConstraint)
|
||||
ABI_FIELD(RadConstraint, key)
|
||||
ABI_FIELD(RadConstraint, op)
|
||||
ABI_FIELD(RadConstraint, ival)
|
||||
ABI_FIELD(RadConstraint, sval)
|
||||
ABI_STRUCT(RadDeviceProps)
|
||||
ABI_FIELD(RadDeviceProps, name)
|
||||
ABI_FIELD(RadDeviceProps, arch)
|
||||
ABI_FIELD(RadDeviceProps, device_id)
|
||||
ABI_FIELD(RadDeviceProps, n_cu)
|
||||
ABI_FIELD(RadDeviceProps, warp_size)
|
||||
ABI_FIELD(RadDeviceProps, vram_bytes)
|
||||
ABI_FIELD(RadDeviceProps, vram_free)
|
||||
ABI_FIELD(RadDeviceProps, lds_bytes)
|
||||
ABI_FIELD(RadDeviceProps, supports_p2p)
|
||||
ABI_FIELD(RadDeviceProps, is_host_backend)
|
||||
ABI_FIELD(RadDeviceProps, unified)
|
||||
ABI_STRUCT(RadDrafterDecl)
|
||||
ABI_FIELD(RadDrafterDecl, name)
|
||||
ABI_FIELD(RadDrafterDecl, kind)
|
||||
ABI_FIELD(RadDrafterDecl, depth)
|
||||
ABI_FIELD(RadDrafterDecl, proposal)
|
||||
ABI_FIELD(RadDrafterDecl, proposal_pitch)
|
||||
ABI_FIELD(RadDrafterDecl, mask_token)
|
||||
ABI_FIELD(RadDrafterDecl, window)
|
||||
ABI_FIELD(RadDrafterDecl, block)
|
||||
ABI_STRUCT(RadDtRow)
|
||||
ABI_FIELD(RadDtRow, dt)
|
||||
ABI_FIELD(RadDtRow, name)
|
||||
ABI_FIELD(RadDtRow, bits)
|
||||
ABI_STRUCT(RadEncPlane)
|
||||
ABI_FIELD(RadEncPlane, role)
|
||||
ABI_FIELD(RadEncPlane, dtype)
|
||||
ABI_FIELD(RadEncPlane, kind)
|
||||
ABI_FIELD(RadEncPlane, block)
|
||||
ABI_FIELD(RadEncPlane, extent)
|
||||
ABI_STRUCT(RadEncoderDecl)
|
||||
ABI_FIELD(RadEncoderDecl, name)
|
||||
ABI_FIELD(RadEncoderDecl, modalities)
|
||||
ABI_FIELD(RadEncoderDecl, patch_dim)
|
||||
ABI_FIELD(RadEncoderDecl, merge)
|
||||
ABI_FIELD(RadEncoderDecl, max_patches)
|
||||
ABI_FIELD(RadEncoderDecl, n_embd)
|
||||
ABI_FIELD(RadEncoderDecl, out)
|
||||
ABI_FIELD(RadEncoderDecl, one_grid)
|
||||
ABI_STRUCT(RadEncoding)
|
||||
ABI_FIELD(RadEncoding, scheme)
|
||||
ABI_FIELD(RadEncoding, transform)
|
||||
ABI_FIELD(RadEncoding, n_planes)
|
||||
ABI_FIELD(RadEncoding, reserved)
|
||||
ABI_FIELD(RadEncoding, plane)
|
||||
ABI_STRUCT(RadFileEntry)
|
||||
ABI_FIELD(RadFileEntry, name)
|
||||
ABI_FIELD(RadFileEntry, quantizer)
|
||||
ABI_FIELD(RadFileEntry, options)
|
||||
ABI_FIELD(RadFileEntry, enc)
|
||||
ABI_FIELD(RadFileEntry, rank)
|
||||
ABI_FIELD(RadFileEntry, shape)
|
||||
ABI_FIELD(RadFileEntry, layer)
|
||||
ABI_FIELD(RadFileEntry, expert)
|
||||
ABI_FIELD(RadFileEntry, slot)
|
||||
ABI_FIELD(RadFileEntry, n_planes)
|
||||
ABI_FIELD(RadFileEntry, plane_first)
|
||||
ABI_FIELD(RadFileEntry, offset)
|
||||
ABI_FIELD(RadFileEntry, bytes)
|
||||
ABI_FIELD(RadFileEntry, reserved)
|
||||
ABI_STRUCT(RadFileHeader)
|
||||
ABI_FIELD(RadFileHeader, magic)
|
||||
ABI_FIELD(RadFileHeader, version)
|
||||
ABI_FIELD(RadFileHeader, file_bytes)
|
||||
ABI_FIELD(RadFileHeader, arch_id)
|
||||
ABI_FIELD(RadFileHeader, model_name)
|
||||
ABI_FIELD(RadFileHeader, quant)
|
||||
ABI_FIELD(RadFileHeader, recipe)
|
||||
ABI_FIELD(RadFileHeader, created_by)
|
||||
ABI_FIELD(RadFileHeader, str_off)
|
||||
ABI_FIELD(RadFileHeader, str_bytes)
|
||||
ABI_FIELD(RadFileHeader, meta_off)
|
||||
ABI_FIELD(RadFileHeader, meta_count)
|
||||
ABI_FIELD(RadFileHeader, dir_off)
|
||||
ABI_FIELD(RadFileHeader, dir_count)
|
||||
ABI_FIELD(RadFileHeader, plane_off)
|
||||
ABI_FIELD(RadFileHeader, plane_count)
|
||||
ABI_FIELD(RadFileHeader, enc_off)
|
||||
ABI_FIELD(RadFileHeader, enc_count)
|
||||
ABI_FIELD(RadFileHeader, vocab_off)
|
||||
ABI_FIELD(RadFileHeader, vocab_bytes)
|
||||
ABI_FIELD(RadFileHeader, prof_off)
|
||||
ABI_FIELD(RadFileHeader, prof_count)
|
||||
ABI_FIELD(RadFileHeader, data_off)
|
||||
ABI_FIELD(RadFileHeader, data_bytes)
|
||||
ABI_FIELD(RadFileHeader, reserved)
|
||||
ABI_STRUCT(RadFileKV)
|
||||
ABI_FIELD(RadFileKV, key)
|
||||
ABI_FIELD(RadFileKV, type)
|
||||
ABI_FIELD(RadFileKV, pad)
|
||||
ABI_FIELD(RadFileKV, v)
|
||||
ABI_STRUCT(RadFilePlane)
|
||||
ABI_FIELD(RadFilePlane, offset)
|
||||
ABI_FIELD(RadFilePlane, bytes)
|
||||
ABI_STRUCT(RadFileProfile)
|
||||
ABI_FIELD(RadFileProfile, layer)
|
||||
ABI_FIELD(RadFileProfile, expert)
|
||||
ABI_FIELD(RadFileProfile, share)
|
||||
ABI_FIELD(RadFileProfile, reserved)
|
||||
ABI_STRUCT(RadFuseStep)
|
||||
ABI_FIELD(RadFuseStep, op)
|
||||
ABI_FIELD(RadFuseStep, p)
|
||||
ABI_FIELD(RadFuseStep, n_p)
|
||||
ABI_FIELD(RadFuseStep, from)
|
||||
ABI_FIELD(RadFuseStep, n_from)
|
||||
ABI_STRUCT(RadGenBatch)
|
||||
ABI_FIELD(RadGenBatch, rows)
|
||||
ABI_FIELD(RadGenBatch, src)
|
||||
ABI_FIELD(RadGenBatch, rope)
|
||||
ABI_FIELD(RadGenBatch, n_seg)
|
||||
ABI_FIELD(RadGenBatch, seg)
|
||||
ABI_FIELD(RadGenBatch, seg_h)
|
||||
ABI_FIELD(RadGenBatch, seg_bidi_h)
|
||||
ABI_FIELD(RadGenBatch, seg_cu)
|
||||
ABI_FIELD(RadGenBatch, seg_start)
|
||||
ABI_FIELD(RadGenBatch, slot_mapping)
|
||||
ABI_FIELD(RadGenBatch, n_px)
|
||||
ABI_FIELD(RadGenBatch, px)
|
||||
ABI_FIELD(RadGenBatch, px_h)
|
||||
ABI_FIELD(RadGenBatch, px_cu)
|
||||
ABI_FIELD(RadGenBatch, inpaint)
|
||||
ABI_FIELD(RadGenBatch, inp_mask)
|
||||
ABI_FIELD(RadGenBatch, n_lane)
|
||||
ABI_FIELD(RadGenBatch, lane_h)
|
||||
ABI_FIELD(RadGenBatch, sigma)
|
||||
ABI_FIELD(RadGenBatch, sigma_next)
|
||||
ABI_FIELD(RadGenBatch, cfg)
|
||||
ABI_FIELD(RadGenBatch, pair)
|
||||
ABI_FIELD(RadGenBatch, lane)
|
||||
ABI_FIELD(RadGenBatch, lane_dh)
|
||||
ABI_FIELD(RadGenBatch, flags)
|
||||
ABI_FIELD(RadGenBatch, seed)
|
||||
ABI_FIELD(RadGenBatch, dec_lane)
|
||||
ABI_FIELD(RadGenBatch, dec_height)
|
||||
ABI_FIELD(RadGenBatch, dec_width)
|
||||
ABI_FIELD(RadGenBatch, dec_preview)
|
||||
ABI_FIELD(RadGenBatch, branch)
|
||||
ABI_FIELD(RadGenBatch, n_pad)
|
||||
ABI_FIELD(RadGenBatch, valid_cu)
|
||||
ABI_FIELD(RadGenBatch, n_img)
|
||||
ABI_FIELD(RadGenBatch, img_cu)
|
||||
ABI_FIELD(RadGenBatch, img_rows)
|
||||
ABI_FIELD(RadGenBatch, mode_cu)
|
||||
ABI_FIELD(RadGenBatch, rope_f)
|
||||
ABI_FIELD(RadGenBatch, mode_rows)
|
||||
ABI_FIELD(RadGenBatch, mode_src)
|
||||
ABI_FIELD(RadGenBatch, mode_ccu)
|
||||
ABI_FIELD(RadGenBatch, n_mode_h)
|
||||
ABI_FIELD(RadGenBatch, mode_rope_f)
|
||||
ABI_FIELD(RadGenBatch, n_aux)
|
||||
ABI_FIELD(RadGenBatch, aux_ids)
|
||||
ABI_FIELD(RadGenBatch, aux_cu)
|
||||
ABI_FIELD(RadGenBatch, sigma_prev)
|
||||
ABI_FIELD(RadGenBatch, timestep)
|
||||
ABI_FIELD(RadGenBatch, sampler)
|
||||
ABI_FIELD(RadGenBatch, step)
|
||||
ABI_FIELD(RadGenBatch, size_px)
|
||||
ABI_FIELD(RadGenBatch, entry_h)
|
||||
ABI_FIELD(RadGenBatch, tokens_h)
|
||||
ABI_FIELD(RadGenBatch, cond_opts)
|
||||
ABI_STRUCT(RadGeneratorDecl)
|
||||
ABI_FIELD(RadGeneratorDecl, name)
|
||||
ABI_FIELD(RadGeneratorDecl, layout)
|
||||
ABI_FIELD(RadGeneratorDecl, tmpl_text)
|
||||
ABI_FIELD(RadGeneratorDecl, tmpl_edit)
|
||||
ABI_FIELD(RadGeneratorDecl, tmpl_image)
|
||||
ABI_FIELD(RadGeneratorDecl, tmpl_image_sep)
|
||||
ABI_FIELD(RadGeneratorDecl, drop_prefix)
|
||||
ABI_FIELD(RadGeneratorDecl, tmpl_transparent)
|
||||
ABI_FIELD(RadGeneratorDecl, latent_channels)
|
||||
ABI_FIELD(RadGeneratorDecl, latent_scale)
|
||||
ABI_FIELD(RadGeneratorDecl, size_multiple)
|
||||
ABI_FIELD(RadGeneratorDecl, pixel_channels)
|
||||
ABI_FIELD(RadGeneratorDecl, slot_rows)
|
||||
ABI_FIELD(RadGeneratorDecl, max_tokens)
|
||||
ABI_FIELD(RadGeneratorDecl, max_refs)
|
||||
ABI_FIELD(RadGeneratorDecl, ref_area)
|
||||
ABI_FIELD(RadGeneratorDecl, default_width)
|
||||
ABI_FIELD(RadGeneratorDecl, default_height)
|
||||
ABI_FIELD(RadGeneratorDecl, default_steps)
|
||||
ABI_FIELD(RadGeneratorDecl, n_sigmas)
|
||||
ABI_FIELD(RadGeneratorDecl, sigmas)
|
||||
ABI_FIELD(RadGeneratorDecl, shift)
|
||||
ABI_FIELD(RadGeneratorDecl, dyn_shift)
|
||||
ABI_FIELD(RadGeneratorDecl, shift_exp)
|
||||
ABI_FIELD(RadGeneratorDecl, base_shift)
|
||||
ABI_FIELD(RadGeneratorDecl, max_shift)
|
||||
ABI_FIELD(RadGeneratorDecl, base_seq)
|
||||
ABI_FIELD(RadGeneratorDecl, max_seq)
|
||||
ABI_FIELD(RadGeneratorDecl, shift_terminal)
|
||||
ABI_FIELD(RadGeneratorDecl, default_cfg)
|
||||
ABI_FIELD(RadGeneratorDecl, max_lanes)
|
||||
ABI_FIELD(RadGeneratorDecl, image_out)
|
||||
ABI_FIELD(RadGeneratorDecl, cond_rows)
|
||||
ABI_FIELD(RadGeneratorDecl, rope_hw_scale)
|
||||
ABI_FIELD(RadGeneratorDecl, rope_text_l)
|
||||
ABI_FIELD(RadGeneratorDecl, pad_multiple)
|
||||
ABI_FIELD(RadGeneratorDecl, pad_token)
|
||||
ABI_FIELD(RadGeneratorDecl, cfg_original)
|
||||
ABI_FIELD(RadGeneratorDecl, default_negative)
|
||||
ABI_FIELD(RadGeneratorDecl, ref_shrink_only)
|
||||
ABI_FIELD(RadGeneratorDecl, aux_max_tokens)
|
||||
ABI_FIELD(RadGeneratorDecl, sigma_grid)
|
||||
ABI_FIELD(RadGeneratorDecl, min_tokens)
|
||||
ABI_FIELD(RadGeneratorDecl, aux_tokens)
|
||||
ABI_FIELD(RadGeneratorDecl, beta_start)
|
||||
ABI_FIELD(RadGeneratorDecl, beta_end)
|
||||
ABI_FIELD(RadGeneratorDecl, train_steps)
|
||||
ABI_FIELD(RadGeneratorDecl, beta_schedule)
|
||||
ABI_FIELD(RadGeneratorDecl, zero_snr)
|
||||
ABI_FIELD(RadGeneratorDecl, samplers)
|
||||
ABI_FIELD(RadGeneratorDecl, default_sampler)
|
||||
ABI_FIELD(RadGeneratorDecl, default_scheduler)
|
||||
ABI_FIELD(RadGeneratorDecl, chunk_tokens)
|
||||
ABI_FIELD(RadGeneratorDecl, chunk_bos)
|
||||
ABI_FIELD(RadGeneratorDecl, chunk_eos)
|
||||
ABI_FIELD(RadGeneratorDecl, cond_opts)
|
||||
ABI_STRUCT(RadKVGroupBatch)
|
||||
ABI_FIELD(RadKVGroupBatch, group)
|
||||
ABI_FIELD(RadKVGroupBatch, slot_mapping)
|
||||
ABI_FIELD(RadKVGroupBatch, block_table)
|
||||
ABI_FIELD(RadKVGroupBatch, block_table_pitch)
|
||||
ABI_FIELD(RadKVGroupBatch, seqused)
|
||||
ABI_FIELD(RadKVGroupBatch, state_index)
|
||||
ABI_FIELD(RadKVGroupBatch, state_index_pitch)
|
||||
ABI_FIELD(RadKVGroupBatch, block_size)
|
||||
ABI_FIELD(RadKVGroupBatch, max_blocks)
|
||||
ABI_FIELD(RadKVGroupBatch, stream)
|
||||
ABI_STRUCT(RadKVGroupDecl)
|
||||
ABI_FIELD(RadKVGroupDecl, kind)
|
||||
ABI_FIELD(RadKVGroupDecl, dtype)
|
||||
ABI_FIELD(RadKVGroupDecl, window)
|
||||
ABI_FIELD(RadKVGroupDecl, n_head_kv)
|
||||
ABI_FIELD(RadKVGroupDecl, head_dim)
|
||||
ABI_FIELD(RadKVGroupDecl, state_dim)
|
||||
ABI_FIELD(RadKVGroupDecl, conv_width)
|
||||
ABI_STRUCT(RadKVStream)
|
||||
ABI_FIELD(RadKVStream, host)
|
||||
ABI_FIELD(RadKVStream, res)
|
||||
ABI_FIELD(RadKVStream, slot_block)
|
||||
ABI_FIELD(RadKVStream, slot_state)
|
||||
ABI_FIELD(RadKVStream, ctl)
|
||||
ABI_FIELD(RadKVStream, block_bytes)
|
||||
ABI_FIELD(RadKVStream, host_layer_stride)
|
||||
ABI_FIELD(RadKVStream, slots)
|
||||
ABI_FIELD(RadKVStream, host_bytes)
|
||||
ABI_STRUCT(RadKernelInfo)
|
||||
ABI_FIELD(RadKernelInfo, name)
|
||||
ABI_FIELD(RadKernelInfo, op)
|
||||
ABI_FIELD(RadKernelInfo, family)
|
||||
ABI_FIELD(RadKernelInfo, computes)
|
||||
ABI_FIELD(RadKernelInfo, shape)
|
||||
ABI_FIELD(RadKernelInfo, dtypes)
|
||||
ABI_FIELD(RadKernelInfo, domain)
|
||||
ABI_FIELD(RadKernelInfo, priority)
|
||||
ABI_FIELD(RadKernelInfo, constraints)
|
||||
ABI_FIELD(RadKernelInfo, n_constraints)
|
||||
ABI_FIELD(RadKernelInfo, tunables)
|
||||
ABI_FIELD(RadKernelInfo, n_tunables)
|
||||
ABI_FIELD(RadKernelInfo, tune_valid)
|
||||
ABI_FIELD(RadKernelInfo, init)
|
||||
ABI_FIELD(RadKernelInfo, fini)
|
||||
ABI_FIELD(RadKernelInfo, launch)
|
||||
ABI_FIELD(RadKernelInfo, scratch)
|
||||
ABI_FIELD(RadKernelInfo, layout)
|
||||
ABI_FIELD(RadKernelInfo, relayout)
|
||||
ABI_FIELD(RadKernelInfo, opd_shape)
|
||||
ABI_FIELD(RadKernelInfo, unrelayout)
|
||||
ABI_FIELD(RadKernelInfo, replaces)
|
||||
ABI_STRUCT(RadLayout)
|
||||
ABI_FIELD(RadLayout, tag)
|
||||
ABI_FIELD(RadLayout, dtype)
|
||||
ABI_FIELD(RadLayout, rank)
|
||||
ABI_FIELD(RadLayout, shape)
|
||||
ABI_FIELD(RadLayout, align)
|
||||
ABI_FIELD(RadLayout, bytes)
|
||||
ABI_STRUCT(RadModelMeta)
|
||||
ABI_FIELD(RadModelMeta, arch_id)
|
||||
ABI_FIELD(RadModelMeta, name)
|
||||
ABI_FIELD(RadModelMeta, quant)
|
||||
ABI_FIELD(RadModelMeta, n_layers)
|
||||
ABI_FIELD(RadModelMeta, n_embd)
|
||||
ABI_FIELD(RadModelMeta, n_head)
|
||||
ABI_FIELD(RadModelMeta, n_head_kv)
|
||||
ABI_FIELD(RadModelMeta, head_dim)
|
||||
ABI_FIELD(RadModelMeta, n_ff)
|
||||
ABI_FIELD(RadModelMeta, n_vocab)
|
||||
ABI_FIELD(RadModelMeta, n_ctx_train)
|
||||
ABI_FIELD(RadModelMeta, n_expert)
|
||||
ABI_FIELD(RadModelMeta, n_expert_used)
|
||||
ABI_FIELD(RadModelMeta, n_expert_shared)
|
||||
ABI_FIELD(RadModelMeta, rms_eps)
|
||||
ABI_FIELD(RadModelMeta, rope_theta)
|
||||
ABI_FIELD(RadModelMeta, rope_scale)
|
||||
ABI_FIELD(RadModelMeta, n_kv)
|
||||
ABI_FIELD(RadModelMeta, kv_key)
|
||||
ABI_FIELD(RadModelMeta, kv_val)
|
||||
ABI_STRUCT(RadNameMap)
|
||||
ABI_FIELD(RadNameMap, declared)
|
||||
ABI_FIELD(RadNameMap, mode)
|
||||
ABI_FIELD(RadNameMap, n_src)
|
||||
ABI_FIELD(RadNameMap, src)
|
||||
ABI_FIELD(RadNameMap, concat_dim)
|
||||
ABI_FIELD(RadNameMap, src_index)
|
||||
ABI_FIELD(RadNameMap, src_rows)
|
||||
ABI_STRUCT(RadOpSchema)
|
||||
ABI_FIELD(RadOpSchema, op)
|
||||
ABI_FIELD(RadOpSchema, params)
|
||||
ABI_FIELD(RadOpSchema, n_params)
|
||||
ABI_FIELD(RadOpSchema, operands)
|
||||
ABI_FIELD(RadOpSchema, n_operands)
|
||||
ABI_FIELD(RadOpSchema, doc)
|
||||
ABI_STRUCT(RadOpdDesc)
|
||||
ABI_FIELD(RadOpdDesc, dtype)
|
||||
ABI_FIELD(RadOpdDesc, rank)
|
||||
ABI_FIELD(RadOpdDesc, shape)
|
||||
ABI_FIELD(RadOpdDesc, fill)
|
||||
ABI_FIELD(RadOpdDesc, fill_chunk)
|
||||
ABI_FIELD(RadOpdDesc, idx_max)
|
||||
ABI_FIELD(RadOpdDesc, idx_const)
|
||||
ABI_FIELD(RadOpdDesc, flags)
|
||||
ABI_STRUCT(RadOperand)
|
||||
ABI_FIELD(RadOperand, kind)
|
||||
ABI_FIELD(RadOperand, dtype)
|
||||
ABI_FIELD(RadOperand, handle)
|
||||
ABI_FIELD(RadOperand, raw)
|
||||
ABI_FIELD(RadOperand, offset)
|
||||
ABI_FIELD(RadOperand, rows)
|
||||
ABI_FIELD(RadOperand, cols)
|
||||
ABI_STRUCT(RadOperandSpec)
|
||||
ABI_FIELD(RadOperandSpec, name)
|
||||
ABI_FIELD(RadOperandSpec, role)
|
||||
ABI_FIELD(RadOperandSpec, optional)
|
||||
ABI_STRUCT(RadParam)
|
||||
ABI_FIELD(RadParam, key)
|
||||
ABI_FIELD(RadParam, kind)
|
||||
ABI_FIELD(RadParam, ival)
|
||||
ABI_FIELD(RadParam, ihi)
|
||||
ABI_FIELD(RadParam, sval)
|
||||
ABI_FIELD(RadParam, dval)
|
||||
ABI_STRUCT(RadParamSpec)
|
||||
ABI_FIELD(RadParamSpec, key)
|
||||
ABI_FIELD(RadParamSpec, type)
|
||||
ABI_FIELD(RadParamSpec, required)
|
||||
ABI_FIELD(RadParamSpec, role)
|
||||
ABI_STRUCT(RadPlanesEntry)
|
||||
ABI_FIELD(RadPlanesEntry, role)
|
||||
ABI_FIELD(RadPlanesEntry, dtype)
|
||||
ABI_FIELD(RadPlanesEntry, kind)
|
||||
ABI_FIELD(RadPlanesEntry, block)
|
||||
ABI_FIELD(RadPlanesEntry, rows)
|
||||
ABI_FIELD(RadPlanesEntry, cols)
|
||||
ABI_FIELD(RadPlanesEntry, row_bytes)
|
||||
ABI_FIELD(RadPlanesEntry, offset)
|
||||
ABI_STRUCT(RadPlanesHeader)
|
||||
ABI_FIELD(RadPlanesHeader, magic)
|
||||
ABI_FIELD(RadPlanesHeader, n_planes)
|
||||
ABI_FIELD(RadPlanesHeader, transform)
|
||||
ABI_FIELD(RadPlanesHeader, bytes)
|
||||
ABI_STRUCT(RadPluginInfo)
|
||||
ABI_FIELD(RadPluginInfo, kind)
|
||||
ABI_FIELD(RadPluginInfo, name)
|
||||
ABI_FIELD(RadPluginInfo, version)
|
||||
ABI_FIELD(RadPluginInfo, description)
|
||||
ABI_FIELD(RadPluginInfo, build_target)
|
||||
ABI_STRUCT(RadPrefetchNext)
|
||||
ABI_FIELD(RadPrefetchNext, layer)
|
||||
ABI_FIELD(RadPrefetchNext, router)
|
||||
ABI_FIELD(RadPrefetchNext, n_expert)
|
||||
ABI_FIELD(RadPrefetchNext, top_k)
|
||||
ABI_FIELD(RadPrefetchNext, n_parts)
|
||||
ABI_FIELD(RadPrefetchNext, parts)
|
||||
ABI_FIELD(RadPrefetchNext, count_at)
|
||||
ABI_STRUCT(RadQuantOption)
|
||||
ABI_FIELD(RadQuantOption, key)
|
||||
ABI_FIELD(RadQuantOption, type)
|
||||
ABI_FIELD(RadQuantOption, deflt)
|
||||
ABI_FIELD(RadQuantOption, doc)
|
||||
ABI_STRUCT(RadQuantWeight)
|
||||
ABI_FIELD(RadQuantWeight, name)
|
||||
ABI_FIELD(RadQuantWeight, rank)
|
||||
ABI_FIELD(RadQuantWeight, shape)
|
||||
ABI_FIELD(RadQuantWeight, rows)
|
||||
ABI_FIELD(RadQuantWeight, cols)
|
||||
ABI_FIELD(RadQuantWeight, layer)
|
||||
ABI_FIELD(RadQuantWeight, expert)
|
||||
ABI_FIELD(RadQuantWeight, importance)
|
||||
ABI_STRUCT(RadQuantizerInfo)
|
||||
ABI_FIELD(RadQuantizerInfo, name)
|
||||
ABI_FIELD(RadQuantizerInfo, doc)
|
||||
ABI_FIELD(RadQuantizerInfo, options)
|
||||
ABI_FIELD(RadQuantizerInfo, n_options)
|
||||
ABI_FIELD(RadQuantizerInfo, encoding)
|
||||
ABI_FIELD(RadQuantizerInfo, row_block)
|
||||
ABI_FIELD(RadQuantizerInfo, quantize)
|
||||
ABI_FIELD(RadQuantizerInfo, decode)
|
||||
ABI_STRUCT(RadRouting)
|
||||
ABI_FIELD(RadRouting, expert_ids)
|
||||
ABI_FIELD(RadRouting, expert_w)
|
||||
ABI_FIELD(RadRouting, expert_count)
|
||||
ABI_FIELD(RadRouting, sorted_tok)
|
||||
ABI_FIELD(RadRouting, expert_offset)
|
||||
ABI_FIELD(RadRouting, top_k)
|
||||
ABI_FIELD(RadRouting, n_expert)
|
||||
ABI_STRUCT(RadSampleParams)
|
||||
ABI_FIELD(RadSampleParams, seed)
|
||||
ABI_FIELD(RadSampleParams, pos)
|
||||
ABI_FIELD(RadSampleParams, temp)
|
||||
ABI_FIELD(RadSampleParams, top_p)
|
||||
ABI_FIELD(RadSampleParams, min_p)
|
||||
ABI_FIELD(RadSampleParams, typical_p)
|
||||
ABI_FIELD(RadSampleParams, rep_penalty)
|
||||
ABI_FIELD(RadSampleParams, freq_penalty)
|
||||
ABI_FIELD(RadSampleParams, pres_penalty)
|
||||
ABI_FIELD(RadSampleParams, xtc_probability)
|
||||
ABI_FIELD(RadSampleParams, xtc_threshold)
|
||||
ABI_FIELD(RadSampleParams, dry_multiplier)
|
||||
ABI_FIELD(RadSampleParams, dry_base)
|
||||
ABI_FIELD(RadSampleParams, top_k)
|
||||
ABI_FIELD(RadSampleParams, penalty_last_n)
|
||||
ABI_FIELD(RadSampleParams, dry_allowed_length)
|
||||
ABI_FIELD(RadSampleParams, dry_penalty_last_n)
|
||||
ABI_FIELD(RadSampleParams, hist_off)
|
||||
ABI_FIELD(RadSampleParams, hist_len)
|
||||
ABI_FIELD(RadSampleParams, mask_row)
|
||||
ABI_FIELD(RadSampleParams, flags)
|
||||
ABI_FIELD(RadSampleParams, dry_rep_limit)
|
||||
ABI_STRUCT(RadSyclStream)
|
||||
ABI_FIELD(RadSyclStream, magic)
|
||||
ABI_FIELD(RadSyclStream, version)
|
||||
ABI_FIELD(RadSyclStream, queue)
|
||||
ABI_FIELD(RadSyclStream, device)
|
||||
ABI_FIELD(RadSyclStream, reserved)
|
||||
ABI_STRUCT(RadTensor)
|
||||
ABI_FIELD(RadTensor, data)
|
||||
ABI_FIELD(RadTensor, dtype)
|
||||
ABI_FIELD(RadTensor, rank)
|
||||
ABI_FIELD(RadTensor, shape)
|
||||
ABI_FIELD(RadTensor, stride)
|
||||
ABI_STRUCT(RadTunable)
|
||||
ABI_FIELD(RadTunable, key)
|
||||
ABI_FIELD(RadTunable, values)
|
||||
ABI_FIELD(RadTunable, n_values)
|
||||
ABI_FIELD(RadTunable, deflt)
|
||||
ABI_FIELD(RadTunable, doc)
|
||||
ABI_STRUCT(RadVideoGenBatch)
|
||||
ABI_FIELD(RadVideoGenBatch, lane)
|
||||
ABI_FIELD(RadVideoGenBatch, geom)
|
||||
ABI_FIELD(RadVideoGenBatch, geom_d)
|
||||
ABI_FIELD(RadVideoGenBatch, lane_d)
|
||||
ABI_FIELD(RadVideoGenBatch, first_d)
|
||||
ABI_FIELD(RadVideoGenBatch, seg_cu)
|
||||
ABI_FIELD(RadVideoGenBatch, lat_cu)
|
||||
ABI_FIELD(RadVideoGenBatch, n_steps)
|
||||
ABI_FIELD(RadVideoGenBatch, t_video)
|
||||
ABI_FIELD(RadVideoGenBatch, t_audio)
|
||||
ABI_FIELD(RadVideoGenBatch, step)
|
||||
ABI_FIELD(RadVideoGenBatch, sched)
|
||||
ABI_FIELD(RadVideoGenBatch, pos)
|
||||
ABI_FIELD(RadVideoGenBatch, seed)
|
||||
ABI_FIELD(RadVideoGenBatch, chunk)
|
||||
ABI_FIELD(RadVideoGenBatch, n_chunks)
|
||||
ABI_FIELD(RadVideoGenBatch, dec_rows)
|
||||
ABI_FIELD(RadVideoGenBatch, n_frames_out)
|
||||
ABI_FIELD(RadVideoGenBatch, n_samples)
|
||||
ABI_FIELD(RadVideoGenBatch, geom_from)
|
||||
ABI_FIELD(RadVideoGenBatch, upscale)
|
||||
ABI_FIELD(RadVideoGenBatch, n_neg)
|
||||
ABI_FIELD(RadVideoGenBatch, guidance_h)
|
||||
ABI_FIELD(RadVideoGenBatch, image)
|
||||
ABI_FIELD(RadVideoGenBatch, has_image)
|
||||
ABI_FIELD(RadVideoGenBatch, guidance)
|
||||
ABI_FIELD(RadVideoGenBatch, decoder)
|
||||
ABI_FIELD(RadVideoGenBatch, sampler)
|
||||
ABI_FIELD(RadVideoGenBatch, enc_pixels)
|
||||
ABI_FIELD(RadVideoGenBatch, enc_frames)
|
||||
ABI_FIELD(RadVideoGenBatch, enc_height)
|
||||
ABI_FIELD(RadVideoGenBatch, enc_width)
|
||||
ABI_FIELD(RadVideoGenBatch, enc_samples)
|
||||
ABI_FIELD(RadVideoGenBatch, enc_n_samples)
|
||||
ABI_FIELD(RadVideoGenBatch, enc_channels)
|
||||
ABI_FIELD(RadVideoGenBatch, enc_geom_d)
|
||||
ABI_FIELD(RadVideoGenBatch, enc_kind)
|
||||
ABI_FIELD(RadVideoGenBatch, enc_slot)
|
||||
ABI_FIELD(RadVideoGenBatch, ref_tab)
|
||||
ABI_FIELD(RadVideoGenBatch, mod_cu)
|
||||
ABI_STRUCT(RadVideoGenDecl)
|
||||
ABI_FIELD(RadVideoGenDecl, name)
|
||||
ABI_FIELD(RadVideoGenDecl, tmpl)
|
||||
ABI_FIELD(RadVideoGenDecl, max_text)
|
||||
ABI_FIELD(RadVideoGenDecl, fps_num)
|
||||
ABI_FIELD(RadVideoGenDecl, fps_den)
|
||||
ABI_FIELD(RadVideoGenDecl, frames_per_chunk)
|
||||
ABI_FIELD(RadVideoGenDecl, frames_tail)
|
||||
ABI_FIELD(RadVideoGenDecl, latents_per_chunk)
|
||||
ABI_FIELD(RadVideoGenDecl, latents_tail)
|
||||
ABI_FIELD(RadVideoGenDecl, dec_latents)
|
||||
ABI_FIELD(RadVideoGenDecl, min_chunks)
|
||||
ABI_FIELD(RadVideoGenDecl, max_chunks)
|
||||
ABI_FIELD(RadVideoGenDecl, latent_scale)
|
||||
ABI_FIELD(RadVideoGenDecl, latent_channels)
|
||||
ABI_FIELD(RadVideoGenDecl, patch)
|
||||
ABI_FIELD(RadVideoGenDecl, size_multiple)
|
||||
ABI_FIELD(RadVideoGenDecl, min_side)
|
||||
ABI_FIELD(RadVideoGenDecl, max_area)
|
||||
ABI_FIELD(RadVideoGenDecl, max_aspect)
|
||||
ABI_FIELD(RadVideoGenDecl, default_width)
|
||||
ABI_FIELD(RadVideoGenDecl, default_height)
|
||||
ABI_FIELD(RadVideoGenDecl, default_chunks)
|
||||
ABI_FIELD(RadVideoGenDecl, sample_rate)
|
||||
ABI_FIELD(RadVideoGenDecl, audio_rate)
|
||||
ABI_FIELD(RadVideoGenDecl, audio_channels)
|
||||
ABI_FIELD(RadVideoGenDecl, audio_latent_channels)
|
||||
ABI_FIELD(RadVideoGenDecl, default_steps)
|
||||
ABI_FIELD(RadVideoGenDecl, max_steps)
|
||||
ABI_FIELD(RadVideoGenDecl, shift_video)
|
||||
ABI_FIELD(RadVideoGenDecl, shift_audio)
|
||||
ABI_FIELD(RadVideoGenDecl, max_lanes)
|
||||
ABI_FIELD(RadVideoGenDecl, frames_out)
|
||||
ABI_FIELD(RadVideoGenDecl, audio_out)
|
||||
ABI_FIELD(RadVideoGenDecl, n_rungs)
|
||||
ABI_FIELD(RadVideoGenDecl, rungs)
|
||||
ABI_FIELD(RadVideoGenDecl, upscale_max)
|
||||
ABI_FIELD(RadVideoGenDecl, upscale_refine)
|
||||
ABI_FIELD(RadVideoGenDecl, sched_kind)
|
||||
ABI_FIELD(RadVideoGenDecl, dyn_shift)
|
||||
ABI_FIELD(RadVideoGenDecl, base_shift)
|
||||
ABI_FIELD(RadVideoGenDecl, max_shift)
|
||||
ABI_FIELD(RadVideoGenDecl, base_seq)
|
||||
ABI_FIELD(RadVideoGenDecl, max_seq)
|
||||
ABI_FIELD(RadVideoGenDecl, shift_terminal)
|
||||
ABI_FIELD(RadVideoGenDecl, n_refine_rungs)
|
||||
ABI_FIELD(RadVideoGenDecl, refine_rungs)
|
||||
ABI_FIELD(RadVideoGenDecl, step_text_rows)
|
||||
ABI_FIELD(RadVideoGenDecl, guidance)
|
||||
ABI_FIELD(RadVideoGenDecl, guidance_default)
|
||||
ABI_FIELD(RadVideoGenDecl, default_negative)
|
||||
ABI_FIELD(RadVideoGenDecl, image_cond)
|
||||
ABI_FIELD(RadVideoGenDecl, image_crf)
|
||||
ABI_FIELD(RadVideoGenDecl, text_left_pad)
|
||||
ABI_FIELD(RadVideoGenDecl, audio_streams)
|
||||
ABI_FIELD(RadVideoGenDecl, upscale_exact)
|
||||
ABI_FIELD(RadVideoGenDecl, duration_out)
|
||||
ABI_FIELD(RadVideoGenDecl, duration_min)
|
||||
ABI_FIELD(RadVideoGenDecl, duration_max)
|
||||
ABI_FIELD(RadVideoGenDecl, duration_dtype)
|
||||
ABI_FIELD(RadVideoGenDecl, decoders)
|
||||
ABI_FIELD(RadVideoGenDecl, decoder_max_area)
|
||||
ABI_FIELD(RadVideoGenDecl, max_ref_images)
|
||||
ABI_FIELD(RadVideoGenDecl, max_ref_videos)
|
||||
ABI_FIELD(RadVideoGenDecl, max_ref_audios)
|
||||
ABI_FIELD(RadVideoGenDecl, max_enc_frames)
|
||||
ABI_FIELD(RadVideoGenDecl, max_enc_side)
|
||||
ABI_FIELD(RadVideoGenDecl, max_enc_samples)
|
||||
ABI_FIELD(RadVideoGenDecl, enc_ratio)
|
||||
ABI_FIELD(RadVideoGenDecl, max_mod_cells)
|
||||
ABI_STRUCT(RadVideoGeom)
|
||||
ABI_FIELD(RadVideoGeom, n_text)
|
||||
ABI_FIELD(RadVideoGeom, frames)
|
||||
ABI_FIELD(RadVideoGeom, lat_frames)
|
||||
ABI_FIELD(RadVideoGeom, lat_h)
|
||||
ABI_FIELD(RadVideoGeom, lat_w)
|
||||
ABI_FIELD(RadVideoGeom, n_audio)
|
||||
ABI_STRUCT(RadVocabHeader)
|
||||
ABI_FIELD(RadVocabHeader, kind)
|
||||
ABI_FIELD(RadVocabHeader, n_tokens)
|
||||
ABI_FIELD(RadVocabHeader, n_merges)
|
||||
ABI_FIELD(RadVocabHeader, n_steps)
|
||||
ABI_FIELD(RadVocabHeader, tok_text_off)
|
||||
ABI_FIELD(RadVocabHeader, tok_score_off)
|
||||
ABI_FIELD(RadVocabHeader, tok_type_off)
|
||||
ABI_FIELD(RadVocabHeader, merge_off)
|
||||
ABI_FIELD(RadVocabHeader, step_off)
|
||||
ABI_FIELD(RadVocabHeader, bos)
|
||||
ABI_FIELD(RadVocabHeader, eos)
|
||||
ABI_FIELD(RadVocabHeader, eot)
|
||||
ABI_FIELD(RadVocabHeader, pad_id)
|
||||
ABI_FIELD(RadVocabHeader, unk)
|
||||
ABI_FIELD(RadVocabHeader, sep)
|
||||
ABI_FIELD(RadVocabHeader, add_bos)
|
||||
ABI_FIELD(RadVocabHeader, add_eos)
|
||||
ABI_FIELD(RadVocabHeader, chat_template)
|
||||
ABI_FIELD(RadVocabHeader, flags)
|
||||
ABI_FIELD(RadVocabHeader, reserved)
|
||||
ABI_STRUCT(RadVocabStep)
|
||||
ABI_FIELD(RadVocabStep, kind)
|
||||
ABI_FIELD(RadVocabStep, flags)
|
||||
ABI_FIELD(RadVocabStep, arg0)
|
||||
ABI_FIELD(RadVocabStep, arg1)
|
||||
ABI_FIELD(RadVocabStep, iarg)
|
||||
ABI_STRUCT(RadWeightDecl)
|
||||
ABI_FIELD(RadWeightDecl, dtype)
|
||||
ABI_FIELD(RadWeightDecl, rank)
|
||||
ABI_FIELD(RadWeightDecl, shape)
|
||||
ABI_FIELD(RadWeightDecl, access)
|
||||
ABI_FIELD(RadWeightDecl, shard)
|
||||
ABI_FIELD(RadWeightDecl, group)
|
||||
ABI_FIELD(RadWeightDecl, optional)
|
||||
ABI_FIELD(RadWeightDecl, n_row_parts)
|
||||
ABI_FIELD(RadWeightDecl, row_parts)
|
||||
ABI_FIELD(RadWeightDecl, source)
|
||||
ABI_FIELD(RadWeightDecl, planes)
|
||||
ABI_STRUCT(RadWeightGroup)
|
||||
ABI_FIELD(RadWeightGroup, layer)
|
||||
ABI_FIELD(RadWeightGroup, expert)
|
||||
ABI_FIELD(RadWeightGroup, slot)
|
||||
ABI_STRUCT(RadYarn)
|
||||
ABI_FIELD(RadYarn, factor)
|
||||
ABI_FIELD(RadYarn, low)
|
||||
ABI_FIELD(RadYarn, high)
|
||||
ABI_FIELD(RadYarn, magnitude)
|
||||
ABI_STRUCT(RadMtpCoupleDraw)
|
||||
ABI_FIELD(RadMtpCoupleDraw, seed)
|
||||
ABI_FIELD(RadMtpCoupleDraw, base)
|
||||
ABI_FIELD(RadMtpCoupleDraw, seq)
|
||||
ABI_FIELD(RadMtpCoupleDraw, card)
|
||||
ABI_FIELD(RadMtpCoupleDraw, mode)
|
||||
ABI_STRUCT(RadMtpCoupleState)
|
||||
ABI_FIELD(RadMtpCoupleState, draw)
|
||||
ABI_FIELD(RadMtpCoupleState, pos)
|
||||
ABI_FIELD(RadMtpCoupleState, status)
|
||||
ABI_FIELD(RadMtpCoupleState, round)
|
||||
ABI_FIELD(RadMtpCoupleState, x)
|
||||
ABI_FIELD(RadMtpCoupleState, count)
|
||||
ABI_FIELD(RadMtpCoupleState, ids)
|
||||
ABI_FIELD(RadMtpCoupleState, q)
|
||||
+311
-18
@@ -188,11 +188,20 @@ typedef struct RadBuildCtx {
|
||||
* 0, so an exact declare is unchanged. The engine refuses to start when no resolved kernel
|
||||
* takes it, so a plugin that ignores the field is refused rather than silently exact.
|
||||
*
|
||||
* Zero-defaulted and in the padding after kv_quant, so no other field moves and a plugin built
|
||||
* against the older struct is unchanged. */
|
||||
* Zero-defaulted and in the padding after kv_quant, so no other field moves. */
|
||||
int attn_prefill_fp8;
|
||||
|
||||
/* ---- appended in ABI 26 (control vectors) */
|
||||
/* ---- appended in ABI 30 (KV streaming) */
|
||||
/* --kv-resident in tokens, 0 when nothing streams: the ring a streamed group carves is this in
|
||||
* whole blocks, raised to the engine's floors and clamped to the context. A plugin states it as
|
||||
* its `kv_resolve`'s ring depth. */
|
||||
int64_t kv_resident_blocks;
|
||||
/* RadArchProbe::kv_stream_ok. The streamed-only ops (`kv_store_streamed`, its folded form,
|
||||
* `kv_resolve`) are declared only when this is set and kv_resident_blocks asks for a ring;
|
||||
* otherwise rad_op_declared says no and the plugin takes its resident path. */
|
||||
int kv_stream_ok;
|
||||
|
||||
/* ---- appended in ABI 27 (control vectors) */
|
||||
/* A control vector loaded from a GGUF `controlvector` file found for this model, or null.
|
||||
*
|
||||
* The engine loads and validates it once, at bringup, and the plugin only reads it: the
|
||||
@@ -208,6 +217,84 @@ typedef struct RadBuildCtx {
|
||||
*
|
||||
* Trailing and zero-defaulted, so a plugin built against the older struct is unchanged. */
|
||||
const struct RadControlVector* cvec;
|
||||
|
||||
/* ---- appended in ABI 27 (row-split prefill attention) */
|
||||
/* 1 from --tp-attn-split rows: from the plugin's split threshold, a prefill-sized step under
|
||||
* tensor parallelism runs attention by rows, each rank all heads of its run of the step's
|
||||
* rows and an all_gather of the runs, instead of by heads. It is faster where the attention
|
||||
* dominates, costs the full-width projections on every rank, and is not bit-identical to the
|
||||
* head split. 0 (the zero-initialised default) is the head split. The engine sets it only
|
||||
* above one rank and only for a plugin whose probe sets RadArchProbe::tp_attn_rows_ok, and
|
||||
* refuses the flag otherwise.
|
||||
*
|
||||
* Trailing and zero-defaulted, so a plugin built against the older struct is unchanged. */
|
||||
int tp_attn_rows;
|
||||
|
||||
/* ---- appended in ABI 27 (recurrent state at f16) */
|
||||
/* RAD_F16 from --state-cache-dtype f16: the recurrent state caches (RAD_KV_LINEAR groups) are
|
||||
* stored at f16 instead of the plugin's f32, which halves the state pool, its checkpoints and
|
||||
* its traffic and changes the generated text. 0 (the zero-initialised default) is the
|
||||
* plugin's own width. The engine sets it only for a plugin whose probe has
|
||||
* RadArchProbe::state_f16_ok and refuses the flag otherwise.
|
||||
*
|
||||
* Trailing and zero-defaulted, so a plugin built against the older struct is unchanged. */
|
||||
uint32_t state_dtype;
|
||||
|
||||
/* ---- appended in ABI 27 (draft coupling) */
|
||||
/* Nonzero from --draft-coupling on: a linear serial drafter samples each round's proposal from
|
||||
* its own shortlist law, or a block drafter's walk each position's (DFlash2), and declares the
|
||||
* planes and ops the coupled verify reads (abi/rad_spechub.h, docs/OPS.md `mtp_couple_propose`,
|
||||
* `dflash_couple_propose`). 0, the zero-initialised default,
|
||||
* declares the greedy drafter. A plugin that cannot couple returns RAD_E_UNSUPPORTED from
|
||||
* declare when it is set; the engine refuses a model whose program carries no coupled planes.
|
||||
*
|
||||
* Trailing and zero-defaulted, so a plugin built against the older struct is unchanged. */
|
||||
int draft_coupling;
|
||||
|
||||
/* ---- appended in ABI 28 (weight prefetch) */
|
||||
/* Nonzero from --weight-prefetch off: the plugin declares none of its weight prefetches, the
|
||||
* reads of a following GEMM's weight beside a collective (arch/common/rad_arch.h
|
||||
* prefetch_beside). An engine that shares its cards with another server sets it: where the
|
||||
* read goes on the second lane, the two servers hold more compute queues than a card has
|
||||
* slots, and the join from the first lane puts a queue switch into every decode step. 0, the
|
||||
* zero-initialised default, prefetches where the plugin does.
|
||||
*
|
||||
* Trailing and zero-defaulted, so a plugin built against the older struct is unchanged. */
|
||||
int weight_prefetch_off;
|
||||
|
||||
/* ---- appended in ABI 31 (tree verification) */
|
||||
/* Nonzero: grow the block drafter's proposals into a tree (rad_drafter_tree) where the plugin
|
||||
* can. The engine sets it where the plugin's probe said trees pay (RadArchProbe::tree_pays)
|
||||
* and the drafter decodes speculatively; 0 keeps the chain. A plugin that grows no trees
|
||||
* ignores it. 64-bit so it starts past the older
|
||||
* struct's tail padding, where a plugin built against it would read nothing.
|
||||
*
|
||||
* Trailing and zero-defaulted, so a plugin built against the older struct is unchanged. */
|
||||
int64_t draft_tree;
|
||||
|
||||
/* ---- appended in ABI 32 (calibration) */
|
||||
/* --calib-dir DIR: the deployment records calibration statistics (the second moment of each
|
||||
* linear's input, GPTQ's Hessian) into DIR; null records nothing. A plugin that keeps none
|
||||
* ignores it. `calib_layer_lo`..`calib_layer_hi` (--calib-layers, hi exclusive; both 0 for
|
||||
* every layer) bound the layers recorded in one run, so a model whose statistics do not fit
|
||||
* in memory at once is recorded in several runs over the same corpus. `calib_tokens` is the
|
||||
* corpus's token count under --calib-corpus: the plugin writes its files once it has seen
|
||||
* that many rows; 0 when the deployment drives no corpus.
|
||||
*
|
||||
* Trailing and zero-defaulted, so a plugin built against the older struct is unchanged. */
|
||||
const char* calib_dir;
|
||||
int32_t calib_layer_lo;
|
||||
int32_t calib_layer_hi;
|
||||
int64_t calib_tokens;
|
||||
|
||||
/* ---- appended in ABI 32 (an image generator's bounds) */
|
||||
/* --image-gen-max-pixels: the largest image an image generator makes, in pixels; and
|
||||
* --image-gen-max-refs: the reference pictures a request at most. 0: the model's own. A
|
||||
* generator sizes its per-image and conditioning buffers for them and states them in its
|
||||
* RadGeneratorDecl (max_tokens, max_refs), which the core holds requests to; one that keeps
|
||||
* fixed buffers ignores them, and the core says so at startup. */
|
||||
int64_t gen_max_pixels;
|
||||
int64_t gen_max_refs;
|
||||
} RadBuildCtx;
|
||||
|
||||
/* ================================================================== control vectors */
|
||||
@@ -396,6 +483,10 @@ typedef struct RadKVGroupDecl {
|
||||
rad_kvgroup rad_decl_kv_group(RadBuilder* b, const char* name, const RadKVGroupDecl* d);
|
||||
/* Valid only after the op that reads this group has been declared. 0 before that. */
|
||||
int64_t rad_kv_block_size(RadBuilder* b, rad_kvgroup g);
|
||||
/* Bytes one block of one layer of a paged group occupies: its pool slot's pitch and its host
|
||||
* mirror row's. 0 for a group that is not paged, or before the block size is known. Additive
|
||||
* export. */
|
||||
int64_t rad_kv_layer_bytes(RadBuilder* b, rad_kvgroup g);
|
||||
|
||||
/* Bind a layer to a group, so the block manager knows how many state instances a sequence owns. */
|
||||
int rad_bind_layer_kv(RadBuilder* b, int layer, rad_kvgroup g);
|
||||
@@ -446,6 +537,17 @@ int rad_op_writes(RadBuilder* b, rad_op h, const rad_buf* bufs, int n);
|
||||
* A no-op for a PERSIST or DERIVED buffer, which is live everywhere already. */
|
||||
int rad_buf_concurrent(RadBuilder* b, rad_buf buf);
|
||||
|
||||
/* ---- appended in ABI 27 (the second lane's window) */
|
||||
/* The second lane's window: every op the architecture issues on lane 1 is declared between
|
||||
* rad_lane1_window_begin and rad_lane1_window_end. With a window a rad_buf_concurrent buffer is live
|
||||
* over the window and its own declared uses instead of the whole program, so buffers used only
|
||||
* outside the window (a drafter's, the heads') can share its bytes. The runtime holds the
|
||||
* architecture to it: an op issued on lane 1 outside the window fails the step by name, and an op
|
||||
* issued on lane 0 outside the window joins lane 1 first when lane 1 has work pending. Optional, one
|
||||
* window a program; call both at declare, in order. */
|
||||
int rad_lane1_window_begin(RadBuilder* b);
|
||||
int rad_lane1_window_end(RadBuilder* b);
|
||||
|
||||
/* An uneven shard: this rank's slice of a RAD_SHARD_ROW or RAD_SHARD_COL weight's split dimension
|
||||
* is [lo, hi) rather than an even 1/tp. Rows of each stacked row part for ROW, columns for COL, in
|
||||
* the container's unsharded units. The declared extent must already be `hi - lo` (per row part,
|
||||
@@ -483,9 +585,16 @@ int rad_kv_group_zero(RadBuilder* b, rad_kvgroup g);
|
||||
* rank computes whole, an indexer's key cache every rank pools into); the engine moves bytes and
|
||||
* cannot know. RADIANCE_DEBUG_TIER_VERIFY checks the claim: each follower hashes what it would
|
||||
* have written and the leader compares. Paged groups only, and never a group this rank declared
|
||||
* zero. No effect at one rank. Additive export; RAD_ABI_VERSION does not move. */
|
||||
* zero. No effect at one rank, and none on a group that streams, whose host mirror is its tier.
|
||||
* Additive export. */
|
||||
int rad_kv_group_replicated(RadBuilder* b, rad_kvgroup g);
|
||||
|
||||
/* The group is read over its whole history every decode step (an indexer's block keys), so it
|
||||
* cannot stream. While a sibling group streams, its carve holds every sequence's full context
|
||||
* rather than the split's share, as the sibling's host mirror holds --max-num-seqs sequences.
|
||||
* Additive export. */
|
||||
int rad_kv_group_dense_read(RadBuilder* b, rad_kvgroup g);
|
||||
|
||||
#define RAD_BUFS(...) ((const rad_buf[]){ __VA_ARGS__ }), \
|
||||
(int)(sizeof((const rad_buf[]){ __VA_ARGS__ }) / sizeof(rad_buf))
|
||||
|
||||
@@ -522,7 +631,10 @@ typedef struct RadNameMap {
|
||||
|
||||
/* RAD_MAP_ROWS only: piece i is rows [src_index[i], src_index[i] + src_rows[i]) of the 2-D (or
|
||||
* higher, rows along dim 0) tensor src[i]; the pieces join along dim 0. RAD_MAP_COLS: columns
|
||||
* [src_index[0], src_index[0] + src_rows[0]) of src[0]'s last dimension. */
|
||||
* [src_index[0], src_index[0] + src_rows[0]) of src[0]'s last dimension. RAD_MAP_TRANSPOSE with
|
||||
* src_index[0] >= 0: rows [src_index[0] * src_rows[0], (src_index[0] + 1) * src_rows[0]) when
|
||||
* src[0] is rank 2 and src_rows[0] > 0 (a stack flattened over rows); otherwise src_index[0] is
|
||||
* the dim-0 sub-tensor of a higher-rank stack. */
|
||||
int64_t src_rows[8];
|
||||
} RadNameMap;
|
||||
|
||||
@@ -549,7 +661,9 @@ typedef struct RadNameMap {
|
||||
* columns it is fed.
|
||||
*
|
||||
* RAD_MAP_TRANSPOSE swaps the last two dimensions of src[0] in each leading slice, [.., a, b] to
|
||||
* [.., b, a]: a linear a checkpoint keeps as (in, out), where the GEMMs read (out, in).
|
||||
* [.., b, a]: a linear a checkpoint keeps as (in, out), where the GEMMs read (out, in). With
|
||||
* src_index[0], it first takes one expert's sub-tensor (see src_rows): a stacked expert table kept
|
||||
* [n_expert, in, out] or flattened [n_expert * in, out].
|
||||
*
|
||||
* RAD_MAP_EMA is an exponential-moving-average codebook as EnCodec-style quantisers keep it: src[0]
|
||||
* the embedding sums [bins, ...], src[1] the cluster usage [bins], and the codebook is each row
|
||||
@@ -581,6 +695,17 @@ int rad_decl_name_map(RadBuilder* b, const RadNameMap* m);
|
||||
* embedding-only or encoder-only plugin declares none. */
|
||||
int rad_declare_logits(RadBuilder* b, rad_buf logits);
|
||||
|
||||
/* Scored steps (RadBatch::score_only). A plugin whose lm_head is the bf16 table `table`
|
||||
* ([n_vocab, n_embd], e.g. a tied embedding, whatever encoding the head itself is read at) and
|
||||
* whose final-normed rows land in `hidden` ([rows, n_embd] bf16, row k the step's k-th sampled row,
|
||||
* as the lm_head reads them) declares both here. On a step where every sampled row is a scored row
|
||||
* the core sets RadBatch::score_only, the plugin issues everything but the lm_head, and the core
|
||||
* reads the hidden rows and the candidates' table rows back and takes the dot products on the host
|
||||
* in f64: the logits a scored request returns, at no head read on the card (half a gigabyte a step
|
||||
* at a 128K bf16 vocabulary). Optional; one rank only (the core ignores it at --tp > 1).
|
||||
* Additive export; RAD_ABI_VERSION does not move. */
|
||||
int rad_declare_scores(RadBuilder* b, rad_buf hidden, rad_weight table);
|
||||
|
||||
/* Which buffer holds this step's pooled vectors, what an embedding model returns instead of
|
||||
* logits. Row s is sequence s's whole input pooled into one vector, with whatever pooling the
|
||||
* model was trained with (a mean, the last token, a CLS row). The core reads rows [0, n_seq) back
|
||||
@@ -598,6 +723,11 @@ int rad_declare_logits(RadBuilder* b, rad_buf logits);
|
||||
* this or logits, never both. */
|
||||
int rad_declare_pooled(RadBuilder* b, rad_buf pooled);
|
||||
|
||||
/* The most integer words one request may hand the plugin (RadBatch::plugin_words), 0 for none.
|
||||
* The engine stages that many a sequence in the step batch and refuses a longer request before
|
||||
* it is admitted, so the plugin reads its words at the size it declared. Additive export. */
|
||||
int rad_declare_plugin_words(RadBuilder* b, int64_t max_words);
|
||||
|
||||
|
||||
/* ================================================================== the drafter */
|
||||
/* The plugin's draft head. The core drives the extra passes, and only the plugin knows what it
|
||||
@@ -626,7 +756,8 @@ typedef struct RadDrafterDecl {
|
||||
|
||||
/* Where a pass leaves its proposal. 0 = the sampler's token buffer. */
|
||||
rad_buf proposal;
|
||||
int64_t proposal_pitch; /* elements a row in `proposal`; 0 means 1 */
|
||||
int64_t proposal_pitch; /* elements a row in `proposal`; 0 means 1, and for a BLOCK
|
||||
* drafter `depth` (less is refused) */
|
||||
|
||||
/* BLOCK only. `mask_token` is the id every unfilled block position embeds; a block drafter
|
||||
* without one cannot run. `window` is the drafter's own sliding window over its own cache, 0
|
||||
@@ -678,6 +809,25 @@ int rad_declare_drafter(RadBuilder* b, const RadDrafterDecl* d);
|
||||
* checkpoint was trained with is the plugin's to know. */
|
||||
int rad_drafter_shared_kv(RadBuilder* b, int pos_offset);
|
||||
|
||||
/* A block drafter whose one pass proposes a tree rather than a chain. Called once, after
|
||||
* rad_declare_drafter. `parents` is an i32 buffer at the proposal's pitch: row i's j-th entry is
|
||||
* the parent of the proposal's j-th token as a node index, 0 for the token the verify starts from
|
||||
* (the bonus token) and j' + 1 for the proposal's j'-th token, with every parent before its child.
|
||||
* Additive export; RAD_ABI_VERSION does not move.
|
||||
*
|
||||
* Each verify then runs the proposal as a tree in the same rows: node j at row j, rotated at the
|
||||
* committed end + its depth, its K and V stored at the committed end + j, and every trunk step
|
||||
* carries RadBatch::spec_parent, which the plugin hands its attention so a row sees, inside its
|
||||
* own block, only its ancestors. The acceptance follows the deepest root path the target agrees
|
||||
* with; the core then moves that path's K and V into place in every paged group. A proposal from
|
||||
* prompt lookup is verified as the chain-shaped tree.
|
||||
*
|
||||
* Requirements on the plugin: the trunk's attention honours spec_parent on every decode row; the
|
||||
* drafter's context pass stores K and V through the slot mapping only (it is staged per node, the
|
||||
* rejected ones at slot -1); and the step is issued ahead, behind which the block driver queues
|
||||
* the drafter's passes (the KL mode drafts nothing, so trees do not apply there). */
|
||||
int rad_drafter_tree(RadBuilder* b, rad_buf parents);
|
||||
|
||||
/* Whether this engine's launches chain (RadKernelChainFn, abi/rad_abi.h): the core's decision, on
|
||||
* the AQL backend only, which keeps a completion counter per queue, where the model's plugin
|
||||
* measured a gain with its speculative drafter (RadArchProbe::chain_pays) and that drafter decodes
|
||||
@@ -686,6 +836,20 @@ int rad_drafter_shared_kv(RadBuilder* b, int pos_offset);
|
||||
* that decision. Additive export; RAD_ABI_VERSION does not move. */
|
||||
int rad_chain_on(void);
|
||||
|
||||
/* A block drafter that also serves a shorter block: the plugin declared its query pass at `block`
|
||||
* rows a sequence as well as at RadDrafterDecl::block, with the same anchor convention, so the
|
||||
* core may stage a step's block at either. The short block proposes
|
||||
* `block - (RadDrafterDecl::block - depth)` tokens; a tree drafter's (rad_drafter_tree, declared
|
||||
* first) a tree of its own over the shorter pass, at most `block - 1` nodes, which needs only that
|
||||
* the short block be 2 rows or more. Called once, after rad_declare_drafter.
|
||||
*
|
||||
* The block is proposed whole, so its length is paid for by every drafting sequence whatever each
|
||||
* verifies: at one sequence a long block's extra drafts pay, at many its rows and its weaker first
|
||||
* positions cost more than they bring. The core picks per step (--draft-short-from; by default
|
||||
* a tree's from two decoding sequences on, a chain's never). */
|
||||
/* ---- appended in ABI 27 (a block drafter's short block) */
|
||||
int rad_drafter_short_block(RadBuilder* b, int64_t block);
|
||||
|
||||
/* ================================================================== the encoder */
|
||||
/* A media encoder the plugin runs on an encoder pass (RadBatch::enc). The core drives the pass and
|
||||
* reads its result, so the plugin declares it. A plugin that declares none serves text only, and
|
||||
@@ -997,7 +1161,8 @@ typedef struct RadAudioGenDecl {
|
||||
/* The prompt, as text the core tokenises: `{instructions}` is replaced by the request's
|
||||
* instructions (a piece's description, a voice's) and `{input}` by its input text (lyrics, the
|
||||
* words to speak), each first rewritten by the plugin's rad_arch_text_prepare when it exports
|
||||
* one. Special tokens are spelled as text. */
|
||||
* one. Special tokens are spelled as text. NULL for a model that takes no instructions, which
|
||||
* then declares `tmpl_plain` and has a request's instructions refused. */
|
||||
const char* tmpl;
|
||||
/* The unconditional branch is the conditional prompt with every token but the first
|
||||
* `neg_keep_head` and the last `neg_keep_tail` replaced by `neg_token`, so the two branches
|
||||
@@ -1058,6 +1223,36 @@ typedef struct RadAudioGenDecl {
|
||||
* latent: `lat_num` = `lat_den` = 1, `samples_per_latent` samples a frame. */
|
||||
int64_t voc_chunk;
|
||||
int64_t voc_context;
|
||||
|
||||
/* ---- appended in ABI 27 (one-branch speech over a hybrid model, references) */
|
||||
/* Sequences a request runs: 0 or 2, the conditional and unconditional branches above; 1, the
|
||||
* conditional one alone, for a model without guidance (no unconditional prompt is rendered,
|
||||
* a request's guidance must be 1, and every per-entry array of a PROMPT or FRAME pass has one
|
||||
* entry a lane, its `slot` the lane itself). The KV, the prompt's rows and a frame's rows then
|
||||
* cost half. */
|
||||
int32_t branches;
|
||||
/* Nonzero: the `{input}` slot is tokenised with its special tokens, which the template's own
|
||||
* text always is, so a caller can write the model's speaker tags. The plugin's
|
||||
* rad_arch_text_prepare then refuses the control tokens a caller must not write. */
|
||||
int32_t input_special;
|
||||
/* References (voice cloning): with `tmpl_ref`, a request may carry up to `ref_max` of them,
|
||||
* each a transcript and a clip of the voice saying it, which the plugin encodes into frames
|
||||
* in the request's PROMPT pass (whole prompts only: `prompt_whole`). `tmpl_ref` is the prompt
|
||||
* of a request with references, `{references}` each of them rendered from `ref_item` in turn
|
||||
* and `{input}` as in `tmpl_plain`. `ref_item` is one reference: `{index}` its number from 1,
|
||||
* `{text}` its transcript (rewritten by rad_arch_text_prepare as RAD_TEXT_REFERENCE) and
|
||||
* `{audio}` its frames, one prompt row each (RadAudioGenBatch::ref_frame); the text before
|
||||
* `{audio}` is tokenised as one segment with its special tokens (the transcript's own, which
|
||||
* prepare() has limited to those a caller may write), and so is the text after it. A clip is
|
||||
* mono f32 in [-1, 1] at `ref_rate`, right-padded with zeros to a whole number of `ref_hop`
|
||||
* samples, each `ref_hop` samples one frame; a request's clips hold at most `ref_max_samples`
|
||||
* samples together. NULL `tmpl_ref`: references are refused. */
|
||||
const char* tmpl_ref;
|
||||
const char* ref_item;
|
||||
int64_t ref_rate;
|
||||
int64_t ref_hop;
|
||||
int64_t ref_max_samples;
|
||||
int32_t ref_max;
|
||||
} RadAudioGenDecl;
|
||||
|
||||
int rad_declare_audio_generator(RadBuilder* b, const RadAudioGenDecl* d);
|
||||
@@ -1120,9 +1315,27 @@ int rad_declare_audio_generator(RadBuilder* b, const RadAudioGenDecl* d);
|
||||
* pass carries the geometry its latent has at that point: a step before the VUPSCALE pass is at
|
||||
* W' x H'. The schedule is the request's own, whatever size each evaluation runs at.
|
||||
*
|
||||
* Reference conditioning, for a plugin with the VAE encoders (`max_enc_side`, `max_enc_samples`,
|
||||
* below): before the prompt pass each of a request's reference media and keyframes is encoded,
|
||||
* one a pass, into the lane, where the steps read it. Nothing an encode makes is read back.
|
||||
*
|
||||
* RAD_GEN_PASS_VENCODE one picture or video, its frames in `enc_pixels` (RadVideoGenBatch),
|
||||
* through the video VAE's encoder.
|
||||
* RAD_GEN_PASS_AENCODE one soundtrack, its samples in `enc_samples`, through the audio VAE's
|
||||
* encoder.
|
||||
*
|
||||
* `enc_kind` (RAD_ENC_*, rad_runtime.h) and `enc_slot`, the media's 1-based number within its kind,
|
||||
* say where the latents go. A latent-upscaled request's keyframes, pinned on the grid its steps
|
||||
* run on, are encoded at W' x H' before the prompt pass, then again at W x H into the same slots
|
||||
* after the VUPSCALE pass and before the first evaluation at W x H. References, on their own grid,
|
||||
* are encoded once. The media's shape is the plugin's to accept: rad_arch_encode_geom
|
||||
* (below) refuses what the encoders cannot take, and the step's packed sequence with the encoded
|
||||
* media in it is the plugin's rad_arch_video_pack.
|
||||
*
|
||||
* A program declares exactly one of this, the other generators, logits or pooled vectors. */
|
||||
enum { RAD_GEN_PASS_VCOND = 8, RAD_GEN_PASS_VSTEP = 9, RAD_GEN_PASS_ADECODE = 10,
|
||||
RAD_GEN_PASS_VDECODE = 11, RAD_GEN_PASS_VUPSCALE = 12 };
|
||||
RAD_GEN_PASS_VDECODE = 11, RAD_GEN_PASS_VUPSCALE = 12,
|
||||
RAD_GEN_PASS_VENCODE = 13, RAD_GEN_PASS_AENCODE = 14 };
|
||||
|
||||
typedef struct RadVideoGenDecl {
|
||||
const char* name; /* "minimax-h3" -- the served model id and messages */
|
||||
@@ -1240,6 +1453,20 @@ typedef struct RadVideoGenDecl {
|
||||
* Null: one decoder. */
|
||||
const char* decoders;
|
||||
const int64_t* decoder_max_area;
|
||||
|
||||
/* ---- appended in ABI 31 (MiniMax-H3 reference conditioning, above) */
|
||||
/* The reference media a request may carry: pictures, videos (each with an optional soundtrack
|
||||
* of its own) and standalone soundtracks. 0 for none of a kind; a plugin that declares any
|
||||
* exports rad_arch_video_pack. */
|
||||
int64_t max_ref_images, max_ref_videos, max_ref_audios;
|
||||
/* What one encode pass carries: a video's frames after rad_arch_encode_geom pads them to whole
|
||||
* clips, a frame's longer side and a soundtrack's samples. `max_enc_side` 0: no video encoder,
|
||||
* `max_enc_samples` 0: no audio encoder. A picture's sides are multiples of `enc_ratio`. */
|
||||
int64_t max_enc_frames, max_enc_side, max_enc_samples;
|
||||
int32_t enc_ratio;
|
||||
/* The distinct modulations a step's groups may read (rad_arch_video_pack's `mod`, the highest
|
||||
* cell + 1); a request needing more is refused at submit. 0: no limit. */
|
||||
int32_t max_mod_cells;
|
||||
} RadVideoGenDecl;
|
||||
|
||||
int rad_declare_video_generator(RadBuilder* b, const RadVideoGenDecl* d);
|
||||
@@ -1343,9 +1570,41 @@ typedef struct RadArchProbe {
|
||||
* then takes them. Zero keeps them off: plain decode measured slower chained, and a plugin
|
||||
* that never measured them asks for nothing. */
|
||||
int32_t chain_pays;
|
||||
/* ---- appended in ABI 30 (KV streaming) */
|
||||
/* Nonzero when the architecture can stream a KV group between host memory and a VRAM ring: its
|
||||
* attention is sparse and block-addressed and it declares a streamed store and `kv_resolve`.
|
||||
* --kv-resident on an architecture that says 0 is turned off at startup, and nothing streamed
|
||||
* is declared (RadBuildCtx::kv_stream_ok). */
|
||||
int32_t kv_stream_ok;
|
||||
/* Nonzero when the plugin applies RadBuildCtx::cvec for this model. --control-vector is
|
||||
* refused at startup with the plugin named when this is 0. */
|
||||
int32_t control_vector_ok;
|
||||
|
||||
/* ---- appended in ABI 27 (row-split prefill attention) */
|
||||
/* Nonzero when the plugin serves RadBuildCtx::tp_attn_rows for this model. --tp-attn-split
|
||||
* rows is refused at startup with the plugin named when this is 0. */
|
||||
int32_t tp_attn_rows_ok;
|
||||
|
||||
/* ---- appended in ABI 27 (recurrent state at f16) */
|
||||
/* Nonzero when the plugin declares its recurrent state at f16 under RadBuildCtx::state_dtype
|
||||
* and its kernels read that width. --state-cache-dtype f16 is refused at startup with the
|
||||
* plugin named when this is 0. */
|
||||
int32_t state_f16_ok;
|
||||
|
||||
/* ---- appended in ABI 31 (tree verification) */
|
||||
/* Nonzero when this plugin can grow its block drafter's proposals into a tree
|
||||
* (rad_drafter_tree) and measured its speculative step faster with one. The core then asks for
|
||||
* a tree (RadBuildCtx::draft_tree) wherever that drafter decodes speculatively. Zero keeps the
|
||||
* chain: a plugin that never measured trees asks for none. 64-bit so it starts past the older
|
||||
* struct's tail padding, which a plugin built against it may copy over. */
|
||||
int64_t tree_pays;
|
||||
|
||||
/* ---- appended in ABI 32 (inputs: an image generator's bounds) */
|
||||
/* Set by the core before the call: --image-gen-max-pixels and --image-gen-max-refs, as
|
||||
* RadBuildCtx carries them to declare (0: the model's own). A generator's gen_rows and
|
||||
* gen_patches answer for them. */
|
||||
int64_t gen_max_pixels;
|
||||
int64_t gen_max_refs;
|
||||
} RadArchProbe;
|
||||
|
||||
int rad_arch_probe(const RadModelMeta* meta, RadArchProbe* out);
|
||||
@@ -1363,6 +1622,12 @@ int rad_arch_probe(const RadModelMeta* meta, RadArchProbe* out);
|
||||
* arg_prefix ARG arg_name_suffix arg_value_prefix VALUE arg_value_suffix ...
|
||||
* call_end [call_close]
|
||||
*
|
||||
* An argument's tag may also say its value's type, with arg_json_value_prefix written in place of
|
||||
* arg_value_prefix before a JSON value. DeepSeek-V4.1's DSML, inside a section
|
||||
* "<|DSML| calls>" / "</|DSML| calls>", is "<|DSML| invoke name=\"" / "\">\n" / "</|DSML| invoke>",
|
||||
* arguments "<|DSML| parameter name=\"" / "\"" / " string=\"true\">" (or
|
||||
* " string=\"false\">") / "</|DSML| parameter>".
|
||||
*
|
||||
* Qwen3.8, for example, is "<think>\n" / "\n</think>\n\n", calls "<tool_call>\n" / "</tool_call>",
|
||||
* "<function=" / ">\n" / "</function>\n", arguments "<parameter=" / ">\n" / "" / "</parameter>\n".
|
||||
* Whitespace at the ends of a tag is optional when matching. Every string is NUL-terminated
|
||||
@@ -1412,14 +1677,13 @@ typedef struct RadChatFormat {
|
||||
const char* reasoning_open; /* "" when the model does not reason */
|
||||
const char* reasoning_close;
|
||||
/* Literals that end a reasoning block the model forgot to close, when a call starts there.
|
||||
* Each must be the call opener: `call_open`, or `name_prefix` when there is no call_open. */
|
||||
* Each must be a call opener (`call_open`, or `name_prefix` without one) or section_open. */
|
||||
const char* const* reasoning_breaks;
|
||||
uint32_t n_reasoning_breaks;
|
||||
uint32_t reasoning_in_prompt; /* RAD_CHAT_THINK_* */
|
||||
|
||||
/* Around all of a turn's calls, and between two calls beyond whitespace. The parser does not
|
||||
* read these yet, so a format that sets one is refused at startup by name; they are fields so
|
||||
* supporting them later does not change the struct. */
|
||||
/* Around the complete list of calls. section_open and section_close must be set together.
|
||||
* call_separator is additional text between calls beyond whitespace; it is not supported. */
|
||||
const char* section_open;
|
||||
const char* section_close;
|
||||
const char* call_separator;
|
||||
@@ -1464,6 +1728,12 @@ typedef struct RadChatFormat {
|
||||
* calls) and is read as reasoning there too, and a reasoning_close with no block open is not
|
||||
* part of the answer. Zero: only a block the reply starts with is reasoning. */
|
||||
uint32_t reasoning_anywhere;
|
||||
|
||||
/* Tagged arguments whose tag says the value's type: written in place of arg_value_prefix,
|
||||
* this opens a JSON value, and arg_value_prefix then opens a string. The tag the reply writes
|
||||
* decides how its value is read, whatever the schema says; the grammar writes the one the
|
||||
* schema calls for. NULL: the schema alone types a value. */
|
||||
const char* arg_json_value_prefix;
|
||||
} RadChatFormat;
|
||||
|
||||
/* Return the format, or NULL for "derive it from the chat template". Called once at startup. */
|
||||
@@ -1524,11 +1794,13 @@ const RadAudioFormat* rad_arch_audio_format(const RadModelMeta* meta);
|
||||
* as given. Training data has conventions a client does not know -- section tags on lines of
|
||||
* their own and lower case, no markdown in a description -- and only the plugin knows them.
|
||||
*
|
||||
* `field` is RAD_TEXT_*, `in` NUL-terminated UTF-8. Writes at most `cap` bytes, the NUL included,
|
||||
* and returns the length the whole result needs without its NUL (call again with more room when
|
||||
* it is >= cap), or a negative status for text the model cannot take. Called on HTTP threads, so
|
||||
* it keeps no state. */
|
||||
enum { RAD_TEXT_INSTRUCTIONS = 1, RAD_TEXT_INPUT = 2 };
|
||||
* `field` is RAD_TEXT_*, `in` NUL-terminated UTF-8: the instructions, the input, or a
|
||||
* reference's transcript (RadAudioGenDecl::ref_item's `{text}`). Writes at most `cap` bytes, the
|
||||
* NUL included, and returns the length the whole result needs without its NUL (call again with
|
||||
* more room when it is >= cap), or a negative status for text the model cannot take, with the
|
||||
* reason in `out` (NUL-terminated within `cap`) when it has one to give the caller. Called on
|
||||
* HTTP threads, so it keeps no state. */
|
||||
enum { RAD_TEXT_INSTRUCTIONS = 1, RAD_TEXT_INPUT = 2, RAD_TEXT_REFERENCE = 3 };
|
||||
int64_t rad_arch_text_prepare(int field, const char* in, char* out, int64_t cap);
|
||||
|
||||
/* The layout of a video generator's passes (rad_declare_video_generator), which only the model
|
||||
@@ -1548,6 +1820,27 @@ typedef struct RadVideoGeom {
|
||||
enum { RAD_VPOS_STEP = 1, RAD_VPOS_DECODE = 2 };
|
||||
int64_t rad_arch_video_positions(int which, const RadVideoGeom* g, float* pos, int64_t cap);
|
||||
|
||||
/* The geometry of an encode pass (RAD_GEN_PASS_VENCODE, RAD_GEN_PASS_AENCODE): the int32s the
|
||||
* driver stages verbatim in RadVideoGenBatch::enc_geom_d for the plugin's kernels. `kind` is the
|
||||
* pass; `in` is {frames or samples, height, width, channels}, 0 where unused. With `out` null it
|
||||
* returns the count, with `out` it fills out[cap]; negative for media the encoders cannot take.
|
||||
* Entry 0 of an Aencode geometry is the samples padded to the encoder's hop, entry 23 of a Vencode
|
||||
* geometry the frames padded to whole clips and entry 24 its latent frames: the driver stages the
|
||||
* media padded to those lengths. A plugin with encoders exports it. Called on any thread. */
|
||||
int64_t rad_arch_encode_geom(int32_t kind, const int64_t* in, int32_t* out, int64_t cap);
|
||||
|
||||
/* The packed sequence of a step with reference media or keyframes in: `ref_tab` is
|
||||
* RadVideoGenBatch::ref_tab. Returns the sequence's rows, the rows RAD_VPOS_STEP would position, or
|
||||
* a negative status. `seg` receives the segment boundaries (seg[0] = 0, the last the rows) and
|
||||
* `mod` the boundaries of the modulation groups, then the cell each group reads (groups that read
|
||||
* the same modulation share a cell, numbered from 0); `*n_seg` and `*n_mod` are their capacities
|
||||
* in and their counts out, and a null array asks for the count alone. `pos` receives the rotary
|
||||
* positions, f32 [3, rows], when `cap_pos` holds 3 x rows. A plugin that declares reference media
|
||||
* exports it. Called on any thread. */
|
||||
int64_t rad_arch_video_pack(const RadVideoGeom* g, const int32_t* ref_tab, int32_t* seg,
|
||||
int32_t* n_seg, int32_t* mod, int32_t* n_mod, float* pos,
|
||||
int64_t cap_pos);
|
||||
|
||||
int rad_arch_declare(RadBuilder* b, const RadModelMeta* meta, const RadBuildCtx* ctx);
|
||||
/* Forward declaration; the signature is in rad_runtime.h. */
|
||||
struct RadCtx;
|
||||
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
/* rad_clef.h -- the words a clef request hands its head (RadBatch::plugin_words).
|
||||
*
|
||||
* clef's joint schema head (arch/common/rad_block_clef.h) reads more of a request than its
|
||||
* tokens: which prompt positions hold each question's instructions and each option's text, each
|
||||
* option's token ids (the lm_head rows it averages), and each question's type. The server lays
|
||||
* them out with the functions below, in the forms the head's kernels read (a cu_seqlens here, a
|
||||
* gather index there), and the engine carries them to the plugin as one range of int32 words.
|
||||
* Both sides include this header, so the layout is stated once.
|
||||
*
|
||||
* Plain C, like every abi/ header: the plugin is built apart from the engine.
|
||||
*/
|
||||
#ifndef RAD_CLEF_H
|
||||
#define RAD_CLEF_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* The bounds the head's buffers are declared at. A request past one is refused by the server. */
|
||||
enum {
|
||||
RAD_CLEF_MAX_QUESTIONS = 64,
|
||||
RAD_CLEF_MAX_OPTIONS = 512, /* every question's options together */
|
||||
RAD_CLEF_MAX_LEX = 8192, /* every option's tokens together */
|
||||
/* Prompt tokens. The head gathers every row of a prompt into buffers of its own, so this,
|
||||
* not the deployment's context, sizes them: at the model's own 262144 they would take
|
||||
* 4.5 GiB of the card for prompts that never pass a fifth of it. */
|
||||
RAD_CLEF_MAX_PROMPT = 32768
|
||||
};
|
||||
|
||||
/* The header: word 0 is the engine's (RadBatch::plugin_words), the rest the counts the layout is
|
||||
* computed from. */
|
||||
enum {
|
||||
RAD_CLEF_W_ROW = 0, /* the sequence's logits row this step, written by the engine */
|
||||
RAD_CLEF_W_N = 1, /* prompt tokens */
|
||||
RAD_CLEF_W_Q = 2, /* questions */
|
||||
RAD_CLEF_W_O = 3, /* options, every question together, in head order */
|
||||
RAD_CLEF_W_L = 4, /* option tokens, every option together */
|
||||
RAD_CLEF_W_S = 5, /* segments the prompt is cut into at every span's edges */
|
||||
RAD_CLEF_HDR = 8
|
||||
};
|
||||
|
||||
/* Where each array starts, in words from the range's start. Every array is int32. */
|
||||
typedef struct RadClefWords {
|
||||
int32_t n, q, o, l, s;
|
||||
int32_t seg_cu; /* [s + 1]: a partition of [0, n) with a boundary at every span's edges */
|
||||
int32_t q_seg; /* [q]: the segment holding each question's instructions */
|
||||
int32_t o_seg; /* [o]: the segment holding each option's text */
|
||||
int32_t o_q; /* [o]: each option's question */
|
||||
int32_t opt_cu; /* [q + 1]: each question's options, consecutive */
|
||||
int32_t type; /* [q]: 0 noul, 1 choice, 2 score */
|
||||
int32_t lex_cu; /* [o + 1]: each option's tokens in lex_ids, consecutive */
|
||||
int32_t lex_ids; /* [l]: the option tokens, as the prompt holds them */
|
||||
int32_t last; /* [1]: n - 1, the prompt's last position */
|
||||
int32_t cu_q; /* [2]: {0, q} */
|
||||
int32_t cu_o; /* [2]: {0, o} */
|
||||
int32_t cu_k; /* [2]: {0, n} */
|
||||
int32_t total; /* words in all */
|
||||
} RadClefWords;
|
||||
|
||||
static inline RadClefWords rad_clef_words_layout(int32_t n, int32_t q, int32_t o, int32_t l,
|
||||
int32_t s) {
|
||||
RadClefWords w;
|
||||
int32_t at = RAD_CLEF_HDR;
|
||||
w.n = n; w.q = q; w.o = o; w.l = l; w.s = s;
|
||||
w.seg_cu = at; at += s + 1;
|
||||
w.q_seg = at; at += q;
|
||||
w.o_seg = at; at += o;
|
||||
w.o_q = at; at += o;
|
||||
w.opt_cu = at; at += q + 1;
|
||||
w.type = at; at += q;
|
||||
w.lex_cu = at; at += o + 1;
|
||||
w.lex_ids = at; at += l;
|
||||
w.last = at; at += 1;
|
||||
w.cu_q = at; at += 2;
|
||||
w.cu_o = at; at += 2;
|
||||
w.cu_k = at; at += 2;
|
||||
w.total = at;
|
||||
return w;
|
||||
}
|
||||
|
||||
/* The layout a range of words carries, read off its header. */
|
||||
static inline RadClefWords rad_clef_words_read(const int32_t* words) {
|
||||
return rad_clef_words_layout(words[RAD_CLEF_W_N], words[RAD_CLEF_W_Q], words[RAD_CLEF_W_O],
|
||||
words[RAD_CLEF_W_L], words[RAD_CLEF_W_S]);
|
||||
}
|
||||
|
||||
/* The most words a request can carry within the bounds: what the head declares
|
||||
* (rad_declare_plugin_words). A span's two edges each cut the prompt, so the segments are at most
|
||||
* two a span plus one. */
|
||||
static inline int32_t rad_clef_max_words(void) {
|
||||
const int32_t spans = RAD_CLEF_MAX_QUESTIONS + RAD_CLEF_MAX_OPTIONS;
|
||||
return rad_clef_words_layout(0, RAD_CLEF_MAX_QUESTIONS, RAD_CLEF_MAX_OPTIONS,
|
||||
RAD_CLEF_MAX_LEX, 2 * spans + 1).total;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* RAD_CLEF_H */
|
||||
@@ -36,12 +36,21 @@ typedef struct RadDeviceProps {
|
||||
int64_t lds_bytes; /* per-workgroup scratch, for occupancy arithmetic only */
|
||||
int supports_p2p;
|
||||
int is_host_backend; /* 1 when there is no accelerator behind this device */
|
||||
int unified; /* 1 when device memory is host memory (integrated graphics):
|
||||
* one address space and one RAM ledger -- the device pools and
|
||||
* the pinned host pools are charged against the same bytes,
|
||||
* KV tiers collapse to resident, and a copy whose source and
|
||||
* destination are the same address is a no-op */
|
||||
} RadDeviceProps;
|
||||
|
||||
int rad_dev_count(void);
|
||||
int rad_dev_set(int device);
|
||||
int rad_dev_props(int device, RadDeviceProps* out);
|
||||
int rad_dev_enable_peer(int self, int peer);
|
||||
/* 1 when the driver reports that `self` can reach `peer`'s memory, 0 when not, negative on a
|
||||
* device error. A tool that declares a multi-rank graph sets the device.p2p fact from it, as the
|
||||
* engine does (RAD_FACT_P2P). */
|
||||
int rad_dev_peer_access(int self, int peer);
|
||||
|
||||
void* rad_dev_alloc(int64_t bytes, int kind);
|
||||
void rad_dev_free(void* p, int kind);
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/* rad_laya.h -- the words a Laya request hands its plugin (RadBatch::plugin_words), and the pooled
|
||||
* row the plugin answers in.
|
||||
*
|
||||
* Laya (arch/laya) reads one sequence a question, `[CLS] <type> question: <instructions> [SEP]
|
||||
* [MASK] opt0 [MASK] opt1 ... [SEP] <state> [SEP]`, and scores each option at its [MASK]. The
|
||||
* server builds the sequence (core/server/laya.cpp) and hands the plugin what the tokens do not
|
||||
* say: the question's type, which picks the head's type embedding, and where the markers are. The
|
||||
* plugin answers in the sequence's pooled row: one logit an option, in marker order.
|
||||
*
|
||||
* Plain C, like every abi/ header: the plugin is built apart from the engine.
|
||||
*/
|
||||
#ifndef RAD_LAYA_H
|
||||
#define RAD_LAYA_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
/* Options a question, llama.cpp's bound for laya. The pooled row holds one logit an option. */
|
||||
RAD_LAYA_MAX_OPTIONS = 255,
|
||||
RAD_LAYA_POOLED = 256
|
||||
};
|
||||
|
||||
/* The question types in the order of the head's type embedding rows (laya's QTYPES). */
|
||||
enum { RAD_LAYA_CHOICE = 0, RAD_LAYA_SCORE = 1, RAD_LAYA_NOUL = 2 };
|
||||
|
||||
/* A sequence's words. Word 0 is the engine's (RadBatch::plugin_words). */
|
||||
enum {
|
||||
RAD_LAYA_W_ROW = 0, /* written by the engine */
|
||||
RAD_LAYA_W_N = 1, /* the sequence's tokens */
|
||||
RAD_LAYA_W_TYPE = 2, /* RAD_LAYA_CHOICE, RAD_LAYA_SCORE or RAD_LAYA_NOUL */
|
||||
RAD_LAYA_W_K = 3, /* options, so markers */
|
||||
RAD_LAYA_W_MARKERS = 4, /* [k]: each option's [MASK] position in the sequence, in order */
|
||||
RAD_LAYA_MAX_WORDS = RAD_LAYA_W_MARKERS + RAD_LAYA_MAX_OPTIONS
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* RAD_LAYA_H */
|
||||
@@ -106,6 +106,15 @@ typedef struct RadQuantizerInfo {
|
||||
int rad_quant_count(void);
|
||||
const RadQuantizerInfo* rad_quant_at(int i);
|
||||
|
||||
/* Optional: the cards a quantiser may run on, as the HIP runtime numbers them (after
|
||||
* HIP_VISIBLE_DEVICES); none is the host alone, the state before any call. rad-convert calls it
|
||||
* once, after loading and before the first weight, with its --gpus list. A quantiser that uses a
|
||||
* card writes the same bytes it writes on the host, so a container does not depend on the machine
|
||||
* that converted it, and --reuse matches it either way. RAD_E_UNSUPPORTED: this build has no
|
||||
* device path; any other negative status refuses the list (a card that is not there). Symbol
|
||||
* name: `rad_quant_devices`. */
|
||||
typedef int (*RadQuantDevicesFn)(const int* ids, int n);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
+173
-10
@@ -22,6 +22,38 @@ typedef struct RadCtx RadCtx;
|
||||
* scheduler and the run phase the bounds without a device read. */
|
||||
enum { RAD_PHASE_PREFILL = 0, RAD_PHASE_DECODE = 1, RAD_PHASE_MIXED = 2 };
|
||||
|
||||
/* ================================================================== KV streaming */
|
||||
/* A streamed KV group keeps its whole context in pinned host memory and a ring of blocks on the
|
||||
* card (docs/KV-STREAMING.md). The step batch points every group that streams at this view, which
|
||||
* is fixed from bring-up (so a recorded pass replays a resolve); a resident group's is null.
|
||||
*
|
||||
* The mirror is laid out like the pool, layer by layer: layer l's row for block b is at
|
||||
* `host + l * host_layer_stride + b * block_bytes`. `res`, `slot_block`, `slot_state` and `ctl`
|
||||
* are device memory, read and rewritten by every resolve launch. */
|
||||
typedef struct RadKVStream {
|
||||
/* The mirror: pinned host memory a kernel reads over the link in place, every layer, zeroed at
|
||||
* bring-up. */
|
||||
uint8_t* host;
|
||||
/* Residency, one slice a layer: `res` is block -> ring slot or -1 (layer l at `res + l *
|
||||
* blocks`), `slot_block` is slot -> block or -1, `slot_state` is [slots, 2]: the epoch of a
|
||||
* slot's last use and its CLOCK reference bit. Per layer, because the resolve copies one
|
||||
* layer's bytes. */
|
||||
int32_t* res;
|
||||
int32_t* slot_block;
|
||||
int32_t* slot_state;
|
||||
/* The group's control block: epoch, clock hand, the last launch's miss count, the overflow
|
||||
* latch and cumulative counters (docs/OPS.md "kv_resolve"). */
|
||||
int32_t* ctl;
|
||||
/* Bytes one block of one layer occupies: the mirror's row pitch and the ring's slot pitch. */
|
||||
int64_t block_bytes;
|
||||
/* Bytes between one layer's mirror and the next. */
|
||||
int64_t host_layer_stride;
|
||||
/* The ring's depth in blocks; a selection names block ids over the whole context. */
|
||||
int64_t slots;
|
||||
/* The whole mirror's bytes, every layer. */
|
||||
int64_t host_bytes;
|
||||
} RadKVStream;
|
||||
|
||||
typedef struct RadKVGroupBatch {
|
||||
rad_kvgroup group;
|
||||
int32_t* slot_mapping; /* [n_tok] flat slot index per token, device */
|
||||
@@ -36,6 +68,8 @@ typedef struct RadKVGroupBatch {
|
||||
int64_t state_index_pitch;
|
||||
int64_t block_size;
|
||||
int64_t max_blocks;
|
||||
/* Null unless this group streams (RadKVStream). Trailing and zero-defaulted. */
|
||||
const RadKVStream* stream;
|
||||
} RadKVGroupBatch;
|
||||
|
||||
typedef struct RadBatch {
|
||||
@@ -85,7 +119,12 @@ typedef struct RadBatch {
|
||||
/* Speculative window (spec §10). n_spec == 0 for an ordinary decode step. */
|
||||
int n_spec; /* draft tokens per sequence this step */
|
||||
const int32_t* num_accepted; /* [n_seq] device, from the previous verify */
|
||||
const int32_t* spec_parent; /* [n_tok] device, tree layout; null for a linear chain */
|
||||
/* [n_tok] device; null for a linear chain. A tree verify (rad_drafter_tree): -2 marks an
|
||||
* ordinary causal row; any other entry is a node of its sequence's verify block and names its
|
||||
* parent by row within the sequence's rows (cu_seqlens), -1 for the block's first row, every
|
||||
* parent before its child. Inside its block such a row attends to itself and its ancestors
|
||||
* only (docs/OPS.md, attn_paged_tree). */
|
||||
const int32_t* spec_parent;
|
||||
|
||||
/* The draft pass. 0 is an ordinary step that runs the trunk; non-zero runs only the draft
|
||||
* head, and the sign gives the kind:
|
||||
@@ -135,9 +174,9 @@ typedef struct RadBatch {
|
||||
/* The longest query in each half. max_q_len over a mixed step is the prefill chunk's, and
|
||||
* banding the decode half with it would give eight rows a thousand-row GEMM's band.
|
||||
*
|
||||
* Only the decode value is currently read (by the GDN blocks). The prefill value is for a
|
||||
* block whose prefill path bands on a per-sequence query length; the GDN prefill ops band on
|
||||
* the step's total tokens, taken from their operands. */
|
||||
* The decode value is read by the GDN blocks and the fp8 gated attention's per-band issue
|
||||
* (rad_block_attn_gated_fp8.h), which also bands its prefill half on the prefill value; the
|
||||
* GDN prefill ops band on the step's total tokens, taken from their operands. */
|
||||
int32_t max_q_len_decode;
|
||||
int32_t max_q_len_prefill;
|
||||
|
||||
@@ -256,6 +295,36 @@ typedef struct RadBatch {
|
||||
* position tables per grid) reads them here; they live as long as the pass. */
|
||||
const int32_t* enc_seg_h;
|
||||
const int32_t* enc_seg_w;
|
||||
|
||||
/* ================================================ scored steps */
|
||||
|
||||
/* Non-zero when every row the sampler wants is a scored row (a /v1/systemone question: the raw
|
||||
* logits at a few candidate ids, the sampled token discarded) and the program declared where
|
||||
* the core finds the hidden rows and the head (rad_declare_scores). The plugin then skips its
|
||||
* lm_head and leaves `rad_declare_scores`' hidden buffer holding the gathered, final-normed
|
||||
* rows; the core computes the candidates' logits itself. Zero on every other step, and always
|
||||
* for a program that declared no scores. Appended; an older plugin never sees it set. */
|
||||
int32_t score_only;
|
||||
|
||||
/* ---- appended in ABI 32 (a request's words for the plugin) */
|
||||
/* Integer words a request hands the plugin whole (Request::plugin_words), for a head that
|
||||
* needs more of a request than its tokens: clef's joint schema head reads the prompt's
|
||||
* question and option spans and the option tokens (abi/rad_clef.h). Sequence s's words are
|
||||
* `plugin_words[plugin_cu[s] .. plugin_cu[s+1])`; a sequence with none has an empty range.
|
||||
* The engine writes the sequence's first sampled logits row of this step into word 0 of its
|
||||
* range, so the head can put its result beside that row's logits; the words after it are the
|
||||
* request's own. Carried only on the trunk step that samples a prompt's first token, so a
|
||||
* head runs once a request, when every prompt row has been computed.
|
||||
*
|
||||
* `plugin_words_h` and `plugin_cu_h` are the same words on the host, for a plugin that reads
|
||||
* counts before it issues; they live as long as the pass. All null, with `n_plugin_words`
|
||||
* 0, on a step no sequence of which carries words, and on every step of a program that
|
||||
* declared none (rad_declare_plugin_words). */
|
||||
int64_t n_plugin_words;
|
||||
const int32_t* plugin_words; /* [n_plugin_words] device */
|
||||
const int32_t* plugin_cu; /* [n_seq + 1] device */
|
||||
const int32_t* plugin_words_h;
|
||||
const int32_t* plugin_cu_h;
|
||||
} RadBatch;
|
||||
|
||||
/* What a generator pass carries beside the step batch's own fields, which keep their meanings:
|
||||
@@ -399,8 +468,13 @@ typedef struct RadGenBatch {
|
||||
|
||||
/* A request's conditioning options on a COND pass (RadGenBatch::cond_opts). */
|
||||
enum {
|
||||
RAD_GEN_COND_REBALANCE = 1 /* the conditioning at the plugin's fixed rebalance gains (the
|
||||
RAD_GEN_COND_REBALANCE = 1, /* the conditioning at the plugin's fixed rebalance gains (the
|
||||
* request field `rebalance`; Krea 2: its text taps) */
|
||||
/* which of the plugin's rebalance presets, beside RAD_GEN_COND_REBALANCE: 0 its default
|
||||
* gains, Krea 2: 1 balanced, 2 detail, 3 subtle (arch/krea2). A plugin declares these bits in
|
||||
* RadGeneratorDecl::cond_opts when it has presets. */
|
||||
RAD_GEN_COND_REBALANCE_PRESET = 0xff00,
|
||||
RAD_GEN_COND_REBALANCE_PRESET_SHIFT = 8
|
||||
};
|
||||
|
||||
/* An entry's flags on a DENOISE pass. */
|
||||
@@ -489,6 +563,30 @@ typedef struct RadAudioGenBatch {
|
||||
/* VOCODE with RadAudioGenDecl::voc_chunk: the lane's first frame the pass reads, counted
|
||||
* from the first kept frame. 64 bits so that it starts past the struct's ABI 18 end. */
|
||||
int64_t voc_frame0;
|
||||
|
||||
/* ---- appended in ABI 27 (a frame head at the previous row, references) */
|
||||
/* FRAME, one value per entry ([n_seq]): the row before the frame's own row -- the one whose
|
||||
* hidden state the frame is sampled from -- as its KV slot, its position, and the context
|
||||
* through it (position + 1). A model whose frame head attends at that row (Fish Audio
|
||||
* drama-3's codebook tower, layers bound to the language model's full-attention group) issues
|
||||
* those layers there, before the language model runs at the frame's own row. */
|
||||
const int32_t* prev_slot;
|
||||
const int32_t* prev_pos;
|
||||
const int32_t* prev_used;
|
||||
|
||||
/* PROMPT of a request with references (RadAudioGenDecl::tmpl_ref; n_ref 0 without): its
|
||||
* clips' samples end to end (`ref_samples` f32 on the device), the clips' bounds in samples
|
||||
* ([n_ref + 1], each a whole number of RadAudioGenDecl::ref_hop), and for every row of the
|
||||
* pass the frame of the clips it is or -1 for a token row ([n_tok]), frames counted over the
|
||||
* clips in order, frame f the samples [f ref_hop, (f + 1) ref_hop). A frame's row stages
|
||||
* token 0; the plugin embeds the frame there instead. */
|
||||
int64_t n_ref;
|
||||
int64_t ref_samples;
|
||||
const float* ref_audio;
|
||||
const int32_t* ref_cu;
|
||||
const int32_t* ref_cu_h;
|
||||
const int32_t* ref_frame;
|
||||
const int32_t* ref_frame_h;
|
||||
} RadAudioGenBatch;
|
||||
|
||||
/* A window entry's flags on a WINDOW pass. FIRST is RAD_GEN_F_FIRST's bit and the others are clear
|
||||
@@ -510,8 +608,11 @@ enum {
|
||||
* ADECODE no rows of the pass's own.
|
||||
* VDECODE `dec_rows` rows of the decoder's own (rad_arch_video_positions, RAD_VPOS_DECODE).
|
||||
* VUPSCALE no rows of the pass's own: the lane's video latent from `geom_from` to `geom`.
|
||||
* VENCODE no rows of the pass's own: a picture's or a video's frames in `enc_pixels`.
|
||||
* AENCODE no rows of the pass's own: a soundtrack's samples in `enc_samples`.
|
||||
*
|
||||
* Every pointer is device memory unless the name ends in _h. */
|
||||
|
||||
typedef struct RadVideoGenBatch {
|
||||
int32_t lane;
|
||||
RadVideoGeom geom; /* the request's geometry */
|
||||
@@ -520,9 +621,10 @@ typedef struct RadVideoGenBatch {
|
||||
/* The same lane, i32 [1], and 1 on a request's first step (0 otherwise), i32 [1]. */
|
||||
const int32_t* lane_d;
|
||||
const int32_t* first_d;
|
||||
/* i32 [4]: the packed sequence's segments, {0, n_text, n_text + audio rows, n_tok} -- text,
|
||||
* soundtrack, video -- and i32 [4] {0, video rows, 0, audio rows}, the bounds of the lane's two
|
||||
* latents counted from each one's first row. */
|
||||
/* i32: the packed sequence's segment boundaries, {0, n_text, n_text + audio rows, n_tok} --
|
||||
* text, soundtrack, video -- or rad_arch_video_pack's for a request with references; and i32
|
||||
* [4] {0, video rows, 0, audio rows}, the bounds of the lane's two latents counted from each
|
||||
* one's first row. */
|
||||
const int32_t* seg_cu;
|
||||
const int32_t* lat_cu;
|
||||
|
||||
@@ -533,7 +635,8 @@ typedef struct RadVideoGenBatch {
|
||||
|
||||
/* ---- VSTEP */
|
||||
int32_t step; /* from 0; the first draws the lane's noise */
|
||||
/* f32 [6]: the video's timestep, sigma and next sigma, then the soundtrack's. */
|
||||
/* f32 [16]: the video's timestep, sigma and next sigma, then the soundtrack's; from [6] the
|
||||
* res_multistep scalars of the video, then of the soundtrack (`sampler`, below). */
|
||||
const float* sched;
|
||||
const float* pos; /* f32 [3, n_tok]: RAD_VPOS_STEP */
|
||||
/* u32 [2, 2]: the video's noise seed and the soundtrack's, low word first (VSTEP, VUPSCALE and
|
||||
@@ -573,8 +676,55 @@ typedef struct RadVideoGenBatch {
|
||||
/* VDECODE: the decoder the request named (RadVideoGenDecl::decoders), its index; 0 the
|
||||
* default. */
|
||||
int32_t decoder;
|
||||
|
||||
/* ---- appended in ABI 31 (rad_builder.h, "Reference conditioning") */
|
||||
/* The sampler a VSTEP advances the latents with: RAD_SAMPLER_EULER, the first-order step on
|
||||
* sched[0..5], or RAD_SAMPLER_RES_MULTISTEP, the second-order one on the clean estimate
|
||||
* (k-diffusion's res_multistep at eta 0), which keeps the previous step's estimate. Its scalars
|
||||
* are sched[6..10] for the video and sched[11..15] for the soundtrack: sigma, r = next sigma /
|
||||
* sigma, the weights hb1 and hb2 of this step's estimate and the previous one, and the order,
|
||||
* 1 where there is no previous estimate on the same grid. */
|
||||
int32_t sampler;
|
||||
/* VENCODE: f32 [enc_frames, enc_height, enc_width, 3] RGB in 0..255, the frames padded to
|
||||
* whole clips by repeating the last (rad_arch_encode_geom's entry 23). AENCODE: f32
|
||||
* [enc_channels, enc_n_samples], each channel padded with zeros to the hop (entry 0). Both:
|
||||
* the pass's geometry as rad_arch_encode_geom gave it, i32 on the device, and the media's
|
||||
* kind (RAD_ENC_*, below) and its number within the kind from 1. */
|
||||
const float* enc_pixels;
|
||||
int32_t enc_frames, enc_height, enc_width;
|
||||
const float* enc_samples;
|
||||
int64_t enc_n_samples;
|
||||
int32_t enc_channels;
|
||||
const int32_t* enc_geom_d;
|
||||
int32_t enc_kind, enc_slot;
|
||||
/* VCOND and VSTEP of a request with reference media or keyframes: their table, host i32, null
|
||||
* without. [0] the references, [1] the keyframes, then 6 words a reference {kind, slot, latent
|
||||
* height, latent width, latent frames, soundtrack latents} in presentation order and 3 a
|
||||
* keyframe {frame, latent frames, soundtrack latents}, then the prompt's vision pads: a count
|
||||
* and {first token, tokens} of each picture's run. A reference's kind is RAD_VREF_PICTURE,
|
||||
* _AUDIO or _VIDEO; its slot is its encode pass's. */
|
||||
const int32_t* ref_tab;
|
||||
/* VSTEP: i32, rad_arch_video_pack's `mod`: the boundaries of the modulation groups, then the
|
||||
* cell each reads; `seg_cu` then holds the segment boundaries. A request without references
|
||||
* stages `seg_cu`'s four and no cells. */
|
||||
const int32_t* mod_cu;
|
||||
} RadVideoGenBatch;
|
||||
|
||||
enum { RAD_SAMPLER_EULER = 0, RAD_SAMPLER_RES_MULTISTEP = 1 };
|
||||
|
||||
/* RadVideoGenBatch::enc_kind: the media an encode pass carries, numbered from 1 within a kind. A
|
||||
* keyframe is 1 for the first frame and 2 for the last. */
|
||||
enum {
|
||||
RAD_ENC_IMAGE = 1, /* a reference picture; Vencode */
|
||||
RAD_ENC_VIDEO = 2, /* a reference video; Vencode */
|
||||
RAD_ENC_VAUDIO = 3, /* the soundtrack of reference video `enc_slot`; Aencode */
|
||||
RAD_ENC_AUDIO = 4, /* a standalone soundtrack; Aencode */
|
||||
RAD_ENC_KEYFRAME = 5 /* a first or last frame; Vencode */
|
||||
};
|
||||
|
||||
/* RadVideoGenBatch::ref_tab: a reference's kind. */
|
||||
enum { RAD_VREF_PICTURE = 0, RAD_VREF_AUDIO = 1, RAD_VREF_VIDEO = 2 };
|
||||
|
||||
/* RadVideoGenBatch::geom_d. The request's latent geometry, then a VDECODE pass's chunk: the latent
|
||||
* frames it reads (from latent frame `chunk_lat0`), its latent grid again so that (frames, h, w,
|
||||
* first, last) is one run, and the same chunk in patches. */
|
||||
@@ -681,7 +831,8 @@ int rad_issue(RadCtx* c, rad_op op, const RadOperand* opd, int n_opd, int64_t n)
|
||||
* the all-reduce numbers its scratch slots per launch and the ranks must agree; a kernel with a
|
||||
* device-wide arrival counter must key it on the stream (libr4d's split-K GEMM does), or it may
|
||||
* not run here; and every buffer the second lane touches must be named to rad_buf_concurrent,
|
||||
* because the planner packs transients from one linear order. */
|
||||
* because the planner packs transients from one linear order (live for the whole program, or across
|
||||
* the second lane's window where the architecture declares one, abi/rad_builder.h). */
|
||||
int rad_lane(RadCtx* c, int lane);
|
||||
int rad_lane_join(RadCtx* c, int from, int to);
|
||||
|
||||
@@ -696,6 +847,18 @@ int rad_step_fail(RadCtx* c, const char* what);
|
||||
|
||||
/* ================================================================== run-phase queries */
|
||||
const RadBatch* rad_batch(RadCtx* c);
|
||||
/* The position of model layer `layer` among `group`'s bound layers, or -1 when this rank has no
|
||||
* pool for it or the group does not hold the layer: the lookup a RAD_KV operand makes, and the
|
||||
* index of the layer's host mirror row. Bound layers need not be contiguous. */
|
||||
int rad_kv_layer_index(RadCtx* c, rad_kvgroup group, int layer);
|
||||
/* Prefill staging of a streamed group (the ordering rule is in core/kvstream/stage.h).
|
||||
* rad_kv_stage_layer, before the layer's store: when the pass uses the one-layer stage view, make
|
||||
* the layer's mirror row whole in it (once a pass) and return 1, after which the caller reads
|
||||
* block ids directly and must not resolve; 0 when the group has no stage view.
|
||||
* rad_kv_stage_next, after every attention launch of the layer: start the next layer's copy. */
|
||||
int rad_kv_stage_layer(RadCtx* c, rad_kvgroup group, const RadKVGroupBatch* kvb,
|
||||
int layer);
|
||||
int rad_kv_stage_next(RadCtx* c, rad_kvgroup group, int layer);
|
||||
int rad_rank(RadCtx* c);
|
||||
int rad_world_size(RadCtx* c);
|
||||
RadStream rad_stream(RadCtx* c);
|
||||
|
||||
@@ -0,0 +1,413 @@
|
||||
/* rad_spechub.h -- the speculative coupling (linear MTP and DFlash2's block walk): wire rows and
|
||||
* the shared arithmetic.
|
||||
*
|
||||
* The core writes these rows and a kernel plugin reads them, so their layout is ABI. The helpers
|
||||
* are header-only and stateless, so the host reference, the device kernel and the sampler share
|
||||
* one definition of the wire and of the arithmetic that turns it into a token.
|
||||
*
|
||||
* A row lives in a U32 plane whose base and row stride are eight-byte aligned, so a state can be
|
||||
* loaded whole on the device.
|
||||
*/
|
||||
#ifndef RAD_SPECHUB_H
|
||||
#define RAD_SPECHUB_H
|
||||
|
||||
#include <math.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* The verify reads a RadSampleParams row. */
|
||||
#include "rad_sample.h"
|
||||
|
||||
/* Linear MTP coupling (--draft-coupling on). One draw per drafting row, staged before the
|
||||
* serial passes; one state per (temporal round, row). `base` is the request's PRE-commit output
|
||||
* size, so (base, round) names one draft stream that no later step reuses. `card` is the step slot
|
||||
* the advance writes, checked against RadBatch::seq_ids. `mode` 1 samples x~Q; 0 keeps the greedy
|
||||
* proposal (temperature 0 or top_k 1). */
|
||||
typedef struct RadMtpCoupleDraw {
|
||||
uint64_t seed, base, seq;
|
||||
int32_t card;
|
||||
uint32_t mode;
|
||||
} RadMtpCoupleDraw;
|
||||
/* status 1: x sampled from the exact q[] stored here; 0: greedy proposal kept; -1: malformed
|
||||
* shortlist or row identity, greedy proposal kept. `pos` is the verify row's output position, bound
|
||||
* by the host after commit; the device writes 0. ids[count..7] = -1, q[count..7] = 0. */
|
||||
typedef struct RadMtpCoupleState {
|
||||
RadMtpCoupleDraw draw;
|
||||
uint64_t pos;
|
||||
int32_t status, round, x, count;
|
||||
int32_t ids[8];
|
||||
double q[8];
|
||||
} RadMtpCoupleState;
|
||||
#define RAD_MTP_COUPLE_DRAW_WORDS (sizeof(RadMtpCoupleDraw) / 4)
|
||||
#define RAD_MTP_COUPLE_STATE_WORDS (sizeof(RadMtpCoupleState) / 4)
|
||||
#define RAD_MTP_COUPLE_MAX_ROUNDS 8
|
||||
/* Draft stream of round r: seed ^ (KEY_DRAFT + r) at coordinate `base`. Acceptance and the
|
||||
* residual draw use RAD_SAMPLE_KEY_ACCEPT / RAD_SAMPLE_KEY_RESID at the verify position. */
|
||||
#define RAD_MTP_COUPLE_KEY_DRAFT 0x4d5450434f55504cull
|
||||
#ifdef __cplusplus
|
||||
static_assert(sizeof(RadMtpCoupleDraw) == 32, "MTP coupling draw wire");
|
||||
static_assert(sizeof(RadMtpCoupleState) == 152, "MTP coupling state wire");
|
||||
static_assert(offsetof(RadMtpCoupleState, q) % 8 == 0, "MTP coupling q alignment");
|
||||
#endif
|
||||
|
||||
/* ================================================================== the shared arithmetic
|
||||
*
|
||||
* Q is the FP64 softmax of an FP32 shortlist at temperature 1; P is the FP64 softmax of the
|
||||
* sampler's FP32 candidate logits; uniforms are 53-bit. A coupled row therefore realises the
|
||||
* filtered target law to FP64 rounding rather than sample_pick's FP32/24-bit law, and is not
|
||||
* seed-identical to the ordinary pick.
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
|
||||
#if defined(__HIPCC__)
|
||||
#define RAD_SPECHUB_HD __host__ __device__
|
||||
#else
|
||||
#define RAD_SPECHUB_HD
|
||||
#endif
|
||||
|
||||
static inline RAD_SPECHUB_HD double rad_spechub_positive(double a) { return a > 0 ? a : 0; }
|
||||
static inline RAD_SPECHUB_HD bool rad_spechub_finite(double x) {
|
||||
return x == x && x <= 1.7976931348623157e308 && x >= -1.7976931348623157e308;
|
||||
}
|
||||
|
||||
/* A 53-bit uniform in [0, 1): splitmix64 over (seed ^ key, pos), top 53 bits scaled by 2^-53. */
|
||||
static inline RAD_SPECHUB_HD double rad_spechub_uniform(uint64_t seed, uint64_t pos, uint64_t key) {
|
||||
uint64_t z = (seed ^ key) * 0x9e3779b97f4a7c15ull + pos + 0x9e3779b97f4a7c15ull;
|
||||
z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9ull;
|
||||
z = (z ^ (z >> 27)) * 0x94d049bb133111ebull;
|
||||
z ^= z >> 31;
|
||||
return (double)(z >> 11) * 0x1p-53;
|
||||
}
|
||||
|
||||
/* Is `s` a state the coupling's propose kernel could have written for a sampled row? The verifier
|
||||
* and the engine's bind check refuse a row by this rule, on the device and on the host. */
|
||||
static inline RAD_SPECHUB_HD bool rad_mtp_couple_state_valid(const RadMtpCoupleState& s,
|
||||
int64_t vocab) {
|
||||
if (s.status != 1 || s.draw.mode != 1 || s.count < 1 || s.count > 8 || s.round < 1 ||
|
||||
s.round > RAD_MTP_COUPLE_MAX_ROUNDS)
|
||||
return false;
|
||||
double sum = 0;
|
||||
bool has_x = false;
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
if (i >= s.count) {
|
||||
if (s.ids[i] != -1 || s.q[i] != 0) return false;
|
||||
continue;
|
||||
}
|
||||
if (s.ids[i] < 0 || s.ids[i] >= vocab || !rad_spechub_finite(s.q[i]) || !(s.q[i] > 0) ||
|
||||
s.q[i] > 1)
|
||||
return false;
|
||||
for (int j = 0; j < i; ++j)
|
||||
if (s.ids[j] == s.ids[i]) return false;
|
||||
sum += s.q[i];
|
||||
has_x |= s.ids[i] == s.x;
|
||||
}
|
||||
return has_x && (sum - 1) <= 1e-12 && (1 - sum) <= 1e-12;
|
||||
}
|
||||
|
||||
/* The verify position of coupled round r (1-based): the coordinate the engine's bind and the
|
||||
* sampler's row check must agree on.
|
||||
*
|
||||
* The sampler stages row k of a request at output position `n_out + k`, where `n_out` is the
|
||||
* request's committed output length when the step is built; round r is verified at row r - 1. The
|
||||
* acceptance and residual uniforms are drawn at this position.
|
||||
*
|
||||
* `n_out` is read from the request after the drafting step's commit. It is not rebuilt from the
|
||||
* draft's pre-commit `base` plus the accepted count: the two differ when the commit emits fewer
|
||||
* tokens than the card accepted (a max_tokens or context cut) or a step is carried. */
|
||||
static inline RAD_SPECHUB_HD uint64_t rad_mtp_couple_verify_pos(uint64_t n_out, int round) {
|
||||
return n_out + (round > 0 ? (uint64_t)(round - 1) : 0);
|
||||
}
|
||||
|
||||
/* Would the verify row for draft index `k` (0-based) of a request with committed output length
|
||||
* `n_out` take `c` as its coupled state? Same request and seed, the round this row's draft came
|
||||
* from, the position it samples, the very token it proposes, and a state the proposer could have
|
||||
* written. Anything else is a stale state from another step, and coupling against it would apply a
|
||||
* law this step never drew.
|
||||
*
|
||||
* Asked by the sampler's step build, against the state the engine bound. The engine's own bind
|
||||
* does not call it: it checks the readback against the card (draw, round, x, status) and writes
|
||||
* the position with rad_mtp_couple_verify_pos, the formula here that both sides must agree on. */
|
||||
static inline RAD_SPECHUB_HD bool rad_mtp_couple_binds(const RadMtpCoupleState& c, uint64_t seq,
|
||||
uint64_t seed, uint64_t n_out, int k,
|
||||
int32_t draft_x, int64_t vocab) {
|
||||
return c.status == 1 && c.draw.seq == seq && c.draw.seed == seed && c.round == k + 1 &&
|
||||
c.pos == rad_mtp_couple_verify_pos(n_out, k + 1) && c.x == draft_x &&
|
||||
rad_mtp_couple_state_valid(c, vocab);
|
||||
}
|
||||
|
||||
/* Build the stored Q from a shortlist of eight (id, score) slots.
|
||||
*
|
||||
* Holes (id < 0) and -inf scores carry no mass. An entry whose FP64 weight or normalized q
|
||||
* underflows to zero is dropped, so the stored q[] is exactly the law the draw walks. False on an
|
||||
* out-of-range id, NaN/+inf score, duplicate id or empty support (s->count = 0). */
|
||||
static inline RAD_SPECHUB_HD bool rad_mtp_couple_build_q(const int32_t* ids, const float* val,
|
||||
int64_t vocab, RadMtpCoupleState* s) {
|
||||
int32_t kid[8];
|
||||
float kv[8];
|
||||
int n = 0;
|
||||
s->count = 0;
|
||||
for (int i = 0; i < 8; ++i) { s->ids[i] = -1; s->q[i] = 0; }
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
if (ids[i] < 0) continue;
|
||||
if (ids[i] >= vocab || val[i] != val[i] || val[i] == INFINITY) return false;
|
||||
if (val[i] == -INFINITY) continue;
|
||||
for (int j = 0; j < n; ++j)
|
||||
if (kid[j] == ids[i]) return false;
|
||||
kid[n] = ids[i];
|
||||
kv[n++] = val[i];
|
||||
}
|
||||
if (!n) return false;
|
||||
float top = kv[0];
|
||||
for (int j = 1; j < n; ++j)
|
||||
if (kv[j] > top) top = kv[j];
|
||||
double w[8], sum = 0;
|
||||
for (int j = 0; j < n; ++j) { w[j] = ::exp((double)kv[j] - top); sum += w[j]; }
|
||||
for (int j = 0; j < n; ++j) {
|
||||
const double q = w[j] / sum;
|
||||
if (q > 0) { s->ids[s->count] = kid[j]; s->q[s->count++] = q; }
|
||||
}
|
||||
return s->count > 0;
|
||||
}
|
||||
|
||||
/* Inverse CDF over the stored q with a uniform in [0, 1); index into ids. */
|
||||
static inline RAD_SPECHUB_HD int rad_mtp_couple_pick(const RadMtpCoupleState& s, double u) {
|
||||
double total = 0;
|
||||
for (int i = 0; i < s.count; ++i) total += s.q[i];
|
||||
double c = u * total;
|
||||
for (int i = 0; i < s.count; ++i) { c -= s.q[i]; if (c < 0) return i; }
|
||||
return s.count - 1;
|
||||
}
|
||||
|
||||
/* Residual mass r(y) = max(0, P(y) - Q(y)) of one candidate. Q tokens use their P aggregated over
|
||||
* duplicate candidates, counted once at the first occurrence (`seen`). */
|
||||
static inline RAD_SPECHUB_HD double rad_mtp_couple_mass(const RadMtpCoupleState& s, const double* pq,
|
||||
int32_t id, float v, float top, double sum,
|
||||
unsigned* seen) {
|
||||
if (id < 0 || v == -INFINITY) return 0;
|
||||
for (int k = 0; k < s.count; ++k)
|
||||
if (s.ids[k] == id) {
|
||||
if (*seen & (1u << k)) return 0;
|
||||
*seen |= 1u << k;
|
||||
return rad_spechub_positive(pq[k] - s.q[k]);
|
||||
}
|
||||
return ::exp((double)v - top) / sum;
|
||||
}
|
||||
|
||||
/* The maximal coupling of the target's law P (over the surviving candidates) with the draft's Q.
|
||||
* Writes the emitted token to *out and returns true, or returns false for an invalid or empty
|
||||
* target. u_accept and u_resid are independent uniforms in [0, 1).
|
||||
*
|
||||
* The draft x is kept when P dominates Q on every Q token or when u_accept * Q(x) < P(x); otherwise
|
||||
* the token is drawn from the residual (P - Q)+. The emitted token is distributed as P, and it
|
||||
* equals x with probability sum min(P, Q).
|
||||
*
|
||||
* If FP64 cancellation leaves the residual total R at 0 while some Q token has P < Q, P is sampled
|
||||
* directly in FP64 with u_resid. That branch depends on (P, Q) only, never on x or a uniform.
|
||||
*
|
||||
* R sums r over every candidate including x. The residual walk runs only when P(x) < Q(x), where
|
||||
* r(x) is exactly +0, so skipping x in the walk leaves its total equal to R bit for bit. */
|
||||
static inline RAD_SPECHUB_HD bool rad_mtp_couple_decide(const RadMtpCoupleState& s,
|
||||
const int32_t* ids, const float* val,
|
||||
int64_t n, int64_t vocab, double u_accept,
|
||||
double u_resid, int32_t* out) {
|
||||
float top = -INFINITY;
|
||||
for (int64_t j = 0; j < n; ++j) {
|
||||
if (ids[j] < 0) continue;
|
||||
if (ids[j] >= vocab || val[j] != val[j] || val[j] == INFINITY) return false;
|
||||
if (val[j] > top) top = val[j];
|
||||
}
|
||||
if (top == -INFINITY) return false;
|
||||
double sum = 0, pq[8] = {};
|
||||
for (int64_t j = 0; j < n; ++j) {
|
||||
if (ids[j] < 0 || val[j] == -INFINITY) continue;
|
||||
const double w = ::exp((double)val[j] - top);
|
||||
sum += w;
|
||||
for (int k = 0; k < s.count; ++k)
|
||||
if (ids[j] == s.ids[k]) { pq[k] += w; break; }
|
||||
}
|
||||
if (!(sum > 0) || !rad_spechub_finite(sum)) return false;
|
||||
int ix = -1;
|
||||
bool dominated = true;
|
||||
for (int k = 0; k < s.count; ++k) {
|
||||
pq[k] /= sum;
|
||||
dominated = dominated && pq[k] >= s.q[k];
|
||||
if (s.ids[k] == s.x) ix = k;
|
||||
}
|
||||
if (ix < 0) return false; /* unreachable for a rad_mtp_couple_state_valid state */
|
||||
unsigned seen = 0;
|
||||
double resid = 0;
|
||||
for (int64_t j = 0; j < n; ++j)
|
||||
resid += rad_mtp_couple_mass(s, pq, ids[j], val[j], top, sum, &seen);
|
||||
if (!dominated && !(resid > 0 && rad_spechub_finite(resid))) {
|
||||
double c = u_resid * sum;
|
||||
int32_t last = -1;
|
||||
for (int64_t j = 0; j < n; ++j)
|
||||
if (ids[j] >= 0 && val[j] != -INFINITY) {
|
||||
const double w = ::exp((double)val[j] - top);
|
||||
if (w > 0) { last = ids[j]; c -= w; if (c < 0) { *out = last; return true; } }
|
||||
}
|
||||
*out = last;
|
||||
return true;
|
||||
}
|
||||
if (pq[ix] >= s.q[ix] || u_accept * s.q[ix] < pq[ix]) { *out = s.x; return true; }
|
||||
/* Rejected, so P(x) < Q(x): not dominated, resid > 0, and some y != x has mass > 0 below. */
|
||||
double c = u_resid * resid;
|
||||
int32_t last = -1;
|
||||
seen = 0;
|
||||
for (int64_t j = 0; j < n; ++j) {
|
||||
if (ids[j] == s.x) continue;
|
||||
const double m = rad_mtp_couple_mass(s, pq, ids[j], val[j], top, sum, &seen);
|
||||
if (m > 0) { last = ids[j]; c -= m; if (c < 0) { *out = last; return true; } }
|
||||
}
|
||||
*out = last;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* ================================================================== DFlash2's coupled walk
|
||||
*
|
||||
* The block drafter's counterpart of mtp_couple_propose (`dflash_couple_propose`). DFlash2 proposes
|
||||
* a block in one pass and `dflash_select` walks its candidate lattice greedily: at draft position l
|
||||
* every candidate c of that position scores
|
||||
*
|
||||
* score[l, c] = unary[l, c] + sum_r pred[pid][r] * hp[l][r] * succ[cand[l, c]][r]
|
||||
*
|
||||
* with pid the anchor at l = 0 and the walk's own previous token after it. The coupled walk scores
|
||||
* the same lattice but SAMPLES each position instead of taking its argmax:
|
||||
*
|
||||
* Q_l = the FP64 softmax of score[l, c] / q_temp over the eight best-scoring candidates whose
|
||||
* ids are in the vocabulary (rad_mtp_couple_build_q), x_l ~ Q_l at the draw's
|
||||
* (seed, base, KEY_DRAFT + l + 1), and pid = x_l for position l + 1.
|
||||
*
|
||||
* Q_l depends on the committed text (through the drafter's pass and the anchor) and on x_0..x_{l-1},
|
||||
* never on the target's verification, and it is stored exactly in the state row the verify reads,
|
||||
* which is all the maximal coupling needs to be exact (rad_mtp_couple_decide). The pairwise term is
|
||||
* what makes Q_l follow the walk's own earlier samples rather than the drafter's marginal.
|
||||
*
|
||||
* Bit-identical on host and device: each candidate's edge is RAD_DFLASH_EDGE_PARTS partial sums,
|
||||
* each a serial fmaf chain over a contiguous slice of the rank, added in order and then to the unary
|
||||
* score. The plugin builds with -ffp-contract=off, so nothing else is fused. */
|
||||
#define RAD_DFLASH_EDGE_PARTS 8
|
||||
#define RAD_DFLASH_COUPLE_MAX_K 32
|
||||
#define RAD_DFLASH_COUPLE_MAX_R 512
|
||||
|
||||
static inline RAD_SPECHUB_HD float rad_dflash_bf2f(uint16_t h) {
|
||||
union { uint32_t u; float f; } c;
|
||||
c.u = (uint32_t)h << 16;
|
||||
return c.f;
|
||||
}
|
||||
|
||||
/* Part `j` of one candidate's edge: a[r] * succ_row[r] over r in [j*R/P, (j+1)*R/P), fmaf in order.
|
||||
* `a` is the candidate-independent half, pred[pid][r] * hp[r] (or pred[pid][r] with no hp, 0 for a
|
||||
* predecessor outside the vocabulary). */
|
||||
static inline RAD_SPECHUB_HD float rad_dflash_edge_part(const float* a, const uint16_t* succ_row,
|
||||
int64_t R, int j) {
|
||||
const int64_t w = R / RAD_DFLASH_EDGE_PARTS;
|
||||
float acc = 0.0f;
|
||||
for (int64_t r = (int64_t)j * w; r < (int64_t)(j + 1) * w; ++r)
|
||||
acc = fmaf(a[r], rad_dflash_bf2f(succ_row[r]), acc);
|
||||
return acc;
|
||||
}
|
||||
|
||||
/* One position of the walk, given its K scores and ids (the ids as the candidate plane holds them).
|
||||
* Fills `*s` as mtp_couple_propose fills a round's state and returns the proposed token:
|
||||
*
|
||||
* mode 0 (a greedy request): status 0, x = `greedy_x`, the token dflash_select already wrote;
|
||||
* mode 1, its card's draw and a Q that builds: status 1, x ~ Q;
|
||||
* mode 1 otherwise: status -1, x = the walk's argmax (ties to the lower index, dflash_select's
|
||||
* rule over these scores), and the ordinary verify applies to it.
|
||||
*
|
||||
* The eight are taken in descending score, ties to the lower index, among candidates with an id
|
||||
* in [0, vocab); a NaN score is never taken (build_q would refuse it). */
|
||||
static inline RAD_SPECHUB_HD int32_t rad_dflash_couple_step(const float* sc, const int32_t* id,
|
||||
int K, float q_temp,
|
||||
const RadMtpCoupleDraw& d, bool card_ok,
|
||||
int round, int64_t vocab,
|
||||
int32_t greedy_x, RadMtpCoupleState* s) {
|
||||
s->draw = d;
|
||||
s->pos = 0;
|
||||
s->round = round;
|
||||
s->count = 0;
|
||||
for (int i = 0; i < 8; ++i) { s->ids[i] = -1; s->q[i] = 0; }
|
||||
if (d.mode != 1) {
|
||||
s->status = 0;
|
||||
s->x = greedy_x;
|
||||
return greedy_x;
|
||||
}
|
||||
s->status = -1;
|
||||
if (card_ok) {
|
||||
int32_t kid[8];
|
||||
float kv[8];
|
||||
unsigned taken = 0;
|
||||
int n = 0;
|
||||
for (; n < 8; ++n) {
|
||||
int best = -1;
|
||||
for (int c = 0; c < K; ++c) {
|
||||
if ((taken >> c) & 1u) continue;
|
||||
if (id[c] < 0 || id[c] >= vocab || sc[c] != sc[c]) continue;
|
||||
if (best < 0 || sc[c] > sc[best]) best = c;
|
||||
}
|
||||
if (best < 0) break;
|
||||
taken |= 1u << best;
|
||||
kid[n] = id[best];
|
||||
kv[n] = sc[best] / q_temp;
|
||||
}
|
||||
for (int i = n; i < 8; ++i) { kid[i] = -1; kv[i] = -INFINITY; }
|
||||
if (n > 0 && rad_mtp_couple_build_q(kid, kv, vocab, s)) {
|
||||
const double u = rad_spechub_uniform(d.seed, d.base,
|
||||
RAD_MTP_COUPLE_KEY_DRAFT + (uint64_t)round);
|
||||
s->x = s->ids[rad_mtp_couple_pick(*s, u)];
|
||||
s->status = 1;
|
||||
return s->x;
|
||||
}
|
||||
s->count = 0;
|
||||
for (int i = 0; i < 8; ++i) { s->ids[i] = -1; s->q[i] = 0; }
|
||||
}
|
||||
int best = 0;
|
||||
float bv = -INFINITY;
|
||||
for (int c = 0; c < K; ++c)
|
||||
if (sc[c] > bv) { bv = sc[c]; best = c; }
|
||||
s->x = id[best];
|
||||
return s->x;
|
||||
}
|
||||
|
||||
/* One sequence's whole walk on the host: the reference the device kernel is checked against, and
|
||||
* what the tests drive. `cand`/`unary` are `steps` rows at pitches `ld_cand`/`ld_unary`, `hp`
|
||||
* `steps` rows at `ld_hp` (null: ones), `tokens` the `steps` tokens dflash_select wrote (rewritten
|
||||
* for a sampled row), `state` round 1's row with `st_round` u32 words between rounds. K <= 32, R a
|
||||
* multiple of RAD_DFLASH_EDGE_PARTS and at most RAD_DFLASH_COUPLE_MAX_R (the plugin's validation).
|
||||
* `pred`/`succ` are [vocab, R]. */
|
||||
static inline void rad_dflash_couple_walk(const int32_t* cand, const float* unary, int64_t ld_cand,
|
||||
int64_t ld_unary, const uint16_t* hp, int64_t ld_hp,
|
||||
int32_t anchor, const uint16_t* pred,
|
||||
const uint16_t* succ, int K,
|
||||
int64_t R, int64_t vocab, int64_t steps, float q_temp,
|
||||
const RadMtpCoupleDraw& d, bool card_ok, int32_t* tokens,
|
||||
uint32_t* state, int64_t st_round) {
|
||||
float a[RAD_DFLASH_COUPLE_MAX_R], sc[RAD_DFLASH_COUPLE_MAX_K] = {};
|
||||
int32_t pid = anchor;
|
||||
for (int64_t l = 0; l < steps; ++l) {
|
||||
RadMtpCoupleState* s = reinterpret_cast<RadMtpCoupleState*>(state + l * st_round);
|
||||
const int32_t* id = cand + l * ld_cand;
|
||||
if (d.mode == 1) {
|
||||
const float* un = unary + l * ld_unary;
|
||||
const bool ok = pid >= 0 && pid < vocab;
|
||||
for (int64_t r = 0; r < R; ++r)
|
||||
a[r] = ok ? rad_dflash_bf2f(pred[(int64_t)pid * R + r]) *
|
||||
(hp ? rad_dflash_bf2f(hp[l * ld_hp + r]) : 1.0f)
|
||||
: 0.0f;
|
||||
for (int c = 0; c < K; ++c) {
|
||||
float acc = 0.0f;
|
||||
if (id[c] >= 0 && id[c] < vocab)
|
||||
for (int j = 0; j < RAD_DFLASH_EDGE_PARTS; ++j)
|
||||
acc += rad_dflash_edge_part(a, succ + (int64_t)id[c] * R, R, j);
|
||||
sc[c] = un[c] + acc;
|
||||
}
|
||||
}
|
||||
pid = rad_dflash_couple_step(sc, id, K, q_temp, d, card_ok, (int)l + 1, vocab, tokens[l], s);
|
||||
tokens[l] = pid;
|
||||
}
|
||||
}
|
||||
|
||||
#undef RAD_SPECHUB_HD
|
||||
#endif /* __cplusplus */
|
||||
#endif /* RAD_SPECHUB_H */
|
||||
Reference in new issue
Block a user