Fix type annotations, dead code, VAE objective, and device consistency bugs from PR review#55
Merged
Merged
Conversation
…ice, encoder return value Co-authored-by: kellrott <113868+kellrott@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Collect changes for next release v0.3
Fix type annotations, dead code, VAE objective, and device consistency bugs from PR review
Mar 10, 2026
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Seven correctness and API hygiene issues identified in code review on PR #48, spanning type annotations, unreachable guards, a VAE objective bug, and device consistency gaps.
Changes
embkit/modules/__init__.pyLayerInforeference from module docstring; the type now lives atembkit.factory.layers.Layerembkit/factory/mapping.pyget_activation()return type:Optional[nn.Module]→Optional[Type[nn.Module]]— the function returns a class, callers instantiate it viaget_activation("relu")()embkit/models/vae/encoder.pyif self.latent_dim is None:branches —latent_dimis a requiredint, these could never fire(mu, logvar, h)wherehis the pre-head hidden state, meaning the decoder operated on a different tensor than the KL term. Fixed to return(mu, logvar, mu)so the deterministic latent is consistent end-to-endembkit/models/vae/base_vae.pyBaseVAE.to()was calling.to()directly onencoder/decoder(crashing when either isNone, skipping all other submodules, and not returningself). Replaced withreturn super().to(device=device, dtype=dtype)— PyTorch's submodule traversal handles everything correctlyembkit/factory/layers.pyLayer.gen_layer()now passesdevice/dtypetonn.BatchNorm1d, preventing mixed-device modules when a caller specifies a non-CPU device at build timeembkit/preprocessing/normalize.pyget_dataset_nonzero_mask()return type corrected fromtorch.TensortoList[torch.Tensor]torch.zeros(len(f))(always CPU, float32) totorch.zeros(f.shape, dtype=torch.int32, device=f.device)to match the input tensor's device✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.