Repository navigation
Pfpl 4gib fields - #8
Open
Seth-Wolfgang wants to merge 9 commits into
Open
Seth-Wolfgang wants to merge 9 commits into
Seth-Wolfgang wants to merge 9 commits into
Conversation
Work in progress, on a branch for testing.
- fz::pfpl (modules/fused/chunk_fusion/pfpl_stream.{h,cu}): compress a float field from one device buffer into another and
back, in one kernel each, ordered on a stream with no host synchronization. The archive is byte-identical to the PFPL preset's
in ABS mode.
- AMD wave64 kernels for it (pfpl_stream_amd.inl), used on HIP. CUDA uses the generic chunk harness.
- include/backend/fp.h: fmulRounded(). On HIP, clang fused the bound check's multiply into its subtraction, so the check tested
the exact product and passed values that decode up to half an ulp past the bound.
- backend/warp.h whole-wavefront primitives, chunk_fusion.cuh on the backend wrappers, and no NVRTC fusion on HIP.
Tested on MI250X with the HIP backend on development only. main configures for CUDA alone, so this branch has not been built yet.
Still missing for a PR: CHANGELOG entries, an in-tree test, a CN-* note, and removing two device-side printf calls.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
-DFZGMOD_BACKEND=HIP configures and builds again. The root CMakeLists.txt, presets and package config take their HIP hunks from development, without its profiling target, which main does not have. Module and test CMake files already branch on the backend. NVRTC specialization is not built on HIP, so every stage runs staged. Four tests need it or include cuda_runtime.h directly, so they are CUDA-only. On one MI250X GCD, 50 of 53 tests pass. test_huffman, test_log_transform and test_stage_registry fail on HIP, and they are not changed here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Plan::reserve cleared its ticket counter and look-back state with a stream-less cudaMemset, which is not ordered with a non-blocking stream's kernels. The first encode could read old page contents as its ticket, compute a wild chunk id and stop with a memory aperture violation. The clears now run on the calling stream, ahead of that call's kernel. See CN-PFPLSTREAM-2. tests/stages/test_pfpl_stream.cpp compares fz::pfpl with the staged pipeline. On HIP, CTest runs it with the AMD kernels and with the generic harness kernels. The device-side printf in the decode error paths is gone, and the measurements moved from code comments to CN-PFPLSTREAM-1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fzgmod_modules calls fz::MemoryPool but never declared the dependency, so libfzgmod_modules.so had no DT_NEEDED entry for libfzgmod_mem.so. A consumer that links the library without calling fzgmod_mem itself failed with undefined references on toolchains that default to --as-needed, such as Ubuntu's GCC. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CN-PFPLSTREAM-3 has the 64-bit chain, the radius, how the float-sized header records the bound, and the throughput on one MI250X GCD. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
compressHost and decompressHost read and write the same stream as the kernels, byte for byte, in plain C++, with no device, Plan or GPU. A caller off the GPU path no longer has to stage a stream through the device: in QCLAB++ that ran out of memory reading back double tiles of 512 MiB, and a rank with no GPU could not code at all. PfplHostCase holds them to the kernels on both kernel sets, both types and every size class, including a hostile field for conversions out of range. compress() and compressHost() now share their checks and quantizer parameters through quantParams(). See CN-PFPLSTREAM-4. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CN-PFPLSTREAM-4 named the caller it came from. Say what any caller needs, and call the measured data a field, as the rest of the library does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
compress()/decompress() refused any field of 4 GiB or more, because even its all-raw stream could pass the LC archive's 32-bit sizes. A field that size usually codes to far less (an 8 GiB state-vector tile to a few MB). The kernels themselves only need 32-bit element counts, so the GPU coder now checks that (fitsKernels: under 2^32 elements in whole chunks) and checks the stream's own length while writing it: - Look-back offsets saturate at 0xffffffff instead of wrapping, so a chunk past 4 GiB is never written over earlier bytes. - A stream that would reach 4 GiB records 0xfffffffc archive bytes in its header. compress() reports SIZE_MAX through d_stream_bytes, and streamBytes() reads the header the same way, so the stream fits no buffer. The capacity is clamped to what a header can record. The LC field-size word of such a field holds its size modulo 2^32, which the decoder already compares the same way. compressHost()/decompressHost() keep the 4 GiB field limit. Tests: PD7 (an 8 GiB field round-trips; the host coder refuses it) and PD8 (a stream that would pass 4 GiB fits no capacity, and nothing is written past the length a header can record). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Title: fz::pfpl: the GPU coder takes fields of 4 GiB and more
Branch
pfpl-4gib-fields(1002dcd), one commit on the fork'smain(74855a4, the head of #7).What
fz::pfpl::compress()/decompress()used to refuse every field of 4 GiB or more. The check was a worst case: even anall-raw stream had to fit the LC archive's 32-bit sizes. The GPU kernels only need 32-bit element counts, so the GPU
coder now checks that limit instead: under 2^32 elements in whole chunks (
fitsKernels).Relaxing that check alone would let a stream that does reach 4 GiB corrupt itself silently. Its 32-bit look-back
offsets would wrap, later chunks would land on earlier bytes, and the stream would report a wrapped length that looks
like it fits. The rest of the change stops that:
0xffffffffinstead of wrapping.0xfffffffcarchive bytes in its header, andcompress()reportsSIZE_MAXthroughd_stream_bytes.streamBytes()reads that header asSIZE_MAX, so the stream fits no buffer.compress()clamps the capacity to what a header can record, so nothing is written past that length.The LC field-size word of such a field holds its size modulo 2^32, which the decoder already compares the same way.
compressHost()/decompressHost()keep the 4 GiB field limit. Documentation is inpfpl_stream.hand the changelog.Testing
test_pfpl_streamran on the AMD kernels and on the generic harnesskernels. 489 of 490 passed in each set. The one failure was PD8's input: uniform noise at 1e-12 coded to 3.3 GiB,
under the 4 GiB it tests. PD8 now uses random 64-bit patterns, and PD7 and PD8 pass on both kernel sets. The
library source did not change between the two runs; only the test did.
(
--verify-analytic), GHZ and BV run at 36 qubits, and GHZ and BV run at 59 qubits on 256 nodes.pfpl_stream.cuandtest_pfpl_stream.cppcompile with nvcc 13.1 for sm_80. They have not run on anNVIDIA GPU yet.
New tests:
PfplStream64.FieldOf8GiBRoundTrips: an 8 GiB field (2^30 doubles) round-trips within the bound, its LCfield-size word is 0 (2^33 modulo 2^32), and the host coder refuses it. Skipped without about 20 GiB of free device
memory.
PfplStream64.StreamOf4GiBOrMoreNeverFits: a 5 GiB stream that would pass 4 GiB fits no capacity(
SIZE_MAXfrom the kernel and from the header), and nothing is written past the length a header can record.Skipped without about 10 GiB.