#5699 [Engine] session-identity: the whole STRATA_* environment and the device plan join the config fingerprint (#5379)

open · @nazerim · 0 评论 · 去 GitHub 看

AMD / HIPNVIDIA / CUDADocumentation

说明

## What this improves

**A saved session can silently disagree with the engine that reads it back, and the config fingerprint cannot see either of the two ways it happens.** Reported in #5379.

1. **The fast-path environment.** The kernel layer picks its arithmetic at load time from `STRATA_*` variables — `STRATA_HC_Q8` decides which hyper-connection rows exist on which stage, `STRATA_ROUTE_TAIL_SKIP` which scorer runs, `STRATA_GDN_*` which scan path computes the state. None of them enters the fingerprint. A file saved under one setting restores "valid" under the other, and the cells mean different things. Enumerating known knobs in `switches` cannot work as a fix: they arrive faster than any list — the last two releases alone added `STRATA_HC_Q8_ALL_STAGES` and `STRATA_ARENA_FILE_CACHE` (`STRATA_CKPT_POOL` in October) — and an enum would only catch the trap after someone falls into it.
2. **The device plan.** The fingerprint has no field for *which card runs which stage*. Today a split engine refuses session files, so the reachable case is the single-card plan changing between saves (`--device`, or a boot that orders cards differently — the `name|cc|total MiB` tag differs and the file now refuses). The multi-stage entries are deliberately laid now because the split session-files lane (#4310) is exactly what will start writing per-stage images, and its own docs state the gap ("the device set is outside the file's fingerprint"). Better to bind the device plan before that lane needs it than after it.

## Problem and result

The config fingerprint enumerates the resolved settings and the arithmetic switches it knows about - but two of the engine's actual numeric inputs are not in any list it can keep: the `STRATA_*` environment the kernel layer reads at load time, and which card the engine ends up on. A saved session can therefore disagree silently with the engine that reads it back.

| | before | with this PR |
|---|---|---|
| save, flip a numeric `STRATA_*` (e.g. `STRATA_HC_Q8`), restart | restores "valid" under different arithmetic - the cells mean other things | refused by name (`config fingerprint differs`); the conversation reads again and the next save writes under the new identity |
| a new fast-path variable ships in some release | no list knew it; the trap waits for someone to fall in | in the fingerprint from its first release - the rule is whole-environment, inclusive by default |
| the engine lands on a different card (`--device`, boot order) | invisible to every field | the `name\|cc\|total MiB` tag differs - one refusal, then fresh |
| a report/trace knob is toggled (`*_DUMP`, `*_TRACE`, ...) | invisible | still invisible, deliberately: excluded, pinned by tests - no pointless invalidations |
| files written before the change | - | refused once and re-saved - every engine release already does this, since `engine_version` is in the hash |

## Approach

Two additive fields on `SessionConfig`, hashed like every other field — no format change, no version bump:

- **`env`**: every `STRATA_*` variable in the process environment, sorted by name, minus a documented *runtime-only* exclusion: `STRATA_PARK_*` (variables saying *where* park data lives — a parked image is the same bytes with any of them, per the docs' own note that parked conversations restore identical), `STRATA_MANIFEST` (a diagnostic output path), and the `_DUMP`/`_TRACE`/`_STATS`/`_PROF`/`_PROFILE`/`_LOG` report knobs. A name that *forces tokens* (`STRATA_LOGPOS`) is not a report knob and enters, pinned by a test. Variables the engine itself sets at start (auto-injected defaults) enter too — the identity is the resolved environment, set or inherited. The rule is inclusive by design: an unlisted variable counts in, because **a wrong inclusion costs one re-save and a wrong exclusion costs correctness**.
- **`devices`**: one entry per stage in stage order (`name|compute capability|total MiB`; on today's non-split engine, the primary's card alone), so a plan that changes is a different config. A failed `cudaGetDeviceProperties` falls back to a `device-N` tag and says so in the log — the mismatch direction is a refusal, never a mis-accept.

The engine fills both once, inside the existing `session_identity` builder, so SAVE, RESTORE and everything written under that identity share the check with no new call sites.

**Cost:** files written before this change are refused once and re-saved by the next turn — the same one-time behavior every engine release already causes, since `engine_version` has been in the fingerprint all along. What it buys is exactly the class of cross-release reloads that today pass silently: same engine build, different environment or different card under a stage. No salt or format bump: every mismatch direction is a refusal, the two fields feed the existing config-digest slot, and the header, magic and version are untouched.

**Not in this PR:** the per-stage architecture and the layer→card *table* (the geometry side) — that belongs to the stage-table work in #4310, which validates stage counts and per-stage bounds; this PR makes the device plan itself visible to the identity check. Sampling, seeds, draft tuning and the expert tier stay out, as before.

## Validation

`conversation_file_test` extended inside the existing fingerprint block: an environment variable enters (presence, value, and empty value), the list is deterministic, a reordered device plan differs, and a collector section pins the capture (every `STRATA_*` enters sorted; placement, manifest, foreign names and the report suffixes stay out; `STRATA_LOGPOS` stays *in*). Built and run on this exact branch: **212 checks green** (11 of them new); the full conversation/session family at this tree passes **11/11** on CUDA 13.1 (archs 86 + 120, Release).

本站相关内容

相关页面的快捷入口。