Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

engram

Personal research utilities for differentiable rendering (Mitsuba 3 / Dr.Jit), NN training and vision science. Engram in this context is more a "memory trace" that I upload here. It will be updated as I go, and may not be fully functional at any given time. The goal however is to provide a stable package at post-alpha time with a clean API making it easier for vision/neuro researchers to use Mitsuba 3 and Dr.Jit in their experiments.

Moves with the experiments I am running. The API is still unstable. Consider this pre-alpha.

uv add engram            # core: numpy, torch, matplotlib, mitsuba, drjit, mitsuba-scene-description
uv add "engram[all]"     # + scipy, wandb/pandas, flip-evaluator, moviepy, gpytoolbox, transformers/accelerate

Python >= 3.12. import engram is side-effect free: no Mitsuba variant is selected, nothing heavy is imported until you touch the module that needs it.

Module tour

Module What's inside
engram.color Correct piecewise sRGB encode/decode (linear_to_srgb, srgb_to_linear), reinhard/hable_filmic tonemaps, linear_to_srgb_ldr display transform. Backend-generic: numpy, torch, and Dr.Jit tensors.
engram.io save_image/load_image (one writer for numpy/torch/Mitsuba images), ensure_dir, renumber_frames + frames_to_video (ffmpeg).
engram.imagenet Offline ImageNet-1k idx2label/label2idx and ImageNet/CLIP normalization constants.
engram.losses smooth_minimum, the controversiality score family (Golan et al. 2020: classification, regression, undirected, confidence-weighted, hard), diagonal-Gaussian W2/symmetric-KL distances. Pure torch.
engram.metrics Torch-native pearsonr/spearmanr (tie-aware)/r2_score/cohens_d, RDM + RSA helpers, FLIP wrapper, colormapped pixel_error_map.
engram.stats JZS Bayes factors (directional + rank-based) and vectorized permutation tests for paired condition scores.
engram.plot Loss curves, image grids, side-by-side comparisons, RDM/RSA figures, sampled and analytic (GGX) polar BSDF-lobe plots.
engram.track StepLogger (per-run CSV + PNG persistence, wandb-free), lazy init_wandb_run, wandb_image_grid, flatten_params/flatten_history for readable log keys.
engram.mi set_variant() (explicit, env-var aware, autodetecting), Variant enum, wrap_torch/wrap_drjit autodiff bridges, Fibonacci-lattice cameras + sensor builders, envmap emitter, pixel/param/dual-buffer losses in correct sRGB, Large Steps registration, SigmoidReparam box constraints, spp-batched gradient accumulation, forward-gradient visualization, SceneDescription.
engram.train seed_everything + deterministic render_seed pairs, EarlyStopping (snapshots torch and Dr.Jit optimizer state) + PixelChangeCriterion, torch helpers (device probe, FSDP-aware checkpointing, DDP mean-reduce), and the training framework below.

Training framework

engram.train ships an HF-Trainer-shaped framework that covers inverse rendering and NN training with one interface: OptimizationConfig mirrors TrainingArguments (output dir, evaluation/save strategies, gradient accumulation, logging frequency), and Optimization subclasses implement the step/loop methods. With use_accelerator=True the run goes through Hugging Face accelerate (device placement, DDP, mixed precision — engram[hf]).

import mitsuba as mi
from engram.mi import set_variant

set_variant()  # cuda_ad_rgb -> llvm_ad_rgb -> scalar_rgb, or $ENGRAM_MI_VARIANT

from engram.mi.scene import SceneDescription
from engram.train import DROptimization, OptimizationConfig
from engram.train.render import RenderPipeline
from engram.train.optimization import GroundTruth

scene = SceneDescription.from_dict(mi.cornell_box())      # dicts or msd.Plugin objects
target_render = scene.render()
scene["red.reflectance.value"] = mi.Color3f(0.5, 0.5, 0.5)

optim = DROptimization(
    config=OptimizationConfig(output_dir="albedo-recovery", epochs=15, learning_rate=0.05),
    pipeline=RenderPipeline(spp=16),
    scene=scene,
)

report = optim.fit(GroundTruth(image=target_render))
report.plot_losses()

Scene dictionaries can be authored with mitsuba-scene-description (typed dataclasses per Mitsuba plugin); SceneDescription.from_dict accepts anything exposing to_dict().

Install groups (just pick what you need)

Extra Enables Pulls in
stats engram.stats, exotic RDM metrics scipy
track StepLogger CSV output, wandb helpers pandas, wandb
flip engram.metrics.flip_error flip-evaluator
video moviepy fallback for video assembly moviepy
geometry remeshing workflows gpytoolbox
hf use_accelerator=True runs transformers, accelerate
all everything above

Development

uv sync --group dev
uv run pytest          # mitsuba tests use llvm_ad_rgb/scalar_rgb and skip when unavailable
uv run ruff check src tests

# package up for PyPI
uv build

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

engram-0.1.0a1.tar.gz (148.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

engram-0.1.0a1-py3-none-any.whl (68.7 kB view details)

Uploaded Python 3

File details

Details for the file engram-0.1.0a1.tar.gz.

File metadata

  • Download URL: engram-0.1.0a1.tar.gz
  • Upload date:
  • Size: 148.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for engram-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 fd613a71211e35f3462648125a0dd22f2326342f26b9f87c8ab490390a3ec26a
MD5 7c57770028e4eef101cbb7e9307dcb10
BLAKE2b-256 724c86154f2053385ec5944fd6ba338f76ac9fad139599f1a235d0ff1c3a87e4

See more details on using hashes here.

File details

Details for the file engram-0.1.0a1-py3-none-any.whl.

File metadata

  • Download URL: engram-0.1.0a1-py3-none-any.whl
  • Upload date:
  • Size: 68.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for engram-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 85600b0b78afbe1b2f7aaeae74b1ac053de575bddd5b98f7edaad8660c22993c
MD5 9e406fa58a0bca14285a206e92e394be
BLAKE2b-256 6a9b56b02eff4abf2d43c45665b1db65f485e11dc1f9e7c21ec96660258c5cc2

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0a1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page