This repository has been archived by the owner on Jul 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
[Feature] Main Embedding and ConcretizedCallable logic #1
Draft
dominikandreasseitz
wants to merge
17
commits into
main
Choose a base branch
from
ds/port
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
01635e6
[Feature] Main Embedding and ConcretizedCallable logic
dominikandreasseitz 0296b59
rework to class, add tests
dominikandreasseitz e6dd59f
add arithmetics tests
dominikandreasseitz 0a7fbea
more tests
dominikandreasseitz 2586c0e
mark parametrize
dominikandreasseitz 8457f98
test more fns
dominikandreasseitz 5ac4327
add infra
dominikandreasseitz 081d737
add and test reembedding
dominikandreasseitz 329aed0
rename
dominikandreasseitz 99b7ef6
fix lint
dominikandreasseitz 81ac1c5
simpler version
dominikandreasseitz 98eee1b
docstring
dominikandreasseitz deb1c2f
better version
dominikandreasseitz 2e00a5e
doc
dominikandreasseitz 360d7f7
store also intermediate td params
dominikandreasseitz 4a30d06
ultimate test
dominikandreasseitz ff826b9
only alloc once
dominikandreasseitz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
name: Linting / Tests / Documentation | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'v[0-9]+.[0-9]+.[0-9]+' | ||
pull_request: | ||
branches: | ||
- main | ||
workflow_dispatch: {} | ||
|
||
concurrency: | ||
group: ${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
lint: | ||
name: Linting | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.10"] | ||
steps: | ||
- name: Checkout main code and submodules | ||
uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install hatch | ||
run: | | ||
python -m pip install hatch | ||
- name: Install main dependencies | ||
run: | | ||
python -m hatch -v -e tests | ||
- name: Lint | ||
run: | | ||
python -m hatch -e tests run pre-commit run --all-files | ||
|
||
unit_tests: | ||
name: Unit testing | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.8","3.9", "3.10", "3.11", "3.12"] | ||
steps: | ||
- name: Checkout main code and submodules | ||
uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install hatch | ||
run: | | ||
python -m pip install hatch | ||
- name: Install main dependencies | ||
run: | | ||
python -m hatch -v -e tests | ||
- name: Lint | ||
run: | | ||
python -m hatch -e tests run pre-commit run --all-files | ||
- name: Perform unit tests | ||
run: | | ||
python -m hatch -e tests run pytest -n auto | ||
|
||
test_docs: | ||
name: Documentation | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.10"] | ||
steps: | ||
- name: Checkout main code and submodules | ||
uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install hatch | ||
run: | | ||
python -m pip install hatch | ||
- name: Install main dependencies | ||
run: | | ||
python -m hatch -v -e docs | ||
- name: Test docs | ||
run: | | ||
python -m hatch run docs:build | ||
|
||
publish: | ||
name: Publish to PyPI | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
needs: unit_tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout main code and submodules | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.ref }} | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install hatch | ||
- name: Build and publish package | ||
run: | | ||
hatch build | ||
hatch publish -u __token__ -a ${{ secrets.PYPI_API_TOKEN }} | ||
- name: Confirm deployment | ||
timeout-minutes: 5 | ||
run: | | ||
VERSION=${GITHUB_REF#refs/tags/v} | ||
until pip download qadence-embeddings==$VERSION | ||
do | ||
echo "Failed to download from PyPI, will wait for upload and retry." | ||
sleep 1 | ||
done | ||
|
||
deploy_docs: | ||
name: Deploy documentation | ||
if: startsWith(github.ref, 'refs/tags/v') | ||
needs: unit_tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout main code and submodules | ||
uses: actions/checkout@v4 | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10' | ||
- name: Install Hatch | ||
run: | | ||
pip install hatch | ||
- name: Deploy docs | ||
run: | | ||
git config user.name "GitHub Actions" | ||
git config user.email "actions@github.com" | ||
git fetch origin gh-pages | ||
hatch -v run docs:mike deploy --push --update-aliases ${{ github.ref_name }} latest |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: end-of-file-fixer | ||
- id: check-yaml | ||
- id: check-added-large-files | ||
|
||
- repo: https://github.com/ambv/black | ||
rev: 24.4.2 | ||
hooks: | ||
- id: black | ||
|
||
- repo: https://github.com/charliermarsh/ruff-pre-commit | ||
rev: "v0.4.4" | ||
hooks: | ||
- id: ruff | ||
args: [--fix] | ||
|
||
|
||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: v1.10.0 | ||
hooks: | ||
- id: mypy | ||
exclude: examples|docs |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
# qadence-embeddings | ||
# qadence-embeddings | ||
|
||
**qadence-embeddings** is a engine-agnostic parameter embedding library. | ||
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
::: qadence_embeddings.callable.ConcretizedCallable | ||
::: qadence_embeddings.embedding.Embedding |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
site_name: qadence-embeddings | ||
repo_url: "https://github.com/pasqal-io/qadence-embeddings" | ||
repo_name: "qadence-embeddings" | ||
|
||
nav: | ||
|
||
- Embeddings in a nutshell: index.md | ||
|
||
|
||
theme: | ||
name: material | ||
features: | ||
- content.code.annotate | ||
- navigation.indexes | ||
- navigation.sections | ||
|
||
palette: | ||
- media: "(prefers-color-scheme: light)" | ||
scheme: default | ||
primary: light green | ||
accent: purple | ||
toggle: | ||
icon: material/weather-sunny | ||
name: Switch to dark mode | ||
- media: "(prefers-color-scheme: dark)" | ||
scheme: slate | ||
primary: black | ||
accent: light green | ||
toggle: | ||
icon: material/weather-night | ||
name: Switch to light mode | ||
|
||
markdown_extensions: | ||
- admonition # for notes | ||
- pymdownx.arithmatex: # for mathjax | ||
generic: true | ||
- pymdownx.highlight: | ||
anchor_linenums: true | ||
- pymdownx.inlinehilite | ||
- pymdownx.snippets | ||
- pymdownx.superfences | ||
|
||
plugins: | ||
- search | ||
- section-index | ||
- mkdocstrings: | ||
default_handler: python | ||
handlers: | ||
python: | ||
selection: | ||
filters: | ||
- "!^_" # exlude all members starting with _ | ||
- "^__init__$" # but always include __init__ modules and methods | ||
|
||
- mkdocs-jupyter: | ||
theme: light | ||
- markdown-exec | ||
|
||
extra_css: | ||
- extras/css/mkdocstrings.css | ||
- extras/css/colors.css | ||
- extras/css/home.css | ||
|
||
# For mathjax | ||
extra_javascript: | ||
- extras/javascripts/mathjax.js | ||
- https://polyfill.io/v3/polyfill.min.js?features=es6 | ||
- https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js | ||
|
||
watch: | ||
- qadence_embeddings |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" | ||
|
||
[project] | ||
name = "qadence-embeddings" | ||
description = "a engine-agnostic parameter embedding library." | ||
authors = [ | ||
{ name = "Dominik Seitz", email = "dominik.seitz@pasqal.com" }, | ||
] | ||
requires-python = ">=3.8,<3.13" | ||
license = {text = "Apache 2.0"} | ||
version = "1.3.0" | ||
classifiers=[ | ||
"License :: OSI Approved :: Apache Software License", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
"Programming Language :: Python :: Implementation :: CPython", | ||
"Programming Language :: Python :: Implementation :: PyPy", | ||
] | ||
dependencies = ["torch", "numpy", "jax"] | ||
|
||
[project.optional-dependencies] | ||
dev = ["flaky","black", "pytest", "pytest-xdist", "pytest-cov", "flake8", "mypy", "pre-commit", "ruff", "nbconvert", "matplotlib", "qutip~=4.7.5"] | ||
|
||
[tool.hatch.envs.tests] | ||
features = [ | ||
"dev", | ||
] | ||
|
||
[tool.hatch.envs.tests.scripts] | ||
test = "pytest -n auto {args}" | ||
test-docs = "hatch -e docs run mkdocs build --clean --strict" | ||
test-cov = "pytest -n auto --cov=qadence-embeddings tests/" | ||
|
||
[tool.hatch.envs.docs] | ||
dependencies = [ | ||
"mkdocs", | ||
"mkdocs-material", | ||
"mkdocstrings", | ||
"mkdocstrings-python", | ||
"mkdocs-section-index", | ||
"mkdocs-jupyter", | ||
"mkdocs-exclude", | ||
"markdown-exec", | ||
"mike", | ||
"matplotlib", | ||
] | ||
|
||
[tool.hatch.envs.docs.scripts] | ||
build = "mkdocs build --clean --strict" | ||
serve = "mkdocs serve --dev-addr localhost:8000" | ||
|
||
[tool.ruff] | ||
lint.select = ["E", "F", "I", "Q"] | ||
lint.extend-ignore = ["F841"] | ||
line-length = 100 | ||
|
||
[tool.ruff.lint.isort] | ||
required-imports = ["from __future__ import annotations"] | ||
|
||
[tool.ruff.lint.per-file-ignores] | ||
"__init__.py" = ["F401", "E402"] | ||
|
||
[tool.ruff.lint.mccabe] | ||
max-complexity = 15 | ||
|
||
[tool.ruff.lint.flake8-quotes] | ||
docstring-quotes = "double" | ||
|
||
[lint.black] | ||
line-length = 100 | ||
include = '\.pyi?$' | ||
exclude = ''' | ||
/( | ||
\.git | ||
| \.hg | ||
| \.mypy_cache | ||
| \.tox | ||
| \.venv | ||
| _build | ||
| buck-out | ||
| build | ||
| dist | ||
)/ | ||
''' | ||
|
||
[lint.isort] | ||
line_length = 100 | ||
combine_as_imports = true | ||
balanced_wrapping = true | ||
lines_after_imports = 2 | ||
include_trailing_comma = true | ||
multi_line_output = 5 | ||
|
||
[lint.mypy] | ||
python_version = "3.10" | ||
warn_return_any = true | ||
warn_unused_configs = true | ||
disallow_untyped_defs = true | ||
no_implicit_optional = false | ||
ignore_missing_imports = true |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from __future__ import annotations | ||
|
||
from .callable import ConcretizedCallable | ||
from .embedding import Embedding |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.