From e28a9d26181ede35833e4d5607b895820dbbf3e9 Mon Sep 17 00:00:00 2001 From: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com> Date: Fri, 13 Nov 2026 16:43:01 -0500 Subject: [PATCH] Converter: preset L (a row in the preset table) and a synthetic two-preset test Preset L uses preset M's map versions and record kinds; a map names it with "preset": "L" and gets its own no-model message (exit 12; the DLSS version named is provisional). run_tests.py adds a synthetic library file with an L block directly before an M block and maps for both: each converts its own block only, and a file without a preset's block fails with that preset's message. The real preset-L map file is not part of this change. Existing synthetic outputs are byte for byte those of main. Refs #89 Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com> --- clean/converter/README.md | 8 +++ clean/converter/src/api.cpp | 3 + clean/converter/src/api.h | 1 + clean/converter/src/map.cpp | 3 + clean/converter/src/map.h | 5 +- clean/converter/tests/cases.py | 84 ++++++++++++++++++++++++++++ clean/converter/tests/run_tests.py | 46 +++++++++++++++ clean/converter/tests/unit_tests.cpp | 13 ++++- 8 files changed, 159 insertions(+), 4 deletions(-) diff --git a/clean/converter/README.md b/clean/converter/README.md index a9e7c807..48467be7 100644 --- a/clean/converter/README.md +++ b/clean/converter/README.md @@ -29,6 +29,13 @@ the version still decides the map's features. A map without the field gets the p not text, or whose preset does not use the map's version (for example `"preset": "K"` in a version-1 map) is "converter data damaged". This is how a further preset that reuses an existing map version is added: one row in that table. +**Preset L** (Model L, issue #89) is such a row: `"preset": "L"` in a map of version 1 or 4. Its maps use the record +kinds of preset M's (no new element format, op or source kind); its parameters are a block of their own in the same +library file as preset M's, found by its own length and hashes like any source. The map file itself +(`data/preset-L.v1.map.json`) comes with the converter data; until it exists, `tests/run_tests.py` covers preset L with a +synthetic library file holding an L block directly before an M block, and maps for both: each converts its own block, +and a file without a preset's block fails with that preset's message. + ## Preset F (map version 5, spec 57) wronggpu-convert --map data\preset-F.v1.map.json --dll [--dll ...] --out [--raw] @@ -112,6 +119,7 @@ Preset K, for the spec team (48-T1, 48-T6): | 11 | file smaller than W (or above 4 GiB) | This is not a DLSS model file. | | 12 | M: W not found. K: T not found | This DLSS file has no preset-M model. Version 310.5 or newer is needed. / This DLSS file has no preset-K model. Version 310.1 or newer is needed. (+ "This file is version a.b.c.d." when the file has a version resource) | | 12 | F: W not found (spec 57 section 8) | This DLSS file has no preset-F (Ray Reconstruction) model. Version 310.7 or newer is needed. (+ the file version when there is one) | +| 12 | L: W not found (a map with `"preset": "L"`) | This DLSS file has no preset-L model. Version 310.9 or newer is needed. (+ the file version when there is one; the version named is provisional) | | 13 | M: W found, D or K not found. K: T found, O not found (spec 48 draft 4 section 8). F: W found, another source (or every variant of IMG-IN) not found. The log names the missing source | This DLSS build is not supported yet (model data found, but other parts differ). | | 14 | F only (spec 57 section 8): a constant's sites disagree, a `const_f16x2` with unequal halves, a `const_f16lo` with a non-zero high half, a non-finite value where 57.6.1 or 57.6.2 forbids it, an RN16 overflow, the two reads of an `also` tensor differ, a `require` or check fails, the attention constants fail 57.6.4. The log names the tensor or check (never a value). Not an installer error: the next file is tried | This DLSS build is not supported yet (model data found, but other parts differ). | | 20 | map invalid: unreadable, bad JSON, bad format or version, unknown op / locate / element / encoding / dtype (or one its version does not define), missing field, unknown perm, perm not dividing its axis, `axes` length ≠ `shape` length, a segment that is not a positive multiple of 4 or runs past the end of T, K sources other than T (and O), `capped_softmax` without 8 × 8 last axes, a source F that is not a keyed optional `lz4-block` block source with variants, a field outside the decoded text, variants with different numbers of fields, a `digest` list whose length is not the number of variants (or a list for a group without variants), a group that mixes tensors from F and from other sources, … Also (spec 08 section 4.3): a variant of F matched its hashes, but the block does not decompress to `decoded_length`, does not match `decoded_sha256`, or a field is not eight hexadecimal digits | Installer error: the converter data is damaged. … | diff --git a/clean/converter/src/api.cpp b/clean/converter/src/api.cpp index 17fde6e9..bf17981a 100644 --- a/clean/converter/src/api.cpp +++ b/clean/converter/src/api.cpp @@ -23,6 +23,9 @@ const char* const kMsgNoPresetK = "This DLSS file has no preset-K model. Version // Spec 57 section 8. const char* const kMsgNoPresetF = "This DLSS file has no preset-F (Ray Reconstruction) model. Version 310.7 or newer is needed."; +// Model L (#89). The DLSS version named is provisional: the first version known to carry a preset-L model; one line to +// change when the first shipping version is confirmed. +const char* const kMsgNoPresetL = "This DLSS file has no preset-L model. Version 310.9 or newer is needed."; const char* const kMsgUnsupported = "This DLSS build is not supported yet (model data found, but other parts differ)."; const char* const kMsgMapDamaged = "Installer error: the converter data is damaged. Please reinstall WrongGPU."; const char* const kMsgMapDoesNotFit = diff --git a/clean/converter/src/api.h b/clean/converter/src/api.h index b8e2adda..e0f95f25 100644 --- a/clean/converter/src/api.h +++ b/clean/converter/src/api.h @@ -42,6 +42,7 @@ extern const char* const kMsgNotModel; extern const char* const kMsgNoPresetM; extern const char* const kMsgNoPresetK; extern const char* const kMsgNoPresetF; +extern const char* const kMsgNoPresetL; extern const char* const kMsgUnsupported; extern const char* const kMsgMapDamaged; extern const char* const kMsgMapDoesNotFit; diff --git a/clean/converter/src/map.cpp b/clean/converter/src/map.cpp index 2f6aa00f..e01f5e97 100644 --- a/clean/converter/src/map.cpp +++ b/clean/converter/src/map.cpp @@ -1378,6 +1378,9 @@ const std::vector& known_presets() { {"M", (1u << 1) | (1u << 4), kMsgNoPresetM}, // spec 08 (version 4 adds the source F) {"K", (1u << 2) | (1u << 3), kMsgNoPresetK}, // spec 48 {"F", 1u << 5, kMsgNoPresetF}, // spec 57 + // Model L (#89): the same record kinds as preset M's map (no new element format, op or source kind), so the + // same map versions; its parameters are a block of their own in the same library file, found by its own hashes + {"L", (1u << 1) | (1u << 4), kMsgNoPresetL}, }; return presets; } diff --git a/clean/converter/src/map.h b/clean/converter/src/map.h index cf335912..e3005a91 100644 --- a/clean/converter/src/map.h +++ b/clean/converter/src/map.h @@ -221,7 +221,7 @@ struct Perm { // model of that preset. A map names its preset in the optional top-level field "preset"; a map without it gets the preset // its version had before the field existed (versions 1 and 4: M; 2 and 3: K; 5: F), so the shipped maps load as before. struct PresetInfo { - const char* name; // "M", "K", "F" + const char* name; // "M", "K", "F", "L" unsigned versions; // bit v set: map version v is allowed for this preset const char* no_model_message; // api.cpp kMsgNoPreset*: the DLL has no model of this preset bool allows(int version) const { return version >= 0 && version < 32 && (versions >> version & 1u) != 0; } @@ -229,7 +229,8 @@ struct PresetInfo { // The known presets, in a fixed order; find_preset: by name (exact, upper case), nullptr when unknown. const std::vector& known_presets(); const PresetInfo* find_preset(const std::string& name); -// The preset a map without a "preset" field has: the one its version always meant ("" for no known version). +// The preset a map without a "preset" field has: the one its version always meant ("" for no known version). The first +// row of known_presets that allows the version: M before L, so a map without the field is never preset L. std::string preset_for_version(int version); struct Map { diff --git a/clean/converter/tests/cases.py b/clean/converter/tests/cases.py index 1d12d24b..18480e91 100644 --- a/clean/converter/tests/cases.py +++ b/clean/converter/tests/cases.py @@ -236,6 +236,90 @@ def mini_case(seed=3, version=None): return case +# ---------------------------------------------------------------- two presets in one file (Model L, #89) + +def _pair_map(rng, preset, label, w_halves, extra_stage): + """One preset's synthetic map and sources: W (f16le), D (u16le), K (keyed pair), and for preset L one stage more + (a stand-in for its extra blocks: an fp8 matrix, a bias, a scaled norm scale).""" + w = bytes(random_finite_halves(rng, w_halves, max_exp_field=0x14)) + d = bytes(rng.randbytes(2048)) + k = struct.pack("allows(1) && find_preset("L")->allows(4) && !find_preset("L")->allows(2) && + !find_preset("L")->allows(3) && !find_preset("L")->allows(5) && std::string(find_preset("L")->no_model_message) == kMsgNoPresetL && + std::string(kMsgNoPresetL).find("preset-L") != std::string::npos); CHECK(std::string(find_preset("M")->no_model_message) == kMsgNoPresetM && std::string(find_preset("K")->no_model_message) == kMsgNoPresetK && std::string(find_preset("F")->no_model_message) == kMsgNoPresetF); { @@ -617,7 +621,12 @@ static void test_api_files(const fs::path& work) { CHECK(load_map_bytes(with_preset(u.map_v4, "4", "\"M\""), pm4, sink).code == kOk && pm4.map && pm4.map->preset_info() == find_preset("M")); // the same map bytes with and without "preset":"M" describe the same tensors (only the file hash differs) CHECK(pm4.map && pm4.map->stages.size() == m4.map->stages.size() && pm4.map->sources.size() == m4.map->sources.size()); - for (const char* bad : {"\"K\"", "\"F\"", "\"X\"", "\"m\"", "\"\"", "7", "null"}) { + LoadedMap lm1, lm4; + CHECK(load_map_bytes(with_preset(u.map_v1, "1", "\"L\""), lm1, sink).code == kOk && lm1.map && lm1.map->preset_name == "L" && + lm1.map->preset() == 'L' && lm1.map->preset_info() == find_preset("L")); + CHECK(load_map_bytes(with_preset(u.map_v4, "4", "\"L\""), lm4, sink).code == kOk && lm4.map && lm4.map->preset_name == "L" && + lm4.map->stages.size() == m4.map->stages.size()); + for (const char* bad : {"\"K\"", "\"F\"", "\"X\"", "\"m\"", "\"l\"", "\"\"", "7", "null"}) { LoadedMap bm; const Result r = load_map_bytes(with_preset(u.map_v1, "1", bad), bm, sink); if (r.code != kMapDamaged) std::printf("preset field %s\n", bad);