Download docs/IMPLEMENTATION_GUIDE.md from PureOne/YEORIN-X-v4-Research: direct link, hf CLI and curl.
- Browser
- Download file 18.1 kB
-
https://huggingface.co/datasets/PureOne/YEORIN-X-v4-Research/resolve/main/docs/IMPLEMENTATION_GUIDE.md
- Command line
-
hf download hf://datasets/PureOne/YEORIN-X-v4-Research/docs/IMPLEMENTATION_GUIDE.md
-
curl -L -o IMPLEMENTATION_GUIDE.md https://huggingface.co/datasets/PureOne/YEORIN-X-v4-Research/resolve/main/docs/IMPLEMENTATION_GUIDE.md
Implementation guide
This guide maps the supplied components to a controlled implementation and identifies the contracts an adapter must establish. The release is a research package: it has no arbitrary-game adapter, no verified Windows executable, and no measured input-to-photon result. Its useful starting point is the tested Python/C++ control core and the reproducible RGB experiments.
1. Choose an implementation track
| Track | Entry points | What it does | Boundary |
|---|---|---|---|
| RGB inference and replay | yeorinx4.pipeline.replay_arrays, tools/replay_v4.py |
Infers restricted camera response from image/input history and evaluates causally available decisions | Offline event schedule; same-source geometric counterfactual |
| Late scalar certificate | yeorinx4.lease.Lease, revalidate; native4/lease.hpp |
Revalidates a prepared field against drift, native freshness, identity, expiry and implementation error | Requires independently justified bounds; not wired into RGB replay |
| CPU worker and candidate eligibility | LatestOnlyWorker, MeasuredBudget, CandidateGate in yeorinx4.runtime |
Completion publication, latest-only queuing, timing estimates and content eligibility | Does not own a GPU queue or reserve presentation time |
| Geometry and field realization | yeorinx3.control.ActionLibrary, shaders/warp.frag, shaders/warp.hlsl |
Bounded, pinned screen-space sampling | Non-rigid deformation; HLSL is uncompiled in the supplied evidence |
| Source-owned Windows laboratory | windows/YeorinLab.cpp |
Controlled D3D11 test window, foreground input and software diagnostics | Source only; RGB observer is not connected |
| Optical event analysis | yeorinx4.optical.analyze_csv |
Validates and analyzes already decoded paired optical events | Does not acquire, associate or authenticate measurements |
The first four tracks are separate components. In particular, the current replay_arrays calls the inherited rational cone selector and yeorinx3.contract.CommitGate; it does not invoke yeorinx4.lease.revalidate as an additional late stage. Combining those paths is new implementation work and must receive its own evidence record.
2. Establish the reference environment
Run commands from the repository root. Python 3.10 or newer is required by pyproject.toml; Python 3.13.5 was used for the archived environment. NumPy/OpenCV are runtime dependencies, pytest is a test dependency, and CMake plus a C++17 compiler are needed for native checks.
python -m pip install -e ".[test]"
python tools/research.py doctor
python tools/research.py build
python tools/research.py test --out runs/tests
python tools/research.py replay --recorded --backend auto --out runs/primary-recorded
The release convenience CLI writes new experiment artifacts to runs/ and leaves archived results/ and data/primary/ intact. See EXPERIMENT_GUIDE.md for experiment design and TROUBLESHOOTING.md for compiler/library issues.
The Hugging Face packaging version is 4.0.0-hf.1; it keeps the research core at 4.0.0. Newly executed checks are recorded separately in release/HF_RELEASE_VERIFICATION.json rather than rewriting upstream verification.
The upstream low-level build commands remain:
cmake -S native -B native/build -DCMAKE_BUILD_TYPE=Release
cmake --build native/build --config Release
cmake -S native4 -B native4/build -DCMAKE_BUILD_TYPE=Release
cmake --build native4/build --config Release
ctest --test-dir native4/build --output-on-failure
YEORIN_NATIVE points to the inherited selector library; YEORIN4_NATIVE points to the independent v4 scalar library when its parity test needs a non-default path. These are different libraries. A .so from Linux is not a Windows DLL.
3. Observable data and calibration
The replay accepts a dictionary containing the following arrays. Use np.load(path, allow_pickle=False) and read named numeric arrays rather than opaque serialized objects.
| Array | Meaning | Requirement |
|---|---|---|
frames |
Source images at their actual receipt events | Consistent image geometry and uint8 channel format |
receipt_times |
Source availability times, seconds | Strictly increasing; one per source frame |
now_times |
Modeled display decision events, seconds | One per source frame in the supplied replay convention |
input_times |
Time-stamped input samples, seconds | Common calibrated clock and sufficient preceding history |
input_cumulative |
Cumulative two-axis input | Shape compatible with input_times; declared input-rate bound |
Ground truth belongs only in scoring_truth.npz, which the observer/replay does not read. It is used after decisions are written by experiments.score.score. Do not place target/source poses, future input, realized camera gain or realized source delay into a proposed observer's inputs.
The existing profile explicitly supplies width, height, horizontal field of view, protected opaque rectangles, gain/delay ranges, error allowance, source-pitch cap and timing assumptions. It is not blind calibration of arbitrary games. data/primary/config.json is a precise example of the supported schema.
The version: "3.0.0" field in generated trace configurations is inherited trace metadata; it is not evidence that the v4 observer was skipped. Check the replay's metadata.observer_kind and the package version separately.
Geometry cache
data/action_cache_480x270.npz is tied to the exact dimensions, FOV, normalized weights, protected rectangles and rho used by the supplied trace. yeorinx3.cache.load validates its profile key and rejects a mismatch. Do not reuse it after changing any of those quantities.
For a new controlled geometry, construct and optionally save a new ActionLibrary outside the real-time path:
from yeorinx4.pipeline import make_weights
from yeorinx3.control import ActionLibrary
from yeorinx3.cache import save
weights, mask = make_weights(cfg)
library = ActionLibrary(
cfg["width"], cfg["height"], cfg["fov_deg"], weights,
cfg["protected"], cfg["rho"],
)
save(library, "runs/custom_action_cache.npz")
Create runs/ before that snippet. Precomputation can be expensive. The v4 replay also slices the candidate arrays on its library instance to retain the inherited cone-only policy; use a fresh loaded or constructed instance for each independent run and do not share one mutable instance across concurrent replays.
4. Use the RGB observer directly
The actual class is GuardedRotationObserver. The update implementation uses OpenCV's BGR channel convention for a three-channel image, despite the research description using RGB as the general image-observation label. Convert externally supplied RGB images explicitly. Gray uint8 input is also accepted.
import cv2
from yeorinx4.observer import GuardedRotationObserver
observer = GuardedRotationObserver(
width=480, height=270, fov_deg=90.0,
tracking_width=240, max_features=64, reseed_every=8,
)
bgr = cv2.cvtColor(rgb_uint8, cv2.COLOR_RGB2BGR)
visual = observer.update(bgr, mask)
if visual.valid:
yaw_pitch_increment = visual.delta
else:
diagnostic_reason = visual.reason
mask is an optional image-sized uint8 feature mask: zero excludes tracking and positive values permit it. The weighting function also zeros declared protected regions. The returned increment is a diagnostic image-model estimate, not a proof that mouse input has the same causal effect in every camera mode.
The observer requires at least 24 features, performs forward/backward tracking and spatial-consensus checks, and tests local and accumulated nonrotation. Keep updates sequential for a given observer; its previous image, tracked points, guard history and invalidation latch are stateful.
After detected nonrotation, profile_invalidated remains latched and subsequent updates return profile_invalidated_requires_recalibration. Reconstruct an observer only after independently establishing a new camera profile. Merely resetting a guard or clearing the Boolean defeats the intended protection.
Known blind spots remain: a hidden camera lock can initially share the same observable history as continued motion; arbitrary translation, roll, orbit pivots, unknown HUDs and generated frames without coherent pose are outside the scored model. A pure identity transform is geometrically compatible with rotation and cannot reveal a future semantic lock.
5. Use the lease API without inventing bounds
All norm-based quantities refer to the same normalized weighted image-displacement space. Norms and maximum displacement are pixels; correlation, field energy, lower gain and path-loss charges are squared pixels; times are seconds.
| Lease/query quantity | Source of the value |
|---|---|
source_id, generation, profile_epoch |
Host-owned immutable source/resource/profile identities |
published_s, expires_s, now_s |
The same monotonic clock; publication after completed preparation |
correlation_lower |
A justified lower bound on the target-displacement/field correlation |
field_energy |
Normalized weighted sum of the unscaled field's squared displacement |
field_max_px |
Conservative maximum displacement of that unscaled field |
residual_norm_cap |
Bound on target response missing from the source at preparation |
residual_drift_cap |
Bound on how that residual changed after preparation |
native_offset_cap |
Independent bound on additional response in the actual native alternative at the same output opportunity |
pixel_cap, alpha_cap |
Predeclared intervention limits, with 0 <= alpha_cap <= 1 |
implementation_error_px |
Bound on field-realization error in the same weighted norm |
path_loss_charge |
An independently justified loss charge in squared pixels |
The Python constructor also verifies field_energy <= field_max_px**2 + 1e-8, which follows from normalized nonnegative pixel weights. Do not use an unnormalized sum in one field and a normalized maximum contract in another.
This exact API example uses illustrative values to demonstrate an admitted scalar decision. They are not estimated from gameplay and do not establish a practical correction:
from yeorinx4.lease import Lease, revalidate
lease = Lease(
source_id=1, generation=2, profile_epoch=3,
published_s=1.0, expires_s=2.0,
correlation_lower=16.0, field_energy=4.0,
field_max_px=2.0, residual_norm_cap=10.0,
)
decision = revalidate(
lease, now_s=1.2, source_id=1, generation=2, profile_epoch=3,
residual_drift_cap=0.0, native_offset_cap=0.0, pixel_cap=12.0,
)
assert decision.status == "conditional_admit"
assert decision.alpha == 1.0
assert decision.lower_bound == 28.0
native_offset_cap=0 is justified only if the host has independently established that the correction and native alternative use the same candidate. It is not the default assumption for captured frames. Clock age alone does not supply a drift bound. Milliseconds cannot be inserted into path_loss_charge without a declared, justified loss model.
The hot path rejects identity changes, unpublished/expired certificates, zero fields, invalid quantities and nonpositive native-relative bounds. A zero decision means abstention; it does not prove that earlier observer/GPU work was free. risk_limited_alpha supplies a separate worst-case loss-budget cap, without promising a positive benefit.
C++ path
The source-facing C++ API is header-only in native4/lease.hpp:
#include "lease.hpp"
yeorin4::Lease lease;
lease.source = 1; lease.generation = 2; lease.epoch = 3;
lease.published = 1.0; lease.expires = 2.0;
lease.a = 16.0; lease.energy = 4.0;
lease.maximum = 2.0; lease.residual = 10.0;
yeorin4::Query query;
query.source = 1; query.generation = 2; query.epoch = 3;
query.now = 1.2; query.pixelCap = 12.0;
const yeorin4::Decision decision = yeorin4::revalidate(lease, query);
The shared library exports yeorin4_query for the supplied numerical parity harness. Its double-array wrapper fixes source to 1 and leaves generation/epoch at zero; it is not a complete host-facing identity ABI. A host should use the header API or implement and test a richer ABI carrying all identities. Do not guess alternate exported function names.
6. Publish CPU work only after completion
LatestOnlyWorker executes a real thread, holds one running job and one replaceable pending job, captures errors in Publication.error, and rejects stale epoch publications after invalidate().
from yeorinx4.runtime import LatestOnlyWorker
with LatestOnlyWorker(prepare_certificate) as worker:
worker.submit(source_id, immutable_observation)
publication = worker.snapshot()
if publication is not None and publication.error is None:
completed_model = publication.value
model_completion_s = publication.completed_s
prepare_certificate and immutable_observation are adapter responsibilities. submit does not copy mutable values; copy/retain a source buffer before the producer reuses it. Invalidate the worker epoch after a source-profile change and reject publications inconsistent with the current host profile. wait_idle() is useful for tests and teardown; do not make presentation wait for an observer just because the method exists.
MeasuredBudget estimates a rolling high quantile plus margin only after warmup. Treat estimate is None as no usable budget. Quantiles are empirical, not a worst-case execution guarantee. Record overruns and invalidate admission assumptions after a material timing change.
CandidateGate.publish(frame, generation, epoch) and commit(...) check source identity, monotonically increasing output identity, publication/expiry, deadline and reported GPU readiness. Its success status is literally content_eligible_not_latency_certified. The same source can serve multiple distinct output opportunities; a repeated output identity cannot commit twice.
7. Realize the admitted field correctly
ActionLibrary.field(choice) returns the scaled reference field. For a GLSL realization, fieldKind=0 selects the inherited cone, requestedShift is the unscaled shift, and alpha applies the admitted scalar once. Double scaling the CPU shift and the shader alpha changes the realized intervention and invalidates its bound.
The supplied GLSL maps an output pixel p to source coordinate p + alpha * displacement(p). Use the immutable original image for every output. Feeding the previously corrected output back into the next warp compounds transformations and is outside the contract.
The shader has one protectedRect; Python geometry can accept a list of rectangles. A host with several protected regions must implement the minimum distance to all pinned regions and verify it against the reference, rather than silently using only the first rectangle. Match coordinate origin, pixel centers, rectangle inclusion, focal length, filtering, texture format and color handling. Keep negative/out-of-range invalid templates rejected upstream.
The continuous no-fold/no-hole result assumes the declared field and rho < 1. Finite precision, texture filtering and discrete output require realization testing. Boundary preservation supplies source-domain validity at the cost of non-rigid deformation, not a complete freshly rendered view. The current raster evidence is Mesa software rendering; the HLSL port and NVIDIA hardware performance remain unverified.
8. Implement a host as a new experiment
Before admitting a correction, a host must establish these records:
- Original source texture ownership, immutability and receipt time.
- Profile/resource generation and calibration epoch.
- Actual native alternative and its freshness bound at the output opportunity.
- Completed model/certificate publication and expiry on a common clock.
- Realized field parameters, implementation error and supported camera mode.
- Queue ownership, synchronization, deadline budget, readiness and final content eligibility.
- The untouched-native, identity and corrected presentation results under matched conditions.
These are implementation requirements, not supplied DXGI/game integration. Content eligibility and scheduling interference are separate: GPU work already submitted can delay native work even if its corrected output is later rejected.
For the source-owned Windows experiment, read WINDOWS_PILOT.md and build using windows\BUILD_AND_RUN.cmd from an x64 Native Tools command prompt. Its initial mode is uncorrected source copy. F1–F4 select source/identity/conditional/naive modes, F8 captures foreground mouse movement, and Escape releases capture before exiting. This source has not been compiled or run in the supplied Linux evidence.
Successful Windows compilation is a new platform result, not proof of a native-preserving game path. Attach the build log and target environment to a new run and label its CSV as software timestamps. Optical input-to-photon validation follows PHYSICAL_BENCHMARK_PROTOCOL.md.
9. Extension acceptance checklist
For a change to observer, geometry, certificate or host, preserve the archived evidence and add a separately named run. Record the exact code revision, environment, profile, scenario/seed, input availability, measured and modeled costs, rejected decisions and unsupported cases. Include an adversarial case matched to the change: geometry invalidation for FOV handling, source replacement for queue work, identity/freshness mismatch for host work, or independent-scene motion for tracking changes.
Passing a new component test does not merge separate tracks into a validated system. A practical claim requires the integrated path to preserve a competitive native baseline and to produce matched-quality physical measurements. The release's AI guidance and machine-readable claims should remain aligned with those facts.