Repository navigation
Input encoder: opt-in E1b (runtime option e1b=on, default off) - #271
Draft
phantoslayer21 wants to merge 2 commits into
Draft
phantoslayer21 wants to merge 2 commits into
phantoslayer21 wants to merge 2 commits into
Conversation
With e1b=on, Model M on the native D3D12 executor runs the encoder forms e1b/input_encoder[_direct] (encoder.hlsl, ENC_E1 == 2). Each wave issues the loads of its four history taps first. Then, per tap, one wave-wide test checks whether every lane's near / far tap position equals its centre tap position; where it does, that tap's values are copied from the centre tap instead of being computed again. The output is byte for byte the default encoder's. The gain depends on camera motion: still and evenly panning views save the most, strong parallax can be slightly slower. - runtime: runtime_options key e1b=on|off (also WG_RUNTIME_OPTIONS), default off; the kernel line in the log shows e1b=on, or e1b=off (...) when the model, executor or manifest cannot run it (the default encoder then runs). manifest_kernels() moves out of the Model L guard so that builds without Model L can check the manifest. - kernels: e1b/input_encoder and e1b/input_encoder_direct in the model M set (VGPR limit 128). ENC_E1 == 1 (the same test without the early loads) stays in the source as the reference form and is not declared. - test harness: WG_TEST_MOTION_PATTERN = ramp (default) | zero | pan | parallax for the timing legs. - FORMATS.md: the option. Option off: every default kernel unchanged. Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
…l create - device (native D3D12): the default warm-up skips the opt-in forms (optional_kernel: e1b/*), so a missing or failing E1b shader cannot fail a default create, and a default create compiles exactly what it did before. - runtime: the e1b key is read once at create, before Model K's create returns (e1b_option.h e1b_scan), and resolved once (e1b_resolve): E1b runs only for Model M on the native D3D12 executor without motion at output resolution, and only when the route's own form (direct or buffer) prepares. Otherwise the default encoder runs and the reason is kept: Model L, Model K, not the native D3D12 executor, motion at output resolution, not in the manifest, or could not be prepared. The kernel report only reads it (no side effects); the launch follows the create-time route from the first frame. - an invalid value (e.g. e1b=1 or a typo) no longer fails create: E1b stays off and the log gets one line, "e1b: unknown value '1', using off". - tests: clean/runtime/tests/test_e1b_option.py (CPU): the value parse, the options scan and the report item (test_e1b_option.cpp, MSVC), and source checks of the wiring (read and resolved at create, side-effect-free report, no opt-in form in the default warm-up). - test harness: WG_TEST_RESET_AT=<frame>[,...] for mid-stream resets in the byte legs. - FORMATS.md: the create-time choice, the reasons, the fallback, and the byte-identity scope. Signed-off-by: phantoslayer21 <156617979+phantoslayer21@users.noreply.github.com>
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.
Opt-in E1b for Model M's input encoder: runtime option
e1b=on(runtime_options, alsoWG_RUNTIME_OPTIONS), default off. With the option off, nothing changes: the default warm-up compiles the same kernels as before and every default kernel is unchanged.With
e1b=on, Model M on the native D3D12 executor runs the encoder formse1b/input_encoder[_direct](clean/dx12/kernels/encoder.hlsl,ENC_E1 == 2). Each wave issues the loads of its four history taps first. Then, per tap, one wave-wide test (WaveActiveAllTrue) checks whether every lane's near / far tap position equals its centre tap position. Where it does, that tap's values are copied from the centre tap instead of being computed again. On the validated driver (below) the output is byte for byte the default encoder's.The gain depends on camera motion: a still or evenly panning view saves the most, and strong parallax gains nothing and can be slightly slower. That is why it is opt-in and not the default.
e1bkey is read once at create, before Model K's create returns (clean/runtime/e1b_option.h), and resolved once (e1b_resolve). E1b runs only for Model M on the native D3D12 executor without motion at output resolution, and only when the form for the context's route (direct or buffer) prepares: shader, digest, pipeline. Otherwise the default encoder runs, and the kernel line of the log sayse1b=off (<reason>): Model L, Model K, not the native D3D12 executor, motion at output resolution, not in the manifest, or could not be prepared. With E1b running it sayse1b=on. The kernel report only reads the choice made at create; the launch follows it from the first frame.e1b=1, a typo) does not fail create: E1b stays off and the log gets one line,e1b: unknown value '1', using off.optional_kernel), so a missing or failing E1b shader cannot fail a create; only the selected form is prepared, and only withe1b=on.e1b/input_encoderande1b/input_encoder_directin the model M set (VGPR limit 128).ENC_E1 == 1, the same test without the early loads, stays in the source as the reference form and is not declared.manifest_kernels()moves out of the Model L guard (builds without Model L check the manifest).clean/runtime/tests/test_e1b_option.py(CPU): value parse, options scan and report item (test_e1b_option.cpp), and source checks of the wiring.WG_TEST_MOTION_PATTERN=ramp(default, unchanged) |zero|pan|parallax, andWG_TEST_RESET_AT=<frame>[,...](mid-stream resets).clean/FORMATS.md: the option.Based on: own design (the encoder's tap positions, spec 03 and the existing
encoder.hlsl).Measured
Interleaved timing: fresh process per run, order reversed on odd rounds, 3 rounds, 1500 frames per run, synthetic Model M, direct route, D3D12 timestamps. Frame time, paired median of (e1b on) - (default), per synthetic motion pattern. The gain depends on camera motion.
Every timing run's 1500-frame output hash is identical between e1b on and the default. The timing was measured with E1b selected through a development switch; the two E1b kernels of this branch are sha256-identical to the ones timed.
Tested
RX 9070 XT, AMD driver 32.0.32015.7029, synthetic Model M, the direct route (the route of every shipped configuration). Each run is its own process; "launch trace" counts the encoder launches per run.
Option off: every default D3D12 kernel (47 DXIL files) and every HIP code object (44) is sha256-identical to the same build of main. The final-output hash over 1500 frames equals main's: 1440p Quality
4032aeefd33ef6e4, 1080p Quality096e28df06b8af96. Launch trace: the default encoder in every frame, no E1b launch, noe1bitem in the log.Option on (
e1b=on): the 1500-frame output hash equals the option-off run for every motion pattern at both shapes, and the launch trace shows the E1b kernel in all 1500 frames and the default encoder in none (log:e1b=on):096e28df06b8af964032aeefd33ef6e427ed43e328910df19fb5697a11743fabfbe19d2cd8099a16888af40bbc40131bd272c4f74344e92230a2b49361b75c7cOdd size, 1001x563 -> 1501x845, 600 frames: option off equals main (
5f0fdf4d31a766f8); option on equals off with the ramp (5f0fdf4d31a766f8) and zero (01be5ec391ce5e88) patterns, E1b in all 600 frames.Mid-stream resets on frames 350, 351, 420 and 599, 600 frames, 1440p Quality: on equals off with the zero (
fa3feca957453372) and parallax (5c3742b498e010e3) patterns, E1b in all 600 frames, the reset frames included. Without the resets the zero run giveseadd3a1e7f71e625, so the resets took effect.Fallbacks, 1440p Quality:
e1b=1creates, logse1b: unknown value '1', using off, runs the default encoder and gives the default bytes. With both E1b shaders corrupted on disk, a default create succeeds with the default bytes, ande1b=oncreates, logse1b=off (e1b/input_encoder_direct could not be prepared: native D3D12 shader integrity mismatch: ...)and gives the default bytes. Motion at output resolution withe1b=on:e1b=off (motion at output resolution runs its own encoder), no E1b launch.RGA (gfx1201), default vs E1b: the same floating-point arithmetic instructions in the same numbers on both routes (direct 2614 = 2614, buffer 2516 = 2516; FMA, multiply, add, subtract, min / max and conversions each equal after merging the dual-issue and constant-operand encodings).
e1b/input_encoder_direct: 89 VGPRs, no spills.clean/runtime/tests/test_e1b_option.py(CPU) passes.public_gates.py: the must-pass gates pass. The leak scan of the changed files has 0 hits, and the whole-tree leak and number lists are the same as main's.Not tested
e1b=onon the GPU: the code reportse1b=off (Model L)/(Model K)/(not the native D3D12 executor)and runs their own encoders; not run here (the synthetic model set has Model M only).Records: e1b-summary.json (timing), e1bev-runs.jsonl (the legs above), e1b-isa-fpops.json (the instruction comparison); team records.