torchsky.map.field.native_integrated_read¶
Experimental surface
These APIs are under active development. Names, defaults, and result objects may change between minor releases; pin a version if you depend on them in production.
Opt-in single-integrated-read native photon/dark/read likelihoods.
Guides: likelihoods
This reference is generated from the package source. Names are grouped by
the module that defines them; import every name from the public
namespace torchsky.map.field.native_integrated_read unless the group text says otherwise.
Top-level namespace¶
Opt-in single-integrated-read native photon/dark/read likelihoods.
NativeIntegratedReadLikelihood
dataclass
¶
NativeIntegratedReadLikelihood(
*,
observation: FieldObservation,
photon_response: NativeFieldResponse,
output_calibration: PixelCalibrationOp,
exposure_time_s: Tensor,
electrons_per_photon: Tensor,
read_variance_electrons2: Tensor,
measurement_ids: tuple[str, ...],
calibration_id: str,
provenance_id: str,
additive_components: tuple[AdditiveComponent, ...] = (),
dependencies: EvidenceSnapshot | None = None,
revision: Callable[[], object] | None = None,
tail_sigma: float = 12.0,
max_terms: int = 4096,
)
Conditional normalized finite-mixture law for one integrated read.
Bind with bind_native_integrated_read_likelihood. This route reuses an empty-
additive FieldObservation with RAW_READS processing and the explicit
single_integrated_read value semantics. Here that processing label means
one continuous output per native pixel, not a nondestructive ramp, event
stream, nonlinear/history response, resampled image or arbitrary pipeline
residual. Fixed diagonal conversion and deterministic output offsets are
declared explicitly, with their density Jacobian supplied by evaluating in
observed units. CALIBRATED_OUTPUT components are allowed only in this
route-local raw-read scope; legacy additive validators remain unchanged.
The native photon response maps source spectral values to photon/s in
already integrated detector pixels. Its calibration input/output and
quadrature output must be photon/s, with the declared physical convention
photon_routing_qe_excluded. This is a caller contract for independent
Poisson routing/thinning, including the fixed scale; labels cannot prove
positivity/substochasticity of a callback or calibrate a sky-flat into a
physical photon response. Remaining QE is an explicit [0,1] probability,
with one electron at most per detected photon. Photon/charge/read mixing
maps are not inferred from moments. Exposure rates are constant over the
explicitly supplied positive duration; this does not integrate time history.
External typed components use RAW_READS processing. PHOTON_ILLUMINATION is [N,L] nonnegative sampled-sky spectral density, in source_value_unit with value_semantics='density_per_angstrom' and photon_shot. DARK_CHARGE is [H,W] nonnegative detector electron/s, semantics='electron_rate' and charge_shot. READ_OFFSET is [H,W] signed detector electrons, semantics='electron_offset' and deterministic_mean. CALIBRATED_OUTPUT is [H,W] signed detector output units, semantics='single_integrated_read' and deterministic_mean. Physical components are passed separately; they are not stored on FieldObservation.
Independent dark rate is added after optics, before readout. Signed read and output offsets change conditional means, never erase photon/dark shot noise. Read variance is electron^2, strictly positive on kept support. Zero read variance is a discrete law rather than this continuous density. Output calibration maps electron to observed units with no inferred gain/area/QE.
sum is the normalized independent-pixel finite-mixture NLL; mean
is a reporting objective. The law, detached support and conservative first/
second derivative-domain limits are exactly those of poisson_gaussian_nll.
It is not the full untruncated physical law, a Gaussian b/H/c compression,
nuisance marginalization, Fisher matrix or sampling-covariance guarantee.
All rates/offsets/calibration are conditional fixed evidence. Original
tensors, metadata and response/calibration are guarded before/after calls;
inference tensors and alias/hidden state require explicit caller revisions.
Rebind after evidence changes and for a new fixed-evidence autograd graph.
By default NLL evaluates all P kept rows together, with O(P*K) mixture
intermediates where K can reach max_terms. Opt-in mixture_chunk_size bounds
each mixture call and checkpoints its reverse-AD intermediates. Source and
detector response graphs remain resident: this is not total bounded-memory
survey training. Checkpointed callbacks must be deterministic and evidence
unchanged through backward; the standard per-call evidence guards apply.
_snapshot
class-attribute
instance-attribute
¶
_snapshot: EvidenceSnapshot = field(
init=False, repr=False, compare=False
)
_support
class-attribute
instance-attribute
¶
_support: Tensor = field(
init=False, repr=False, compare=False
)
additive_components
class-attribute
instance-attribute
¶
additive_components: tuple[AdditiveComponent, ...] = ()
expected_output ¶
expected_output(values: Tensor) -> Tensor
Full physical conditional mean; masked output rows are zero.
This is the untruncated detector expectation, not the expectation of the helper's finite retained mixture, and it supplies no noise precision.
nll ¶
nll(
values: Tensor,
*,
reduction: Literal["sum", "mean", "none"] = "sum",
mixture_chunk_size: int | None = None,
) -> Tensor
Evaluate the normalized kept-pixel law, optionally in pixel chunks.
none returns a masked-zero image. With mixture_chunk_size=C, each
call has at most C kept rows. Non-reentrant checkpointing recomputes
mixture intermediates in ordinary reverse AD, including double backward:
O(C*K) first-backward workspace plus O(P) saved law inputs/results.
Higher-order derivative graphs can retain recomputed intermediates.
Field sampling and response graphs remain resident. No host transfer,
change in finite support, detached score or parameter-gradient omission
is introduced. Floating-point batching can change roundoff.
The default is unchanged. Forward AD evaluates chunks directly, without checkpointing; simultaneous forward/reverse AD therefore retains its mixture graph. Evidence must remain fixed through recomputation, not only through forward evaluation.
nll_field ¶
nll_field(
model: Module,
*,
forward_context: ForwardContext | None = None,
source_chunk_size: int = 4096,
reduction: Literal["sum", "mean", "none"] = "sum",
mixture_chunk_size: int | None = None,
) -> Tensor
Actual monochromatic field client on source nodes, then native NLL.
validate_evidence ¶
validate_evidence() -> None
Reject changes to original data/support/physics and parent calibration.
bind_native_integrated_read_likelihood ¶
bind_native_integrated_read_likelihood(
observation: FieldObservation,
photon_response: NativeFieldResponse,
output_calibration: PixelCalibrationOp,
*,
exposure_time_s: Tensor,
electrons_per_photon: Tensor,
read_variance_electrons2: Tensor,
measurement_ids: tuple[str, ...],
calibration_id: str,
provenance_id: str,
additive_components: tuple[AdditiveComponent, ...] = (),
dependencies: EvidenceSnapshot | None = None,
revision: Callable[[], object] | None = None,
charge_response: LinearDetectorResponse | None = None,
read_noise_response: LinearDetectorResponse
| None = None,
tail_sigma: float = 12.0,
max_terms: int = 4096,
) -> NativeIntegratedReadLikelihood
Bind explicit independent physical collection/read law without a field.
No legacy weight/noise/additive pipeline is used. Source-independent area/ throughput conversion must already be declared inside photon_response; observation area metadata is provenance only. Exposure/gain metadata on the observation rejects, preventing a second ambiguous conversion. Duration is scalar; QE/read variance are scalar or explicit row-major [P], preserving dtype/device without coercion. General charge/read maps are rejected even when a caller claims identity: one test cannot establish independence.