Archived
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>
49 lines
1.7 KiB
C++
49 lines
1.7 KiB
C++
/* advance.cpp -- issuing an advance. See advance.h. */
|
|
#include "advance_impl.h"
|
|
|
|
#include "device/device.h"
|
|
|
|
namespace rad {
|
|
|
|
int step_advance(const AdvanceArgs& a, RadStream s) {
|
|
if (a.n_seq <= 0) return RAD_OK;
|
|
/* Host backend streams are queues run by worker threads (device/host.cpp), and device memory
|
|
* is host memory. Drain the stream first so the rows run where the kernel would in stream
|
|
* order; otherwise they can read a sampled token or staged row whose copy is still queued. */
|
|
if (device_is_host()) {
|
|
RAD_TRY(rad_stream_sync(s));
|
|
for (int i = 0; i < a.n_seq; ++i) adv_row(a, i);
|
|
return RAD_OK;
|
|
}
|
|
#if (defined(RAD_HAVE_HIP) && RAD_HAVE_HIP) || (defined(RAD_HAVE_SYCL) && RAD_HAVE_SYCL)
|
|
/* The launcher: advance.hip on the AQL backend, advance_sycl.cpp (in librad_sycl.so) on the
|
|
* SYCL one. A build holds one of the two. */
|
|
return rad_step_advance_launch(&a, (void*)s) == 0 ? RAD_OK : RAD_E_DEVICE;
|
|
#else
|
|
(void)s;
|
|
return RAD_E_UNSUPPORTED;
|
|
#endif
|
|
}
|
|
|
|
int step_compact(const AdvanceArgs& a, RadStream s) {
|
|
if (a.n_seq <= 0 || a.n_pool <= 0) return RAD_OK;
|
|
if (device_is_host()) {
|
|
RAD_TRY(rad_stream_sync(s));
|
|
const int items = adv_compact_items(a);
|
|
for (int i = 0; i < a.n_seq; ++i)
|
|
for (int w = 0; w < items; ++w) {
|
|
int p = 0, l = 0, h = 0;
|
|
if (adv_compact_item(a, w, &p, &l, &h)) adv_compact(a, i, p, l, h, 0, 1);
|
|
}
|
|
return RAD_OK;
|
|
}
|
|
#if defined(RAD_HAVE_HIP) && RAD_HAVE_HIP
|
|
return rad_step_compact_launch(&a, (void*)s) == 0 ? RAD_OK : RAD_E_DEVICE;
|
|
#else
|
|
(void)s;
|
|
return RAD_E_UNSUPPORTED;
|
|
#endif
|
|
}
|
|
|
|
} /* namespace rad */
|