Skip to content

Add ClavaDDPM to SDGym multi table synthesizers - #630

Open
sarahmish wants to merge 25 commits into
mainfrom
clavaddpm
Open

Add ClavaDDPM to SDGym multi table synthesizers#630
sarahmish wants to merge 25 commits into
mainfrom
clavaddpm

Conversation

@sarahmish

@sarahmish sarahmish commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

original implementation is https://github.com/weipang142857/ClavaDDPM

The important class to review is ClavaDDPM and ClavaDDPMSynthesizer as these are the wrappers I wrote. I've written other code pieces, if it's taken from the source code directly, I mention "from" in the docstrings.

@sarahmish
sarahmish requested a review from a team as a code owner July 22, 2026 22:12
@sarahmish
sarahmish requested review from R-Palazzo and amontanez24 and removed request for a team July 22, 2026 22:12
@sarahmish sarahmish self-assigned this Jul 22, 2026
@codecov

codecov Bot commented Jul 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 81.63558% with 128 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.50%. Comparing base (9b1f0f7) to head (ec384ac).

Files with missing lines Patch % Lines
sdgym/synthesizers/clavaddpm.py 81.47% 128 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #630      +/-   ##
==========================================
- Coverage   86.86%   86.50%   -0.37%     
==========================================
  Files          41       42       +1     
  Lines        4409     5104     +695     
==========================================
+ Hits         3830     4415     +585     
- Misses        579      689     +110     
Flag Coverage Δ
integration 55.83% <79.62%> (+4.14%) ⬆️
unit 76.09% <31.42%> (-7.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sarahmish
sarahmish requested a review from frances-h July 27, 2026 17:18
@sarahmish
sarahmish requested a review from pvk-developer July 29, 2026 18:21

@pvk-developer pvk-developer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When fitting I also see the steps (they come from TabDDPM), if verbose is set to False do we need to display them?

Comment thread sdgym/synthesizers/clavaddpm.py Outdated
Comment thread sdgym/synthesizers/clavaddpm.py Outdated
Comment thread sdgym/synthesizers/clavaddpm.py Outdated
Comment thread sdgym/synthesizers/clavaddpm.py Outdated
Comment thread sdgym/synthesizers/clavaddpm.py Outdated
@pvk-developer

pvk-developer commented Jul 31, 2026

Copy link
Copy Markdown
Member

During fit there is a point where MLoss and GLoss start to produce nan values, should we stop there for that table?

Step 9000/25000 MLoss: 2.7555 GLoss: 0.9242 Sum: 3.6797
Step 9500/25000 MLoss: nan GLoss: nan Sum: nan
...
Step 24500/25000 MLoss: nan GLoss: nan Sum: nan
Step 25000/25000 MLoss: nan GLoss: nan Sum: nan

@sarahmish
sarahmish removed the request for review from frances-h August 3, 2026 11:31
@sarahmish

Copy link
Copy Markdown
Contributor Author

During fit there is a point where MLoss and GLoss start to produce nan values, should we stop there for that table?

I lean towards keeping it as faithful to the original implementation as possible. Sometimes nan indicates that this model doesn't work for a particular dataset on this synthesizer.

@sarahmish
sarahmish requested a review from pvk-developer August 3, 2026 13:01
Base automatically changed from tabddpm to main August 3, 2026 13:55
Comment thread sdgym/synthesizers/clavaddpm.py
Comment thread sdgym/synthesizers/clavaddpm.py Outdated
@sarahmish
sarahmish requested a review from amontanez24 August 5, 2026 13:07
Comment thread sdgym/synthesizers/clavaddpm.py Outdated
Comment thread sdgym/synthesizers/clavaddpm.py Outdated

@R-Palazzo R-Palazzo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is looking good!

I’m still reviewing the logic and checking that it aligns with their implementation. In the meantime, I’m thinking about two things:

  1. For the structure, we could either:
  • Define a clavaddpm folder where we keep files such as pipeline_modules.py and preprocess_utils.py, along with our SDGym logic.
  • Keep everything in one file, but be more explicit about what comes from their implementation versus what we added. It could look something like:
######################### SDGym extra logic #########################

def get_group_data_dict(np_data, group_id_attrs=[0]):
    """Grouping dictionary from pipeline_utils.py."""
    group_data_dict = {}
    data_len = len(np_data)
    for i in range(data_len):
        row_id = tuple(np_data[i, group_id_attrs])
        if row_id not in group_data_dict:
            group_data_dict[row_id] = []
        group_data_dict[row_id].append(np_data[i])
    return group_data_dict


######################## From preprocess_utils.py ###################

def get_domain(df, id_cols, discrete_cols):
    """Build the ``{col: {'size', 'type'}}`` domain of a table from preprocess_utils.py."""
    domain = {}
    for col in df.columns:
        if col in discrete_cols:
            domain[col] = {'size': len(df[col].unique()), 'type': 'discrete'}
        elif col not in id_cols:
            domain[col] = {'size': len(df[col].unique()), 'type': 'continuous'}

    return domain
.
.
.
######################## From pipeline_modules.py ###################
.
.
.
  1. Would it be possible to have an integration test that runs the SDGym ClavaDDPM implementation against their original implementation and checks that the results are the same or similar? It would be nice to have, although I’m not sure how feasible it is. It might require adding their repo as a test dependency.

Comment thread sdgym/synthesizers/clavaddpm.py Outdated
Comment thread sdgym/synthesizers/clavaddpm.py Outdated
Comment thread sdgym/synthesizers/clavaddpm.py Outdated
Comment thread sdgym/synthesizers/clavaddpm.py Outdated
Comment thread sdgym/synthesizers/clavaddpm.py Outdated
Comment thread sdgym/synthesizers/clavaddpm.py Outdated
Comment thread sdgym/synthesizers/clavaddpm.py Outdated
Comment on lines +213 to +214
encoder's fitted range get fresh values: numeric ids continue after the
largest original id, other ids become new ``'{column}_{code}'`` strings.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we need to handle the numerical case here?

In l875 and l883 we're skipping the encoder for numerical ids

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is additional logic from our side. ClavaDDPM requires id columns to be numeric values, so I added logic to encode non-numerical ids, which is why I added this part during decoding.

If the column is already numeric, the code defaults to expected ClavaDDPM behavior.

Comment thread sdgym/synthesizers/clavaddpm.py Outdated
Comment thread sdgym/synthesizers/clavaddpm.py Outdated
Comment thread sdgym/synthesizers/clavaddpm.py
@R-Palazzo
R-Palazzo self-requested a review August 17, 2026 12:47
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.

4 participants