gr_parity, ple_parity: wait for the default-stream setup before launching on the test stream
Both tests upload and memset on the legacy default stream, then launch on a cudaStreamNonBlocking stream, which does not wait for it. cudaMemset is asynchronous to the host and a pageable cudaMemcpy may return before the DMA lands, so the kernels can read buffers still being written. A device sync before each launch closes it, the same fix 0.1.36 made in the fused tests. Not reproduced on an RTX 5090: 0 failures in 210 runs of gr_parity before and after. Only the first commit of the PR (the stream syncs); the second one (a rewrite of ple_parity without the fixtures) is not taken. The same syncs for the HIP tests were not added (no AMD test machine). (PR #568)
This commit is contained in:
1 parent
b8aca3e6fb
commit
832b2e4f34
2 files changed
+12
No files matched your search
@@ -190,12 +190,15 @@ int scalar_activation_contract() {
|
||||
};
|
||||
check(cudaMemcpy(d_R, ones, sizeof(ones), cudaMemcpyHostToDevice), "scalar upload R");
|
||||
check(cudaMemcpy(d_weights, weights, sizeof(weights), cudaMemcpyHostToDevice), "scalar upload weights");
|
||||
// the uploads run on the legacy stream from pageable memory, which the non-blocking `stream` does not wait for
|
||||
check(cudaDeviceSynchronize(), "scalar setup");
|
||||
cudaStream_t stream;
|
||||
check(cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking), "scalar stream");
|
||||
int bad = 0;
|
||||
for (float gamma : {1.0f, 1.00390625f}) {
|
||||
const float gammas[] = {gamma, gamma};
|
||||
check(cudaMemcpy(d_norm, gammas, sizeof(gammas), cudaMemcpyHostToDevice), "scalar upload norm");
|
||||
check(cudaDeviceSynchronize(), "scalar norm sync");
|
||||
float mixed_by_mode[3][2] = {}, inject_by_mode[3] = {};
|
||||
for (int mode = 0; mode < 3; ++mode) {
|
||||
select_activation_mode(mode);
|
||||
@@ -243,6 +246,7 @@ int scalar_activation_contract() {
|
||||
|
||||
const float sentinel = -73.25f;
|
||||
check(cudaMemcpy(d_inject, &sentinel, sizeof(float), cudaMemcpyHostToDevice), "scalar sentinel");
|
||||
check(cudaDeviceSynchronize(), "scalar sentinel sync"); // a late sentinel would hide a write to d_inject
|
||||
select_activation_mode(mode);
|
||||
gr_read(d_R, d_norm, d_weights, d_weights + 4, nullptr, 0.0f,
|
||||
sh, ws, d_mixed, d_inject, stream);
|
||||
@@ -358,6 +362,8 @@ int fused_multi_lds_parity(const float* d_norm, const uint16_t* d_down, const ui
|
||||
|
||||
cudaStream_t stream = nullptr;
|
||||
check(cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking), "multi stream");
|
||||
// the uploads above (and the caller's weights) run on the legacy stream, which the non-blocking `stream` does not wait for
|
||||
check(cudaDeviceSynchronize(), "multi setup");
|
||||
// Max T forces the HIP kernel's full dynamic-LDS request: 8 * 1280 * sizeof(float) = 40 KiB.
|
||||
fused_gr_read_multi(args.data(), T, d_xn, stream);
|
||||
check(cudaStreamSynchronize(stream), "multi max-T sync");
|
||||
|
||||
@@ -199,6 +199,8 @@ int history_advance_regression() {
|
||||
float* history = history_storage + guard;
|
||||
float* norm = norm_storage + guard;
|
||||
ck(cudaMemcpy(history, expected.data(), count * sizeof(float), cudaMemcpyHostToDevice), "history initial values");
|
||||
// the guard memsets and this upload run on the legacy stream, which the non-blocking `stream` does not wait for
|
||||
ck(cudaDeviceSynchronize(), "history setup");
|
||||
cudaStream_t stream;
|
||||
cudaGraph_t graph;
|
||||
cudaGraphExec_t executable;
|
||||
@@ -880,6 +882,9 @@ int main(int argc, char** argv) {
|
||||
ck(cudaStreamCreateWithFlags(&stream, cudaStreamNonBlocking), "native PLE key stream");
|
||||
const size_t workspace_bytes = (size_t) k::ple_block_scratch_bytes();
|
||||
ck(cudaMemset(ple_ws, 0xa5, workspace_bytes), "native PLE no-launch sentinel");
|
||||
// the guards, the weight upload and the sentinel run on the legacy stream, which the non-blocking
|
||||
// `stream` does not wait for
|
||||
ck(cudaDeviceSynchronize(), "native PLE key setup");
|
||||
int refused = 0;
|
||||
for (int c = 0; c < 9; ++c) {
|
||||
auto invalid = nw;
|
||||
@@ -905,6 +910,7 @@ int main(int argc, char** argv) {
|
||||
std::vector<float> projected(hcd), normalized(hcd), actual_key(hcd), actual_result(hcd), replay(hcd);
|
||||
for (int p = 0; p < std::min(cap.nt, 2); ++p) {
|
||||
ck(cudaMemcpy(d_emb, cap.emb.data() + (size_t) p * nd, nd * 4, cudaMemcpyHostToDevice), "native PLE key input");
|
||||
ck(cudaDeviceSynchronize(), "native PLE key input sync");
|
||||
k::native_q2_0_f32(native_data, d_emb, native_q, raw_projection, k::NG_N_EMBD, k::NG_HC_DIM, 1, stream);
|
||||
ck(cudaStreamSynchronize(stream), "native PLE raw key sync");
|
||||
ck(cudaMemcpy(projected.data(), raw_projection, hcd * 4, cudaMemcpyDeviceToHost), "native PLE raw key read");
|
||||
|
||||
Reference in new issue
Block a user