Skip to content

Conversation

@JonasETHZ
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings December 17, 2025 10:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a complete PixelCNN++ implementation for 2D design generation, based on the OpenAI TensorFlow implementation and Lucas Caccia's PyTorch port. The implementation includes training, sampling, and evaluation capabilities for conditional generative modeling of engineering designs.

Key Changes

  • Adds a full PixelCNN++ 2D model implementation with shifted convolutions, gated residual blocks, and discretized mixture of logistics loss
  • Provides an evaluation script for model assessment using wandb artifact management
  • Accidentally modifies cgan_cnn_2d.py to reduce training epochs from 200 to 2 (likely a debugging change)

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 10 comments.

File Description
engiopt/pixel_cnn_pp_2d/pixel_cnn_pp_2d.py Complete PixelCNN++ implementation including model architecture (Nin, GatedResnet, shifted convolution layers), loss functions, sampling logic, and training loop with wandb integration
engiopt/pixel_cnn_pp_2d/evaluate_pixel_cnn_pp_2d.py Evaluation script that loads trained models from wandb artifacts, generates samples with specified conditions, and computes performance metrics
engiopt/pixel_cnn_pp_2d/init.py Empty init file for the new module
engiopt/cgan_cnn_2d/cgan_cnn_2d.py Reduces default training epochs from 200 to 2 (appears to be an unintended debugging change)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

shuffle=True,
)

# Optimzer
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in comment: "Optimzer" should be "Optimizer".

Copilot uses AI. Check for mistakes.

# Algorithm specific
n_epochs: int = 200
n_epochs: int = 2
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The n_epochs default value has been changed from 200 to 2. This appears to be a debugging value that was accidentally left in the code. Training for only 2 epochs is insufficient for model convergence and will result in poor performance. This should be reverted to the original value of 200 or another appropriate value for production use.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed with copilot @JonasETHZ

Copy link
Collaborator

@ffelten ffelten left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a quick pass. I think copilot has some good points, also ruff will probably complain


# Algorithm specific
n_epochs: int = 200
n_epochs: int = 2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed with copilot @JonasETHZ


def sample_from_discretized_mix_logistic(l: th.Tensor, nr_mix: int) -> th.Tensor:
"""Sample from a discretized mixture of logistic distributions."""
# Tensorflow ordering
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some Tensorflow comments left here and there


# unpack parameters
logit_probs = l[:, :, :, :nr_mix] # mixture probabilities
l = l[:, :, :, nr_mix:].contiguous().view([*xs, nr_mix * 2]) # for mean, scale
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very cryptic to me, a comment would help understanding what's going on here.

@JonasETHZ JonasETHZ requested a review from ffelten December 17, 2025 12:27
@markfuge
Copy link
Member

markfuge commented Jan 7, 2026

@ffelten I see that this PR is ready to be merged and that you have approved. Can you confirm that we are all good and that I can merge this? If this is good to go then the only thing I see that needs updating is the README.md to add a row to the table noting the implementation in the library.

@markfuge markfuge mentioned this pull request Jan 7, 2026
6 tasks
@ffelten
Copy link
Collaborator

ffelten commented Jan 7, 2026

@ffelten I see that this PR is ready to be merged and that you have approved. Can you confirm that we are all good and that I can merge this? If this is good to go then the only thing I see that needs updating is the README.md to add a row to the table noting the implementation in the library.

I think it is good to go. Although a bit complex due to the masking ops and slow inference, it is a simple example of an AutoRegressive model--will be a good addition for educational purposes.

@markfuge markfuge merged commit bfc9f38 into IDEALLab:main Jan 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants