ngnrsaa / qflex

Flexible Quantum Circuit Simulator (qFlex) implements an efficient tensor network, CPU-based simulator of large quantum circuits.
Apache License 2.0
97 stars 24 forks source link

Add examples for entering a Docker container #203

Closed 95-martin-orion closed 4 years ago

95-martin-orion commented 4 years ago

Currently, the process for building and testing changes to qFlex with Docker (e.g. when working on a Mac) looks like this:

  1. Make desired change in repository.
  2. Build and test change with docker-compose up --build (takes X minutes) 2a. If all tests pass, you're done.
  3. For issues seen in previous test run, apply fixes to the repository. Return to (2)

The bottleneck here is rebuilding the Docker container, even with something like #198 to speed things up. A faster build/test cycle looks like this:

  1. Make desired change in repository.
  2. Build and test change with docker-compose up --build (takes X minutes) 2a. If all tests pass, you're done.
  3. Enter the docker container using ${COMMAND_TBD} 3a. For issues seen in the previous test run, apply fixes inside the docker container. 3b. Run tests from inside the container using make run-tests (takes XX seconds) 3c. If any tests fail, return to (3a).
  4. Exit the docker container and replicate all changes to the real repository. Return to (2).

We should either add an example of how to enter the docker container, or update existing examples/Dockerfiles to enter the container (similar to the current rootless-container examples).

95-martin-orion commented 4 years ago

Added @s-mandra and @alankao64 for feedback on this. One issue with the second strategy is that I don't know of a good way to perform step (4); when I tried this originally, I copied the changes out manually.

s-mandra commented 4 years ago

The best approach to fix this would be to pinpoint which files to COPY in Dockerfile so that only the relevant layers are updated if some files are missing. Right now, in the most inner layer qflex, we copy everything as COPY ./ /qflex. Therefore, any change in the folder ./ triggers the update of qflex and therefore the recompilation of all layers. This is something I was already thinking about, but it needs some work ..

95-martin-orion commented 4 years ago

The examples requested here are largely unnecessary now - the above changes allow docker-compose up --build to run just about as fast as a normal make would.