interplane.Get Omega
Read in your language

CUDApp

CUDA++: AIEN’s GPU machine-code toolchain, runtime and driver client for NVIDIA GPUs without the CUDA toolkit. Hardware coverage and driver replacement limits are explicit.

Brought by drakestapleton

GitHub aien-dev/CUDApp#262 (code only)

closed derived 67f1c0d9de8c52b6 #262

Imported from GitHub aien-dev/CUDApp#262 (code only)

GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed).

Base 183fa4f161de512094e47cd68285dcfde9c53a0c · Head eccdb744b8f1adafb6413711ce7471379c434488

cursor[bot] reviewed (APPROVED) on 2026-11-02 00:35 UTC

Risk: low. Approved. Cursor Security Agent passed with no findings that need human review; Cursor Bugbot was not present, and this is a narrow coefficient-validation change with host tests.

<div><a href="https://cursor.com/agents/bc-c392dcbb-cf3a-4ac8-b4c1-87e190d1b7c0?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a href="https://cursor.com/automations/ca4a13aa-d616-11f1-a7e4-4605a90eab71"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/view-automation-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/view-automation-light.png"><img alt="View Automation" width="141" height="28" src="https://cursor.com/assets/images/view-automation-dark.png"></picture></a> </div>

<sub>Sent by Cursor Approval Agent: Pull Request Router and Approver</sub>

Fetch it

A git bundle of the pull request's head, 2195 bytes.

curl -fsSL https://interplane.io/drakestapleton/CUDApp/patches/67f1c0d9de8c52b6.bundle -o 67f1c0d9de8c52b6.bundle
git fetch 67f1c0d9de8c52b6.bundle refs/pull/262/head

Raw bundle · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/CUDApp
262
eccdb744b8f1adafb6413711ce7471379c434488
{"kind":"github-import","owner":"aien-dev","repo":"CUDApp","number":262,"url":"https://github.com/aien-dev/CUDApp/pull/262","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:39:02Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/src/omega_gpu_q38_graph.c b/src/omega_gpu_q38_graph.c
index ad10394e..614fe00d 100644
--- a/src/omega_gpu_q38_graph.c
+++ b/src/omega_gpu_q38_graph.c
@@ -13,6 +13,7 @@
 #include "omega_gpu_fmt.h"
 #include "omega_gpu_mem_cached.h"
 #include "cudapp_native.h"
+#include <float.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -248,10 +249,18 @@ uint64_t omega_gpu_q38_exact_extra_bytes(void) {
     const uint8_t unused[H*4]={0};uint64_t m[16]={3,248320},q[192]={0},result=0;
     return !omega_q38_runtime(&result,m,16,unused,sizeof unused,q,192) && result==1 ? q[10] : 0;
 }
+/* A NaN, negative or infinite coefficient would silently pick a wrong greedy token; refuse it. */
+int omega_gpu_q38_exact_coef_ok(const float *coef, size_t n) {
+    if (!coef) return 0;
+    for (size_t i = 0; i < n; i++)
+        if (!(coef[i] >= 0.0f) || coef[i] > FLT_MAX) return 0;
+    return 1;
+}
 int omega_gpu_q38_graph_set_exact_head(OmegaGpuQ38Graph *g, const OmegaGpuFp8Tensor *head,
                                       const float *coef, uint32_t roundings) {
     if (!g || !head || !coef || g->in_token || !g->final_set || g->exact8 || g->head8 ||
-        !shape_is(head, g->cfg.vocab, H) || g->cfg.eps != 1e-6f) return OMEGA_GPU_DGRAPH_BAD_ARGS;
+        !shape_is(head, g->cfg.vocab, H) || g->cfg.eps != 1e-6f ||
+        !omega_gpu_q38_exact_coef_ok(coef, g->cfg.vocab)) return OMEGA_GPU_DGRAPH_BAD_ARGS;
     uint64_t m[16]={1,g->cfg.vocab},result=0,entry[2];
     if (omega_q38_runtime(&result,m,16,cpu_of(g,g->lo.fnorm),H*4,g->exact_info,192) || result!=1 ||
         roundings!=g->exact_info[2] || omega_gpu_fp8_tensor_entry(head,0,&entry[0],&entry[1]))
diff --git a/src/omega_gpu_q38_graph.h b/src/omega_gpu_q38_graph.h
index 30ae934b..ee6d73fd 100644
--- a/src/omega_gpu_q38_graph.h
+++ b/src/omega_gpu_q38_graph.h
@@ -97,6 +97,8 @@ int omega_gpu_q38_graph_set_lm_head_fp8(OmegaGpuQ38Graph *g, const OmegaGpuFp8Te
  * The original head is retained. Disable for sampled requests needing all logits. */
 int omega_gpu_q38_graph_set_exact_head(OmegaGpuQ38Graph *g, const OmegaGpuFp8Tensor *head,
                                       const float *coef, uint32_t roundings);
+/* 1 when all n coefficients are finite and >= 0 (set_exact_head refuses anything else), else 0. */
+int omega_gpu_q38_exact_coef_ok(const float *coef, size_t n);
 uint64_t omega_gpu_q38_exact_extra_bytes(void);
 void omega_gpu_q38_graph_set_exact_head_on(OmegaGpuQ38Graph *g, int on);
 int omega_gpu_q38_graph_exact_head_active(const OmegaGpuQ38Graph *g);
diff --git a/tests/gpu_q38_graph_test.c b/tests/gpu_q38_graph_test.c
index 81b5b344..e767bbac 100644
--- a/tests/gpu_q38_graph_test.c
+++ b/tests/gpu_q38_graph_test.c
@@ -227,6 +227,16 @@ static int host_only(void) {
     OmegaGpuQ38GraphConfig c; memset(&c, 0, sizeof c);
     CHECK(omega_gpu_q38_graph_create(&c, &g) == OMEGA_GPU_DGRAPH_BAD_ARGS && !g, "create refuses an empty config");
     CHECK(omega_gpu_q38_graph_create(NULL, &g) == OMEGA_GPU_DGRAPH_BAD_ARGS, "create refuses NULL");
+    float coef[4] = {0.0f, 1.5f, 3.0e38f, 2.0f};
+    CHECK(omega_gpu_q38_exact_coef_ok(coef, 4) == 1, "exact coef: finite nonnegative table accepted");
+    const float bad_vals[3] = {NAN, -1.0f, INFINITY};
+    const char *bad_names[3] = {"NaN", "negative", "infinite"};
+    for (int i = 0; i < 3; i++) {
+        coef[2] = bad_vals[i];
+        CHECK(omega_gpu_q38_exact_coef_ok(coef, 4) == 0, "exact coef: %s entry refused", bad_names[i]);
+    }
+    CHECK(omega_gpu_q38_exact_coef_ok(NULL, 4) == 0, "exact coef: NULL table refused");
+    CHECK(omega_gpu_q38_graph_set_exact_head(NULL, NULL, coef, 0) == OMEGA_GPU_DGRAPH_BAD_ARGS, "set_exact_head refuses NULL graph");
     return g_failed ? 1 : 0;
 }