From Niko1221/Strata tag v0.2.4 (commit 96ca4383, 2026-10-24), unmodified: src/dsv41/ (the engine and its vendored
EXL3 / sampler / window kernels), include/strata/dsv41/, tests/dsv41/, tools/dsv41/{pack_gguf,smoke,tune}.py,
data/dsv41/ (the shipped hot-expert profiles), tools/trellis/tqenc.{cpp,hpp} (the tests' encoder),
third_party/project-maya/ (the MIT notice: the engine is a port of Project Maya's maya-ds4),
third_party/ggml/ggml-common-tq.h, docs/DEEPSEEK41.md (upstream's text, to be rewritten for this fork).
src/kernels/cpu: upstream's iq_avx2.{cpp,hpp}, iq_avx2_rows.inl, iq_avx512.{cpp,hpp} replace this fork's
(v0.1.45-poly.1) copies - they add the engine's CPU lane rows iq256x_rows / iq512x_rows and leave the main engine's
iq256_* / iq512_* as they were (upstream's statement; iq_avx2_parity is the check) - and the trellis CPU lane
tq_cpu.{hpp,cpp}, tq_avx2.cpp, tq_avx512.cpp, tq_states.hpp, tq_computed.hpp is new. expert_layout.hpp stays at
layout version 4 (upstream's 5 adds Hadamard-folded packs this fork has no use for yet).
CMakeLists.txt: upstream's strata-dsv41 block, with ggml.h / ggml-cpu.h coming through strata_kernels_cpu's ggml-cpu
link from the submodule (no FetchContent), the tq sources and flags in strata_kernels_cpu, and iq_avx512.cpp built
with -mavx512vpopcntdq -mbmi2 as upstream does (iq512x_rows uses them). Makefile: STRATA_BUILD_DSV41=ON and
strata-dsv41 among the targets `make build` produces.
Target: ISTA-DASLab/DeepSeek-V4.1-Flash-1017-GSQ-RCO-GGUF (IQ1_M / IQ2_XXS + the IQ4_NL Engram) on the A6000 VM.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
46 lines
2.7 KiB
C++
46 lines
2.7 KiB
C++
// Copyright (c) 2026 Peasant Smith and the Project Maya contributors (MIT; https://github.com/mw00/project-maya, v1.1.17).
|
|
// Ported into Strata (third_party/project-maya/NOTICE.md, LICENSE); changes are in the git history of this file.
|
|
// include/strata/dsv41/hip_or_cuda.h - the runtime the dsv41 *tests* need, whichever backend the build has.
|
|
//
|
|
// The engine's own sources take their runtime from the backend's headers (ds4_*.cu compile as HIP or as CUDA). The tests
|
|
// are plain .cpp files that launch kernels and copy buffers, and they used to include <hip/hip_runtime.h> unconditionally,
|
|
// which no CUDA toolkit ships: every CUDA box had to pass a shim on -I to build them (found on l620 and z440, 2026-10-23).
|
|
// This header is that shim, in the tree: HIP names on a HIP build, mapped onto the CUDA runtime otherwise.
|
|
//
|
|
// Two details that a first version got wrong (z440, 2026-10-23): HIP's hipMalloc is a *template* taking T**, so a plain
|
|
// void** overload does not bind `hipMalloc(&uint8_ptr)`; and hipMemset has no CUDA counterpart under that name.
|
|
#pragma once
|
|
|
|
#if defined(__HIP_PLATFORM_AMD__) || defined(__HIPCC__)
|
|
#include <hip/hip_runtime.h>
|
|
#else
|
|
#include <cuda_runtime.h>
|
|
|
|
using hipError_t = cudaError_t;
|
|
using hipEvent_t = cudaEvent_t;
|
|
using hipStream_t = cudaStream_t;
|
|
constexpr hipError_t hipSuccess = cudaSuccess;
|
|
constexpr int hipMemcpyHostToDevice = cudaMemcpyHostToDevice;
|
|
constexpr int hipMemcpyDeviceToHost = cudaMemcpyDeviceToHost;
|
|
|
|
inline hipError_t hipMalloc(void** p, size_t n) { return cudaMalloc(p, n); }
|
|
template <typename T>
|
|
inline hipError_t hipMalloc(T** p, size_t n) { return cudaMalloc(reinterpret_cast<void**>(p), n); }
|
|
inline hipError_t hipFree(void* p) { return cudaFree(p); }
|
|
inline hipError_t hipMemcpy(void* dst, const void* src, size_t n, int kind) {
|
|
return cudaMemcpy(dst, src, n, static_cast<cudaMemcpyKind>(kind));
|
|
}
|
|
template <typename T>
|
|
inline hipError_t hipMemcpy(T* dst, const T* src, size_t n, int kind) {
|
|
return cudaMemcpy(static_cast<void*>(dst), static_cast<const void*>(src), n, static_cast<cudaMemcpyKind>(kind));
|
|
}
|
|
inline hipError_t hipMemset(void* p, int v, size_t n) { return cudaMemset(p, v, n); }
|
|
inline hipError_t hipDeviceSynchronize() { return cudaDeviceSynchronize(); }
|
|
inline hipError_t hipSetDevice(int d) { return cudaSetDevice(d); }
|
|
inline const char* hipGetErrorString(hipError_t e) { return cudaGetErrorString(e); }
|
|
inline hipError_t hipEventCreate(hipEvent_t* e) { return cudaEventCreate(e); }
|
|
inline hipError_t hipEventRecord(hipEvent_t e, hipStream_t s = nullptr) { return cudaEventRecord(e, s); }
|
|
inline hipError_t hipEventSynchronize(hipEvent_t e) { return cudaEventSynchronize(e); }
|
|
inline hipError_t hipEventElapsedTime(float* ms, hipEvent_t a, hipEvent_t b) { return cudaEventElapsedTime(ms, a, b); }
|
|
#endif
|