From 337da4f1af7311d2c20cb5275c67a53f3586fd93 Mon Sep 17 00:00:00 2001 From: drmckay Date: Wed, 1 Jul 2026 12:45:11 +0200 Subject: [PATCH] Fix autoencoder CUDA kernel: initialise the example-buffer padding bits The kernel computed number_of_literal_chunks but only set the literal bits, leaving the final-chunk padding uninitialised. Zero the whole buffer first, matching the CPU memset. --- tmu/clause_bank/cuda/tools.cu | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/tmu/clause_bank/cuda/tools.cu b/tmu/clause_bank/cuda/tools.cu index 24fda48f..80f19012 100644 --- a/tmu/clause_bank/cuda/tools.cu +++ b/tmu/clause_bank/cuda/tools.cu @@ -82,12 +82,11 @@ extern "C" unsigned int number_of_literal_chunks = (number_of_literals-1)/32 + 1; - // Initialize example vector X - - for (int k = 0; k < number_of_features; ++k) { - int chunk_nr = k / 32; - int chunk_pos = k % 32; - X[chunk_nr] &= ~(1U << chunk_pos); + // Initialize example vector X to the empty-example state, matching the CPU path (Tools.c): + // zero the whole buffer with number_of_literal_chunks (so the final-chunk padding bits + // are 0), then set the negated-literal bits below. + for (unsigned int c = 0; c < number_of_literal_chunks; ++c) { + X[c] = 0; } for (int k = number_of_features; k < number_of_literals; ++k) {