Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
9957171
Dispatch volume TV loss to quantem-cuda kernels when available
cedriclim1 Jun 10, 2026
5a8666e
Dispatch tilted K-Planes interpolation to quantem-cuda when available
cedriclim1 Jun 10, 2026
4d4f325
Build INR training batches on the compute device for single-process runs
cedriclim1 Jun 10, 2026
9e7e505
Shard DeviceBatchSampler across DDP ranks
cedriclim1 Jun 10, 2026
5da8a7e
Fix INR dataset indexing for non-square tilt images and TV soft-const…
cedriclim1 Jun 10, 2026
7765dc3
Batch volume TV finite-difference taps into a single model call
cedriclim1 Jun 10, 2026
48b4213
Speed up KPlanesTILTED feature interpolation and volume TV loss
cedriclim1 Jun 10, 2026
d1f6360
Fold volume-TV tap evaluation into the main forward pass
cedriclim1 Jun 10, 2026
a16ea38
Fix ObjectINR out-of-volume masking along z and soft-constraint devic…
cedriclim1 Jun 10, 2026
0eb870f
Reduce INR dataloader and ray-transform overhead
cedriclim1 Jun 10, 2026
0152992
Fix no-op SIRT inline alignment and multi-angle rotation operators
cedriclim1 Jun 10, 2026
6a88afb
Make scheduler params() pure and fix gradient-detaching angle wrappin…
cedriclim1 Jun 10, 2026
9fbe4e3
Fix ignored winner-initialization seed in Siren and remove dead learn…
cedriclim1 Jun 10, 2026
329e300
Fix pose parameters being reset by to() and refuse anisotropic KPlane…
cedriclim1 Jun 10, 2026
4e13b1e
Merge pull request #1 from cedriclim1/fix/tomography-dataset-indexing…
cedriclim1 Jun 10, 2026
cfdc0b2
Merge pull request #2 from cedriclim1/perf/kplanes-tilted-inr-hotpaths
cedriclim1 Jun 10, 2026
949acd3
Merge pull request #3 from cedriclim1/feat/single-pass-volume-tv
cedriclim1 Jun 10, 2026
229efd9
Merge pull request #4 from cedriclim1/fix/objectinr-zmask-softloss-de…
cedriclim1 Jun 10, 2026
0c2ddea
Merge pull request #5 from cedriclim1/perf/inr-dataloader-raymath
cedriclim1 Jun 10, 2026
a6014dd
Merge pull request #6 from cedriclim1/fix/sirt-inline-alignment-rot-ops
cedriclim1 Jun 10, 2026
fc119e6
Merge branch 'feat/tomography-inr-fixes' into fix/scheduler-params-pu…
cedriclim1 Jun 10, 2026
102ce94
Merge pull request #7 from cedriclim1/fix/scheduler-params-purity-rot…
cedriclim1 Jun 10, 2026
ec4cfd5
Merge pull request #8 from cedriclim1/fix/winner-init-seed-dead-setter
cedriclim1 Jun 10, 2026
340a954
Track quantem-cuda's per-module layout in the dispatch imports
cedriclim1 Jun 10, 2026
d852989
Add notebook documenting direct quantem-cuda kernel usage
cedriclim1 Jun 10, 2026
20b9377
Merge branch 'feat/tomography-inr-fixes' into fix/pose-reset-on-to-kp…
cedriclim1 Jun 10, 2026
442783b
Merge pull request #9 from cedriclim1/fix/pose-reset-on-to-kplanes-aniso
cedriclim1 Jun 10, 2026
a5273d2
Merge pull request #10 from cedriclim1/feat/gpu-batch-sampler
cedriclim1 Jun 10, 2026
b56ede8
Dispatch the ptychography TV constraint to the fused quantem-cuda L1 …
cedriclim1 Jun 10, 2026
0e5bfae
Update kernel-usage notebook for L1 TV; add reconstruction-level qual…
cedriclim1 Jun 10, 2026
db483da
Keep notebooks out of the repo; attach them to the PR instead
cedriclim1 Jun 11, 2026
be7188e
Fix sampler parity test to match int-returning __getitem__
cedriclim1 Jun 11, 2026
62e871e
Guard tilt-stack normalization against sparse data
cedriclim1 Jun 11, 2026
6496aa6
Fix TV gate so plane-only TV is applied for tensor-decomp models
cedriclim1 Jun 11, 2026
6ed9fdc
Hoist loop-invariant sampling grid in CP-TILTED interpolation and dro…
cedriclim1 Jun 10, 2026
f8d9fb9
Merge pull request #11 from cedriclim1/perf/cp-ms-grid-hoist
cedriclim1 Jun 11, 2026
2640ba6
Vectorize INR dataset batch fetching and stack epoch loss reductions
cedriclim1 Jun 10, 2026
e42fc96
Enable fused Adam/AdamW on CUDA and drop redundant epoch metrics redu…
cedriclim1 Jun 10, 2026
d845451
Merge pull request #12 from cedriclim1/perf/inr-batch-vectorize
cedriclim1 Jun 11, 2026
8b77d4a
Revert "Merge pull request #12 from cedriclim1/perf/inr-batch-vectorize"
cedriclim1 Jun 11, 2026
a582f9e
Revert "Merge pull request #11 from cedriclim1/perf/cp-ms-grid-hoist"
cedriclim1 Jun 11, 2026
7d31076
Hoist loop-invariant sampling grid in CP-TILTED interpolation and dro…
cedriclim1 Jun 10, 2026
4fea74a
Vectorize INR dataset batch fetching and stack epoch loss reductions
cedriclim1 Jun 10, 2026
110c7da
Enable fused Adam/AdamW on CUDA and drop redundant epoch metrics redu…
cedriclim1 Jun 10, 2026
c05ed98
Give KPlanes a linear head when use_hybrid_mlp is off
cedriclim1 Jun 11, 2026
d6b30d4
Re-join optimizer hyperparameters to param groups by key on reconnect
cedriclim1 Jun 11, 2026
8919af7
Add opt-in torch.compile path for ObjectINR forwards
cedriclim1 Jun 11, 2026
8fac79d
Fix DDP device placement and wrapper unwrapping in tomography
cedriclim1 Jun 24, 2026
d187d1d
Add S3IM stochastic structural-similarity loss to tomography INR reco…
cedriclim1 Jun 26, 2026
32696af
Add box_fixed_ds ray sampler + coarse-to-fine + anisotropic-TV to tom…
cedriclim1 Jun 28, 2026
80bfa94
Commit WIP TomographyINRDataset.from_data + fix missing _token guard arg
cedriclim1 Jul 2, 2026
415cc19
Add mode='tensorboard'|'wandb' dual backend to LoggerBase/LoggerTomog…
cedriclim1 Jul 2, 2026
5523e41
Add grad-update snapshot hooks to Tomography.reconstruct
cedriclim1 Jul 2, 2026
9634f97
Add CV pixel-holdout validation loss to the tomography training loop
cedriclim1 Jul 2, 2026
6fe6c12
Fix holdout validation: restore model/dset train-eval modes after val…
cedriclim1 Jul 2, 2026
b70b4c0
Fix wandb dropped datapoints: per-tag step domains instead of global …
cedriclim1 Jul 2, 2026
535babd
Include grad_step alongside epoch in every wandb scalar/image payload
cedriclim1 Jul 2, 2026
60b0c1e
fix(tomography): validate tilt stack by angle count, not dimension or…
cedriclim1 Jul 2, 2026
fcb8a2a
profiling: NVTX ranges in INR reconstruct loop (epoch/batch/get_coord…
cedriclim1 Jul 8, 2026
68173f6
Merge remote-tracking branch 'cedriclim1/feat/quantem-cuda-extra' int…
cedriclim1 Jul 9, 2026
d378f70
Fix forward_with_tv_taps to keep the 3-axis out-of-volume mask (a16ea38)
cedriclim1 Jul 9, 2026
12d7828
Fix integrate_rays unit test for the instance-method dispatch signature
cedriclim1 Jul 9, 2026
b74fe46
Merge remote-tracking branch 'cedriclim1/perf/cp-ms-grid-hoist-v2' in…
cedriclim1 Jul 9, 2026
a6159c2
Merge remote-tracking branch 'cedriclim1/fix/kplanes-getparams-no-mlp…
cedriclim1 Jul 9, 2026
e661f56
Merge remote-tracking branch 'cedriclim1/fix/optimizer-reconnect-by-n…
cedriclim1 Jul 9, 2026
3e82b26
Partially merge perf/inr-batch-vectorize-v2: fused Adam + stacked epo…
cedriclim1 Jul 9, 2026
20f767b
Merge remote-tracking branch 'cedriclim1/perf/objectinr-compile-opt-i…
cedriclim1 Jul 9, 2026
cf9436f
Consolidate: merge perf/nvtx-profiling into the benchmark lineage
cedriclim1 Jul 12, 2026
46ef632
profiling: env-guarded bounded nsys capture window (QUANTEM_NSYS_CAPT…
cedriclim1 Jul 13, 2026
416943e
bench: conference snapshot 2026-07-22 — full working state (pose/logg…
cedriclim1 Jul 22, 2026
6d102cd
Add per-row/per-column tilt-angle support to TomographyINRDataset
cedriclim1 Jul 22, 2026
05aefdb
Expose autocast precision knob on Tomography.reconstruct
cedriclim1 Jul 22, 2026
934402e
Thread compile_model through ObjectTensorDecomp constructor and from_…
cedriclim1 Jul 22, 2026
5959ecf
Keep SO(3) rotation-matrix construction in fp32 under autocast
cedriclim1 Jul 22, 2026
3c8052f
Store KPlanes grid parameters in channels-last memory format
cedriclim1 Jul 22, 2026
62863d7
Decouple gradient scaling from fp16 autocast
cedriclim1 Jul 22, 2026
76458bd
Dispatch KPlanesTILTED multiscale interpolation to the fused three-le…
cedriclim1 Jul 22, 2026
16185a5
Add opt-in CUDA graph capture to Tomography.reconstruct
cedriclim1 Jul 22, 2026
e61206f
Remove broken KPlanes.grids property that failed under dynamo tracing
cedriclim1 Jul 22, 2026
8dd3b30
Guard nvtx profiling ranges for CPU-only torch builds
cedriclim1 Jul 22, 2026
eee2ece
Dispatch plane-TV loss to the fused CUDA op when available
cedriclim1 Jul 22, 2026
b5dd28b
Assert bf16 feature boundary through KPlanesTILTED dispatch
cedriclim1 Jul 22, 2026
f8c3751
Merge branch 'perf/r2-planetv-py' into perf/r2-integration-py
cedriclim1 Jul 22, 2026
9fb75a6
Consume the combined plane-TV scalar and gate positivity on activatio…
cedriclim1 Jul 23, 2026
f8d1eac
Dispatch the hybrid sigma head to the fused cuBLASLt MLP when eligible
cedriclim1 Jul 23, 2026
9f1199b
Add gradient-clip skip, reconstruction-scoped fused plane-TV, and pre…
cedriclim1 Jul 23, 2026
7dce659
Merge branch 'perf/r4-mlp-py' into perf/r4-integration-py
cedriclim1 Jul 23, 2026
cfe9fb6
Merge branch 'perf/r4-stream-py' into perf/r4-integration-py
cedriclim1 Jul 23, 2026
9c37d3d
Round-4 hardening: fused-MLP default-on, TV cleanup on exceptions, pr…
cedriclim1 Jul 23, 2026
999196e
Use a step-count-dependent tolerance in the pred-fork equivalence test
cedriclim1 Jul 23, 2026
9f17c5e
Restrict pred-fork equivalence to the reproducible horizon
cedriclim1 Jul 23, 2026
10dc9b4
Accept torch dtypes for reconstruct's autocast_dtype
cedriclim1 Jul 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/quantem/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@
if "cuda" in str(e):
NUM_DEVICES = 0
_defaults["has_cupy"] = False
try:
import quantem.cuda # type: ignore # noqa: F401

_defaults["has_quantem_cuda"] = True
except ModuleNotFoundError:
_defaults["has_quantem_cuda"] = False
except Exception:
# installed but unloadable (e.g. libcudart missing at runtime)
_defaults["has_quantem_cuda"] = False


defaults: list[Mapping] = [_defaults]
Expand Down
58 changes: 57 additions & 1 deletion src/quantem/core/ml/activation_functions.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,66 @@
from typing import Callable
import os
from typing import Any, Callable

import torch
import torch.nn as nn
import torch.nn.functional as F


class _TruncExpReference(torch.autograd.Function):
"""Exponential with the torch-ngp clamped backward used by tomography."""

@staticmethod
def forward(ctx: Any, values: torch.Tensor, offset: float) -> torch.Tensor:
ctx.save_for_backward(values)
ctx.offset = offset
return torch.exp(values - offset)

@staticmethod
def backward(ctx: Any, grad_output: torch.Tensor) -> tuple[torch.Tensor, None]:
(values,) = ctx.saved_tensors
shifted = values - ctx.offset
return grad_output * torch.exp(shifted.clamp(max=15)), None


def trunc_exp(values: torch.Tensor, offset: float = 0.0) -> torch.Tensor:
"""Apply trunc-exp, using the fused CUDA density tail when available."""
use_fused = (
os.environ.get("QUANTEM_DENSITY_TAIL_FUSED", "1") != "0"
and values.is_cuda
and values.dtype in (torch.float32, torch.bfloat16)
and values.ndim in (1, 2)
and values.numel() > 0
)
if use_fused:
try:
import quantem.cuda.core.ml as cuda_ml
except (ImportError, OSError, RuntimeError):
pass
else:
fused = getattr(cuda_ml, "density_tail", None)
if fused is not None:
return fused(values, float(offset))
return _TruncExpReference.apply(values, float(offset))


# Object constraints consume this explicit capability instead of guessing from
# a callable name or implementation detail.
trunc_exp.quantem_guarantees_nonnegative = True # type: ignore[attr-defined]


class TruncExpActivation(nn.Module):
"""Configurable trunc-exp activation with a non-negativity capability."""

quantem_guarantees_nonnegative = True

def __init__(self, offset: float = 0.0) -> None:
super().__init__()
self.offset = float(offset)

def forward(self, values: torch.Tensor) -> torch.Tensor:
return trunc_exp(values, self.offset)


class ModReLU(nn.Module):
"""Modulated ReLU activation for complex-valued inputs.

Expand Down
24 changes: 13 additions & 11 deletions src/quantem/core/ml/inr.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,20 @@ def _build(self) -> None:
self.net = nn.Sequential(*net_list)

if self.winner_initialization:
if type(self.winner_initialization) is int:
rng = torch.Generator()
rng.manual_seed(self.winner_initialization)
else:
rng = torch.Generator()
rng.manual_seed(42)
seed = self.winner_initialization if type(self.winner_initialization) is int else 42
rng = torch.Generator()
rng.manual_seed(seed)
# torch.randn_like ignores generators, so the noise must come from
# torch.randn with the seeded generator -- otherwise the "winner" seed
# silently has no effect and the perturbation is not reproducible.
with torch.no_grad():
self.net[0].linear.weight += ( # type: ignore[reportAttributeAccessIssue]
torch.randn_like(self.net[0].linear.weight) * 5 / self.first_omega_0 # type:ignore
)
self.net[1].linear.weight += ( # type: ignore[reportAttributeAccessIssue]
torch.randn_like(self.net[1].linear.weight) * 0.1 / self.hidden_omega_0 # type:ignore
w0 = self.net[0].linear.weight # type: ignore[reportAttributeAccessIssue]
w0 += torch.randn(w0.shape, generator=rng, dtype=w0.dtype) * 5 / self.first_omega_0
w1 = self.net[1].linear.weight # type: ignore[reportAttributeAccessIssue]
w1 += (
torch.randn(w1.shape, generator=rng, dtype=w1.dtype)
* 0.1
/ self.hidden_omega_0
)

def forward(self, coords: torch.Tensor) -> torch.Tensor:
Expand Down
Loading