---
title: "Rule 11.23: Targets and the oracle, a TypeShade design rule"
description: "Rule 11.23 of the TypeShade language design, in Targets and the oracle. A compiled program may carry more than one WGSL text of a compute entry (a variant)."
url: https://typeshade.dev/reference/rules/11-23/
language: en
---

# Rule 11.23

Chapter 11, Targets and the oracle Test

A compiled program may carry more than one WGSL text of a compute entry (a variant). Every variant of an entry must write the same bits for every input, except where a rule records a divergence between them. The runtime must select a variant when it opens a device, from the device’s features and from a known-answer probe that runs the variant’s shape once on the device and compares what it wrote with the known answer; a variant whose probe fails, or whose feature the device lacks, must not be selected, and the device’s report must say what the probe saw and which text each kernel call ran. A feature a variant alone needs must not be in the module’s `requiredFeatures` ([Rule 10.2](https://typeshade.dev/reference/rules/10-2/)); the runtime requests it where the adapter has it. The subgroup variant of a kernel function’s loop ([Rule 8.22](https://typeshade.dev/reference/rules/8-22/)) is one: it needs `subgroups`, `createDevice({ subgroups: 'off' })` keeps it off, `DeviceInfo.subgroups` is the probe’s observation and `DeviceStatistics.variants` the text each call ran.

The rule text and the parts under it are the compiler's own English, as the design document writes them.

## Rationale

`docs/compiler-owns-performance.md` (sections 1 and 6): a program must become faster when the compiler improves with no change to its source, and a device difference belongs to the compiler and the runtime, so a faster form a device may lack is a text the runtime picks, as the emulated double’s flavor is picked (changes 0073 and 0085), and a probe selects it on a device with unknown signals and refuses it on one whose driver folds wrongly. A WGSL module that spells `enable subgroups;` does not compile on a device without the feature, so a branch inside one text cannot choose. The bits are held equal so that selection is invisible to the author; a divergence a rule records (an `f32` sum, [Rule 7.2](https://typeshade.dev/reference/rules/7-2/)) is kept out of every variant until the rule changes.

## Derives from

`changes/0119-subgroup-reduction-variant.md` (sections 2 to 5, decisions O1, O3 and O4); `docs/compiler-owns-performance.md`; changes 0073 and 0085 (the flavor axis); [#536](https://github.com/typeshade/typeshade/issues/536).

## How it is verified

Checked by a test. A test, a gate script or a CI workflow names this rule, and the traceability check fails when a file listed below stops naming it.

Where the rule says the compiler enforces it:

`src/core/subgroup-probe.ts` (the probe’s text, its known answers and `probeSubgroups`), pinned by `src/core/subgroup-probe.test.ts`; `createDevice` and `DeviceImpl` in `src/runtime/device.ts` and `gpuDevice` in `src/core/host-entry.ts` (the probe at open, the option, the observation and the statistics), pinned by `src/runtime/device.test.ts` (a device that passes, fails, lacks the feature or keeps it off, and the default owner); `textOf` in `src/core/host-kernel.ts` (the dispatch’s choice); `journeys/subgroup-folds/` (equal bits on a device that selects the variant).

The files that verify it at commit af54ddad5, each at the first line that names the rule:

- [`src/core/host-entry.ts:388`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/host-entry.ts#L388)
- [`src/core/host-kernel.ts:477`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/host-kernel.ts#L477)
- [`src/core/subgroup-probe.test.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/subgroup-probe.test.ts#L1)
- [`src/core/subgroup-probe.ts:1`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/subgroup-probe.ts#L1)
- [`src/runtime/device.test.ts:1529`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/runtime/device.test.ts#L1529)
- [`src/runtime/device.ts:77`](https://github.com/typeshade/typeshade/blob/af54ddad5/src/runtime/device.ts#L77)

## Explained in

The sections of the surface document that explain this rule, at commit af54ddad5:

- [§65 A loop that runs as a kernel](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#65-a-loop-that-runs-as-a-kernel)
- [§69 Running a compiled program](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/use-typeshade-surface.md#69-running-a-compiled-program)

## See also

- [Rule 11.22](https://typeshade.dev/reference/rules/11-22/) Test
- [Rule 11.27](https://typeshade.dev/reference/rules/11-27/) Test
- [Rule 7.2](https://typeshade.dev/reference/rules/7-2/)
- [Rule 8.22](https://typeshade.dev/reference/rules/8-22/)
- [Rule 10.2](https://typeshade.dev/reference/rules/10-2/)
- [Design rules](https://typeshade.dev/reference/rules/)
- [Error codes](https://typeshade.dev/reference/errors/)

## Source

The rule at commit af54ddad5:

- [`docs/language-design.md:1703`](https://github.com/typeshade/typeshade/blob/af54ddad5/docs/language-design.md#L1703) (the design document)
- [`reqs/rules/RULE-1123.md`](https://github.com/typeshade/typeshade/blob/af54ddad5/reqs/rules/RULE-1123.md) (its traceability item)
