Change storagetype to UInt8 Dynkin labels to reduce memory footprint#46
Change storagetype to UInt8 Dynkin labels to reduce memory footprint#46
UInt8 Dynkin labels to reduce memory footprint#46Conversation
Codecov Report❌ Patch coverage is
🚀 New features to boost your workflow:
|
|
Both changes would definitely be ok with me; in particular I think Dynkin labels make sense if we anyway go through the effort of having tuples of length But you quoted the benefit of currently still having the same hash, which would be advantageous for disk-based caches, whereas the hash would definitely change with either of those two changes? |
|
Well, technically I could force the hash to remain the same, but I would indeed feel way less comfortable about that since we do actually call the hash function quite a lot in TensorKit as well. On the flipside of that though, changing to the I do think though that the files on disk should remain valid, since that is all stored with actual text files (the key there being |
|
Well, another issue might be that your current convention is that Dynkin labels come in a vector, whereas weights come in a tuple (of length |
|
Hence, if you want to construct both tuple weights and tuple dynkin labels in the constructor, you can no longer infer |
UInt8 to reduce memory footprintUInt8 Dynkin labels to reduce memory footprint
Replace all direct s.I field accesses in internal code with weight(s), and update Base.getproperty to route s.I through weight(s) for backward compatibility. Pure refactor — no behavioral change. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
8× memory reduction per irrep. The weight() accessor now promotes UInt8 to Int on access, so UInt8 never leaks into arithmetic or public API. Constructors validate that all weight components fit in [0, 255]. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
@Jutho apologies for exploding this PR, but I didn't really see an easy way of incrementally doing this change. I ended up making this breaking as discussed, and now store the I also took the time to clean up a bunch of the file organization since I wasn't a big fan of having (some of) the code in the SUNRepresentations.jl file and some code in the other files, and I needed to migrate things around anyways. I think I'm okay with merging this and tagging this as a breaking release in its current state, so let me know what you think and feel free to do so :) |
This change fixes #45, storing the weights as
UInt8values rather thanInt.This does limit the maximal weight to
255, although that seems reasonable for now?This being said, there are 2 further changes we should discuss, before tagging this (Breaking) release.
The first is whether we want to reduce the storage slightly more, by getting rid of the last entry of
a.Iwhich necessarily has to be0. This is another1 / Nreduction in required storage, but would incur another type parameter to fix the length of the tuple toM = N - 1.The second, which is slightly related is whether we want to instead store Dynkin labels, and compute the weights dynamically from that.
IIRC, this is simply
diff(weight(a)), which therefore also can be stored as anNTuple{N - 1, UInt8}, but with the difference that these no longer have to form a non-increasing sequence.This slightly expands the range of possible sectors that can be represented within the
UInt8tuples, but otherwise has the same drawback of needing another type parameterM = N - 1Keep in mind that all of this concerns only the internal storage types, and accessor functions would still be available for either information.