hls4ml icon indicating copy to clipboard operation
hls4ml copied to clipboard

Integration of PQuantML with hls4ml

Open enlupi opened this issue 1 month ago • 2 comments

Description

This PR introduces the possibility of directly parsing PQuantML layers into hls4ml, both using the PyTorch and Keras V3 frontend. It uses HGQ2 conventions and relies on the bit_exact optimization pass to ensure correct precision is enforced and bit exactness.

Type of change

  • [x] New feature (non-breaking change which adds functionality)

Tests

Tests are present both for PyTorch and Keras V3 frontend: test_pquant_pytoch.py and test_pquant_keras.py.

Checklist

  • [x] I have read the guidelines for contributing.
  • [x] I have commented my code, particularly in hard-to-understand areas.
  • [x] I have made corresponding changes to the documentation.
  • [x] My changes generate no new warnings.
  • [x] I have installed and run pre-commit on the files I edited or added.
  • [x] I have added tests that prove my fix is effective or that my feature works.

enlupi avatar Nov 19 '25 08:11 enlupi

What's the plan for installing PQuant together with hls4ml? In principle, we should have pquant-ml defined as an optional dependency in the pyproject.toml. I see that the tool is available via pypi (https://libraries.io/pypi/pquant-ml), but just doing pip install pquant-ml in an empty conda environment with python 3.11 doesn't work for me because of version conflicts that prevent tensorflow from being installed. So I'm not sure the version available via pypi is up to date.

I expect the pytests to fail currently because of this. We are preparing a dedicated testing container with keras 3 that should be able to be used for this going forward, but that would then need the proper installation instructions for pquant to work.

Also, would be nice to have the documentation update included in this PR ;)

JanFSchulte avatar Dec 08 '25 19:12 JanFSchulte

What's the plan for installing PQuant together with hls4ml? In principle, we should have pquant-ml defined as an optional dependency in the pyproject.toml.

I have now included it.

doing pip install pquant-ml in an empty conda environment with python 3.11 doesn't work for me because of version conflicts that prevent tensorflow from being installed.

This is a known issue for the PQuantML team and they are trying to solve it. As far as I have understood, the problem is due to pip trying to install the wrong version of tensorflow, and the only solution at the moment is "manually" installing it with conda.

Also, would be nice to have the documentation update included in this PR ;)

Added :)

enlupi avatar Dec 09 '25 14:12 enlupi